Ejemplo n.º 1
0
void CommonAPI::Init(HookWrapper* h)
{
	hook = h;
	exePath = GetExecutablePath();

	// Init logging
	FILE* logFile = fopen("touchenabler.log", "w");
	Output2FILE::Stream() = logFile;

	// Init AS
	InitAS();

	// Init Vjoy
	//InitVjoy();

	// Init Input
	InitInput();

	//InitTouch();
	
	if (!SetWindowSubclass(hook->windowHandle,  &WindowProcSubclass, 0, 0))
    {
		FILE_LOG(logERROR) << "Unable to subclass HWND.";
    }


	CallScriptFunction("void OnLoad()");

}
Ejemplo n.º 2
0
int EXPORT HUD_Init( void )
{
	InitInput();
	gHUD.Init();
	Scheme_Init();
	return 1;
}
Ejemplo n.º 3
0
Archivo: main.c Proyecto: idmit/accomb
int main(int argc, const char * argv[])
{
    List *cmnds = NULL;
    char *string = NULL;
    int quit = 0;
    
    ErrorCode errorCode = ERRORCODE_NO_ERROR, endOfFile = ERRORCODE_NO_ERROR;
    
    CATCH_ERROR(InitInput(&string), errHandler); // allocating input string
    MEM(string, initialError); // checking if allocation was successful, otherwise quiting
    
    while (endOfFile == ERRORCODE_NO_ERROR && quit != 1) // ends on <quit> command
    {
        ReleaseList(&cmnds); // releasing list of tokens
        endOfFile = ReadStringFromStream(stdin, &string); // reading string of unknown length
        CATCH_ERROR(Tokenize(string, &cmnds), errHandler); // creating a list of tokens from input string
        CATCH_ERROR(Route(cmnds, &quit), errHandler); // trying to find a matching method
        
        errHandler:
            PrintErrorFeedback(errorCode); // on error printing feedback info and continuing main loop
    }
    
    ReleaseList(&cmnds); // after escaping while
    ReleaseInput(string);
    
    return 0;
    
    initialError:
        return 1;
}
Ejemplo n.º 4
0
int mhemain(char* romName)
{
	clearScreen();
	console_write(romName,COLOR_GREEN);
	console_write("Loading...",COLOR_GREEN);

    handleInputFile(romName);

	InitInput();

	clearScreen();

    sound_system_init();

	gp_startSound();

    ngpc_run();

	gp_stopSound();

	if (autosave)
		flashShutdown();

	return 0;
}
Ejemplo n.º 5
0
bool VistaDirectXGamepad::Connect()
{
	if(InitInput())
	{
		// create and attach a single sensor
		VistaDeviceSensor *pSensor = new VistaDeviceSensor;
		//pSensor->SetTypeHint( VistaDirectXGamepad::GetDriverFactoryMethod()->GetTypeFor("") );
		pSensor->SetTypeHint(GetFactory()->GetTypeFor(""));

		pSensor->SetMeasureTranscode( GetFactory()->GetTranscoderFactoryForSensor("")->CreateTranscoder() );
		pSensor->SetTypeHint( GetFactory()->GetTypeFor("") );

		// this call will allocate the default number of history slots
		// (hopefully set for by the user)
		AddDeviceSensor(pSensor);

		// set the correct button number in the transcoder
		IVistaMeasureTranscode *pTrans = pSensor->GetMeasureTranscode();

		pTrans->SetNumberOfScalars( 7 + m_nNumberOfButtons );


		//@CHANGE: This is done by SensorUpdate	
		/*
		VistaDirectXGamepadScalarTranscode *pTranscode
		= dynamic_cast<VistaDirectXGamepadScalarTranscode*>
			(pTrans->GetMeasureProperty("DSCALAR")->);

		pTranscode->m_nBtOffset = m_nNumberOfButtons;
		*/
		
        return true;
	}
    return false;
}
Ejemplo n.º 6
0
void DLLEXPORT HUD_Init( void )
{
	InitInput();
	gHUD.Init();

	gEngfuncs.pfnHookUserMsg( "Bhopcap", __MsgFunc_Bhopcap );
}
Ejemplo n.º 7
0
//-----------------------------------------------------------------------------
// Name: OneTimeSceneInit()
// Desc: Called during initial app startup, this function performs all the
//       permanent initialization.
//-----------------------------------------------------------------------------
HRESULT CMyApplication::OneTimeSceneInit()
{
    HRESULT hr;
    
    // Load the icon
    HICON hIcon = LoadIcon( GetModuleHandle(NULL), MAKEINTRESOURCE( IDI_MAIN ) );
    
    // Set the icon for this dialog.
    SendMessage( m_hWnd, WM_SETICON, ICON_BIG,   (LPARAM) hIcon );  // Set big icon
    SendMessage( m_hWnd, WM_SETICON, ICON_SMALL, (LPARAM) hIcon );  // Set small icon
    
    // Initialize DirectInput
    if( FAILED( hr = InitInput() ) )
        return DXTRACE_ERR( TEXT("InitInput"), hr );
    
    HWND hNumPlayers = GetDlgItem( m_hWnd, IDC_NUM_PLAYERS_COMBO );
    SendMessage( hNumPlayers, CB_ADDSTRING, 0, (LPARAM) TEXT("1") );
    SendMessage( hNumPlayers, CB_ADDSTRING, 0, (LPARAM) TEXT("2") );
    SendMessage( hNumPlayers, CB_ADDSTRING, 0, (LPARAM) TEXT("3") );
    SendMessage( hNumPlayers, CB_ADDSTRING, 0, (LPARAM) TEXT("4") );
    SendMessage( hNumPlayers, CB_SETCURSEL, m_dwNumPlayers-1, 0 );

    EnableUI();
    
    return S_OK;
}
Ejemplo n.º 8
0
int main(int argc, char* argv[])
{
	//初始化NGE分为VIDEO,AUDIO,这里是只初始化VIDEO,如果初始化所有用INIT_VIDEO|INIT_AUDIO,或者INIT_ALL
	NGE_Init(INIT_VIDEO);
	//初始化按键处理btn_down是按下响应,后面是弹起时的响应,0是让nge处理home消息(直接退出),填1就是让PSP系统处理
	//home消息,通常填1正常退出(1.50版的自制程序需要填0)
	InitInput(btn_down,NULL,1);
	//最后一个参数是psp swizzle优化,通常填1
	p_bg = image_load("images/demo0.jpg",DISPLAY_PIXEL_FORMAT_8888,1);
	if(p_bg == NULL) {
		printf("can not open file\n");
	}
	p_logo = image_load("images/nge2logo.png",DISPLAY_PIXEL_FORMAT_4444,1);
	if(p_logo == NULL) {
		printf("can not open file\n");
	}
	//创建一个半透明的图片遮罩color
	logomask1 = CreateColor(255,255,255,128,p_logo->dtype);
	//随便创建一个图片遮罩color
	logomask2 = CreateColor(100,100,100,255,p_logo->dtype);

	while ( !game_quit )
	{
		ShowFps();
		InputProc();
		DrawScene();
	}
	image_free(p_bg);
	image_free(p_logo);
	NGE_Quit();
	return 0;
}
Ejemplo n.º 9
0
void CL_DLLEXPORT HUD_Init( void )
{
//	RecClHudInit();
	InitInput();
	gHUD.Init();
	Scheme_Init();
}
Ejemplo n.º 10
0
bool RDGpio::open()
{
  int ver;
  
  if(gpio_open) {
    return false;
  }
  if((gpio_fd=::open((const char *)gpio_device,O_RDONLY|O_NONBLOCK))<0) {
    return false;
  }
  if(ioctl(gpio_fd,GPIO_GETINFO,&gpio_info)==0) {
    gpio_api=RDGpio::ApiGpio;
    InitGpio();
    RemapTimers();
  }
  else {
    if(ioctl(gpio_fd,EVIOCGVERSION,&ver)==0) {
      gpio_api=RDGpio::ApiInput;
      InitInput();
    }
    else {
      ::close(gpio_fd);
      return false;
    }
  }
  gpio_open=true;
  gpio_input_timer->start(GPIO_CLOCK_INTERVAL);
  return true;
}
Ejemplo n.º 11
0
void DLLEXPORT HUD_Init( void )
{
	InitInput();
	gHUD.Init();
#ifndef NO_VGUI
	Scheme_Init();
#endif
}
Ejemplo n.º 12
0
int main(int argc, char* argv[])
{
	PFont pf[2] ;
	int i;

	NGE_Init(INIT_VIDEO);
	//NGE_SetFontEncoding(NGE_ENCODING_UTF_8);
	InitInput(btn_down,btn_up,1);

	int maxid = GetInfoCount();
	//创建一个显示image,字就显示在这个上面注意DISPLAY_PIXEL_FORMAT必须与创建字体的DISPLAY_PIXEL_FORMAT一致
	pimage_text = image_create(512,512,DISPLAY_PIXEL_FORMAT_4444);
	//创建字体
	pf[0] = create_font_hzk("fonts/GBK14","fonts/ASC14",14,DISPLAY_PIXEL_FORMAT_4444);
	pf[1] = create_font_freetype("fonts/simfang.ttf",13,DISPLAY_PIXEL_FORMAT_4444);
	char str[3][128]={"【小萝莉】","众芳摇落独暄妍,占尽风情向小园。","疏影横斜水清浅,暗香浮动月黄昏。"};
	//显示GBK Font
	font_setcolor(pf[0],MAKE_RGBA_4444(128,0,0,255));
	font_drawtext(pf[0],str[0],strlen(str[0]),pimage_text,100,195,FONT_SHOW_NORMAL);
	NGE_SetFontEncoding(NGE_ENCODING_GBK);
	for(i = 0;i<maxid;i++){
		font_drawtext(pf[0],CreateInfoByid(i),strlen(CreateInfoByid(i)),pimage_text,120,200+i*20,FONT_SHOW_SHADOW);
		font_setcolor(pf[0],MAKE_RGBA_4444(255,0,0,255));
	}

	//显示freetype
	font_setcolor(pf[1],MAKE_RGBA_4444(128,0,0,255));
	NGE_SetFontEncoding(NGE_ENCODING_UTF_8);
	font_drawtext(pf[1],str[0],strlen(str[0]),pimage_text,100,30,FONT_SHOW_NORMAL);
	//for(i =1;i<3;i++){
	//	font_drawtext(pf[1],str[i],strlen(str[i]),pimage_text,120,35+i*20,FONT_SHOW_NORMAL);
	//	font_setcolor(pf[1],MAKE_RGBA_4444(255,0,0,255));
	//}
	pimage_bg = image_load("images/demo1_bg.jpg",DISPLAY_PIXEL_FORMAT_8888,1);
	if(pimage_bg == NULL) {
		printf("can not open file\n");
	}
	pimage_box = image_load("images/demo1_box.jpg",DISPLAY_PIXEL_FORMAT_8888,1);
	if(pimage_box == NULL) {
		printf("can not open file\n");
	}
	pimage_icon[0] = image_load_colorkey("images/demo1_icon0.bmp",DISPLAY_PIXEL_FORMAT_8888,MAKE_RGB(0,0,0),1);
	pimage_icon[1] = image_load_colorkey("images/demo1_icon1.png",DISPLAY_PIXEL_FORMAT_8888,MAKE_RGB(0,0,0),1);
	while ( !game_quit )
	{
		ShowFps();
		InputProc();
		DrawScene();
	}
	font_destory(pf[0]);
	font_destory(pf[1]);
	image_free(pimage_bg);
	image_free(pimage_text);
	image_free(pimage_box);
	NGE_Quit();
	return 0;
}
Ejemplo n.º 13
0
int main(int argc, char* argv[])
{
    SetSphereDirectory();

    // load the configuration settings, then save it for future reference
    SPHERECONFIG config;
    LoadSphereConfiguration(&config);

    for (int i = 0; i < 4; i++)
    {
        SetPlayerConfig(i,
                KeyStringToKeyCode(config.player_configurations[i].key_menu_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_up_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_down_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_left_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_right_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_a_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_b_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_x_str.c_str()),
                KeyStringToKeyCode(config.player_configurations[i].key_y_str.c_str()),
                config.player_configurations[i].keyboard_input_allowed,
                config.player_configurations[i].joypad_input_allowed);
    }

	SetGlobalConfig(config.language, config.sound, config.allow_networking);
    SaveSphereConfig(&config, (GetSphereDirectory() + "/engine.ini").c_str());

    // initialize screenshot directory
    std::string sphere_directory;
    char screenshot_directory[512];
    GetDirectory(sphere_directory);
    sprintf(screenshot_directory, "%s/screenshots", sphere_directory.c_str());
    SetScreenshotDirectory(screenshot_directory);

    // initialize video subsystem
    if (InitVideo(&config) == false)
    {
        printf("Video subsystem could not be initialized...\n");
        return 0;
    }

    // initialize input
    InitInput();

    // initialize audio
    if (!InitAudio(&config))
    {
        printf("Sound could not be initialized...\n");
    }

    atexit(CloseVideo);
    atexit(CloseAudio);

    RunSphere(argc, const_cast<const char **>(argv));

    return 0;
}
Ejemplo n.º 14
0
		void Application::Init()
		{
			InitAppPreServices();
			InitPrimaryWindow();
			InitGraphics();
			InitInput();
			InitSound();
			InitExtraSubsystems();
			InitAppPostServices();
		}
Ejemplo n.º 15
0
void xrSASH::TryInitEngine( bool bNoRun)
{
	if (m_bReinitEngine)
	{
		InitEngine();
		//	It was destroyed on previous exit
		Console->Initialize();
	}

	xr_strcpy						(Console->ConfigFile,"user.ltx");
	if (strstr(Core.Params,"-ltx ")) 
	{
		string64				c_name;
		sscanf					(strstr(Core.Params,"-ltx ")+5,"%[^ ] ",c_name);
		xr_strcpy				(Console->ConfigFile,c_name);
	}

	if(strstr(Core.Params,"-r2a"))	
		Console->Execute			("renderer renderer_r2a");
	else if(strstr(Core.Params,"-r2"))	
		Console->Execute			("renderer renderer_r2");
	else
	{
		CCC_LoadCFG_custom*	pTmp = xr_new<CCC_LoadCFG_custom>("renderer ");
		pTmp->Execute				(Console->ConfigFile);
		if (m_bOpenAutomate)
			pTmp->Execute				("SASH.ltx");
		else
			pTmp->Execute				(Console->ConfigFile);
		xr_delete					(pTmp);
	}

	InitInput();

	Engine.External.Initialize( );

	if (bNoRun)
		InitSound1();

	Console->Execute			("unbindall");
	Console->ExecuteScript		(Console->ConfigFile);
	if (m_bOpenAutomate)
	{
		//	Overwrite setting using SASH.ltx if has any.
		xr_strcpy(Console->ConfigFile,"SASH.ltx");
		Console->ExecuteScript		(Console->ConfigFile);
	}

	if (bNoRun)
	{
		InitSound2();
		Device.Create();
	}

}
Ejemplo n.º 16
0
void DLLEXPORT HUD_Init( void )
{
	InitInput();
	gHUD.Init();
	Scheme_Init();
	
	SetupLogging (); // buz

	// buz: enable CrashRpt library
	LoadCrashRpt();
}
Ejemplo n.º 17
0
/**
 * AppInit()
 */
int AppInit(HINSTANCE hInst)
{
	CreateConsole();

	if(!InitD3D(hInst, windowed, screenWidth, screenHeight, multisampleType, multisampleQuality, HWnd, &D3D, &D3DDevice))
		return 0;

	if(!InitInput(hInst, HWnd, &DI, &DID_Keyboard, &DID_Mouse))
		return 0;

	return 1;
}
Ejemplo n.º 18
0
int main() {
    int   n = 1;
    char *key;
    char *value;

    /*  Get key/value pairs from input  */

    if ( !InitInput(1000) )
	DisplayErrorHTML();

    
    /*  Output HTML header  */

    printf("Content-Type: text/html\n\n");

    printf("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 4.0//EN\">\n\n");
    printf("<HTML>\n\n<HEAD>\n");
    printf("    <TITLE>Formecho Output</TITLE>\n");
    printf("</HEAD>\n\n");
    printf("<BODY>\n\n");


    /*  Output table of key/value pairs  */

    printf("<TABLE BORDER=1 CELLPADDING=10px>\n\n");
    printf("    <TR>\n");
    printf("        <TH>Key</TH>\n\n");
    printf("        <TH>Value</HT>\n\n");
    printf("    </TR>\n\n");

    while ( (key = GetIndexedKey(n)) && (value = GetIndexedValue(n)) ) {
	printf("    <TR>\n");
	printf("        <TD>%s</TD>\n", key);
	printf("        <TD>%s</TD>\n", value);
	printf("    </TR>\n\n");
	++n;
    }

    printf("</TABLE>\n\n");


    /*  Output HTML footer  */

    printf("</BODY>\n\n</HTML>\n\n");


    /*  Clean up and exit  */

    FreeCGI();
    return 0;
}
Ejemplo n.º 19
0
Game::Game(int fps, int width, int height)
{
    mWidth = width;
    mHeight = height;
    mFPS = fps;
    GameGlobal::SetWidth(width);
    GameGlobal::SetHeight(height);
    InitInput();

    Scene *newScene = new TestScene();
    SceneManager::GetInstance()->ReplaceScene(newScene);

    LoadContent();
    InitLoop();
}
Ejemplo n.º 20
0
HRESULT Application::Initialise(HINSTANCE hInstance, int nCmdShow)
{
    if (FAILED(InitWindow(hInstance, nCmdShow)))
	{
        return E_FAIL;
	}

    RECT rc;
    GetClientRect(_hWnd, &rc);
    _WindowWidth = rc.right - rc.left;
    _WindowHeight = rc.bottom - rc.top;

	//inits device
    if (FAILED(InitDirectX()))
    {
        Cleanup();

        return E_FAIL;
    }

	//inits input
	if (FAILED(InitInput(hInstance)))
	{
		Cleanup();

		return E_FAIL;
	}

	// Initialize the world matrix
	XMStoreFloat4x4(&_cube1, XMMatrixIdentity());
	XMStoreFloat4x4(&_cube2, XMMatrixIdentity());

	_cubbe1.Initialise(_pd3dDevice);
	_cubbe2.Initialise(_pd3dDevice);

	//inits camera (view matrix)
	if (FAILED(_cam.Initialise()))
	{
		Cleanup();

		return E_FAIL;
	}

    // Initialize the projection matrix
	XMStoreFloat4x4(&_projection, XMMatrixPerspectiveFovLH(XM_PIDIV2, _WindowWidth / (FLOAT) _WindowHeight, 1.0f, 100.0f));

	return S_OK;
}
Ejemplo n.º 21
0
// enter shell state
void EnterShellState()
{
	// set up drawlists
	InitDrawlists();

	// create default font
	CreateDefaultFont();

	// clear the screen
	glClear(
		GL_COLOR_BUFFER_BIT
#ifdef ENABLE_DEPTH_TEST
		| GL_DEPTH_BUFFER_BIT
#endif
		);

	// show back buffer
	Platform::Present();

	// reset simulation timer
	sim_rate = float(SIMULATION_RATE);
	sim_step = 1.0f / sim_rate;
	sim_turn = 0;
	sim_fraction = 1.0f;

	// input binding
	InitInput(INPUT_CONFIG.c_str());

	// level configuration
	InitLevel("shell.xml");

	// create options overlay
	shellmenu.mActive = NULL;
	shellmenu.Push(&shellmenumainpage);
	Overlay *options = new Overlay(0xef286ca5 /* "options" */);
	Database::overlay.Put(0xef286ca5 /* "options" */, options);
	options->SetAction(Overlay::Action(RenderShellOptions));
	options->Show();

	// start audio
	Sound::Resume();

	// play the startup sound (HACK)
	PlaySoundCue(0x94326baa /* "startup" */);

	// set to runtime mode
	runtime = true;
}
Ejemplo n.º 22
0
//=============================================================================
// キーボードの初期化
//=============================================================================
HRESULT InitKeyboard(HINSTANCE hInstance, HWND hWnd)
{
	HRESULT hr;

	// 入力処理の初期化
	hr = InitInput(hInstance, hWnd);
	if(FAILED(hr))
	{
		MessageBox(hWnd, "DirectInputオブジェクトが作れねぇ!", "警告!", MB_ICONWARNING);
		return hr;
	}

	// デバイスオブジェクトを作成
	hr = g_pInput->CreateDevice(GUID_SysKeyboard, &g_pDevKeyboard, NULL);
	if(FAILED(hr))
	{
		MessageBox(hWnd, "キーボードがねぇ!", "警告!", MB_ICONWARNING);
		return hr;
	}

	// データフォーマットを設定
	hr = g_pDevKeyboard->SetDataFormat(&c_dfDIKeyboard);
	if(FAILED(hr))
	{
		MessageBox(hWnd, "キーボードのデータフォーマットを設定できませんでした。", "警告!", MB_ICONWARNING);
		return hr;
	}

	// 協調モードを設定(フォアグラウンド&非排他モード)
	hr = g_pDevKeyboard->SetCooperativeLevel(hWnd, (DISCL_FOREGROUND | DISCL_NONEXCLUSIVE));
	if(FAILED(hr))
	{
		MessageBox(hWnd, "キーボードの協調モードを設定できませんでした。", "警告!", MB_ICONWARNING);
		return hr;
	}

	// キーボードへのアクセス権を獲得(入力制御開始)
	g_pDevKeyboard->Acquire();

	// 各ワークのクリア
	ZeroMemory(g_aKeyState, sizeof g_aKeyState);
	ZeroMemory(g_aKeyStateTrigger, sizeof g_aKeyStateTrigger);
	ZeroMemory(g_aKeyStateRelease, sizeof g_aKeyStateRelease);
	ZeroMemory(g_aKeyStateRepeat, sizeof g_aKeyStateRepeat);
	ZeroMemory(g_aKeyStateRepeatCnt, sizeof g_aKeyStateRepeatCnt);

	return S_OK;
}
Ejemplo n.º 23
0
int main(int argc, char* argv[])
{
	//初始化NGE分为VIDEO,AUDIO,这里是只初始化VIDEO,如果初始化所有用INIT_VIDEO|INIT_AUDIO,或者INIT_ALL
	NGE_Init(INIT_VIDEO);
	//初始化按键处理btn_down是按下响应,后面是弹起时的响应,0是让nge处理home消息(直接退出),填1就是让PSP系统处理
	//home消息,通常填1正常退出(1.50版的自制程序需要填0)
	InitInput(btn_down,NULL,1);
	//最后一个参数是psp swizzle优化,通常填1
	p_logo = image_load("images/nge2logo.png",DISPLAY_PIXEL_FORMAT_8888,1);
	if(p_logo == NULL)
		printf("can not open file\n");
	p_par = image_load("par/particles.png",DISPLAY_PIXEL_FORMAT_8888,1);
	if(p_par == NULL)
		printf("can not open file\n");
	//设置sprite子图
	mParticle = (sprite_p)malloc(sizeof(sprite_t));
	memset(mParticle,0,sizeof(sprite_t));
	mParticle->sprite_image = p_par;
	mParticle->sprite_clip.left= 0.0f;
	mParticle->sprite_clip.top= 0.0f;
	mParticle->sprite_clip.right= 32.0f;
	mParticle->sprite_clip.bottom = 32.0f;
	mParticle->sprite_center.x = 16.0f; 
	mParticle->sprite_center.y = 16.0f;

	mParticleSys = new hgeParticleSystem("par/particle1.psi", mParticle);
	mParticleSys->MoveTo(480.0f/2, 272.0f/2,0);
	mParticleSys->Fire();
	timer = timer_create();
	timer->start(timer);
	while ( !game_quit )
	{
		ShowFps();
		InputProc();
		Update();
		DrawScene();
		LimitFps(60);
	}
	image_free(p_logo);
	image_free(p_par);
	SAFE_FREE(mParticle);
	delete mParticleSys;
	NGE_Quit();
	return 0;
}
Ejemplo n.º 24
0
//=============================================================================
// ジョイパッドの初期化
//=============================================================================
HRESULT InitJoypad(HINSTANCE hInstance, HWND hWnd)
{
	int nLoop;

	HRESULT hr;

	// 入力処理の初期化
	hr = InitInput(hInstance, hWnd);
	if(FAILED(hr))
	{
		MessageBox(hWnd, "DirectInputオブジェクトが作れねぇ!", "警告!", MB_ICONWARNING);
		return hr;
	}

	// 初期化
	for(nLoop = 0; nLoop < MAX_CONTROLER; nLoop++)
		g_pDIDevJoypad[nLoop] = NULL;

	// デバイスオブジェクトを作成(接続されているジョイパッドを列挙する)
	if(FAILED(g_pInput->EnumDevices(DI8DEVCLASS_GAMECTRL, EnumJoyCallback, NULL, DIEDFL_ATTACHEDONLY)))
		return E_FAIL;

	// ジョイパッドの数だけ処理
	for(nLoop = 0; nLoop < MAX_CONTROLER; nLoop++)
	{
		// ジョイパッドがない場合はすっ飛ばす
		if(g_pDIDevJoypad[nLoop] == NULL)
			continue;

		// データフォーマットの設定
		if(FAILED(g_pDIDevJoypad[nLoop]->SetDataFormat(&c_dfDIJoystick)))
			return E_FAIL;

		// 協調レベルの設定
		if(FAILED(g_pDIDevJoypad[nLoop]->SetCooperativeLevel(hWnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND)))
			return E_FAIL;

		// デバイスへの入力制御開始
		g_pDIDevJoypad[nLoop]->Acquire();	
	}

	return S_OK;
}
Ejemplo n.º 25
0
//--------------------------------------
void Platform::init()
{
   Con::printf("Initializing platform...");

   // Set the platform variable for the scripts
   Con::setVariable( "$platform", "windows" );

   WinConsole::create();

   if ( !WinConsole::isEnabled() )
      Input::init();

   InitInput();   // in case DirectInput falls through

   installRedBookDevices();

   sgDoubleByteEnabled = GetSystemMetrics( SM_DBCSENABLED );
   sgQueueEvents = true;
   Con::printf("Done");
}
Ejemplo n.º 26
0
bool wd::Application::Initialize(
	const HINSTANCE& hInstance,
	const int& nCmdShow)
{
	// Init config file - get global settings.
	InitConfig();

	// Create OS window.
	if (!InitWindow(hInstance, nCmdShow))
		return false;

	// Create video device and context.
	if (!InitVideoDevice())
		return false;

	InitInput();
	// Show window. By now we should be able to show some sort of loading screen.
	m_pWindow->Show();
	// Create scene.
	InitScene();

	return true;
}
Ejemplo n.º 27
0
int init() {
	//初始化NGE分为VIDEO,AUDIO,这里是只初始化VIDEO,如果初始化所有用INIT_VIDEO|INIT_AUDIO,或者INIT_ALL
	NGE_Init(INIT_VIDEO);
	//初始化按键处理btn_down是按下响应,后面是弹起时的响应,0是让nge处理home消息(直接退出),填1就是让PSP系统处理
	//home消息,通常填1正常退出(1.50版的自制程序需要填0)
#ifdef NGE_INPUT_BUTTON_SUPPORT
	InitInput(btn_down,NULL,1);
#endif
	//最后一个参数是psp swizzle优化,通常填1
	p_bg = image_load(RES_PATH("images/demo0.jpg"),DISPLAY_PIXEL_FORMAT_8888,1);
	if(p_bg == NULL) {
		nge_print("can not open file\n");
	}
	p_logo = image_load(RES_PATH("images/nge2logo.png"),DISPLAY_PIXEL_FORMAT_4444,1);
	if(p_logo == NULL) {
		nge_print("can not open file\n");
	}
	//创建一个半透明的图片遮罩color
	logomask1 = CreateColor(255,255,255,128,p_logo->dtype);
	//随便创建一个图片遮罩color
	logomask2 = CreateColor(100,100,100,255,p_logo->dtype);
	return 0;
}
Ejemplo n.º 28
0
int init() {
	//初始化NGE分为VIDEO,AUDIO,这里是只初始化VIDEO,如果初始化所有用INIT_VIDEO|INIT_AUDIO,或者INIT_ALL
	NGE_Init(INIT_VIDEO);
	//初始化按键处理btn_down是按下响应,后面是弹起时的响应,0是让nge处理home消息(直接退出),填1就是让PSP系统处理
	//home消息,通常填1正常退出(1.50版的自制程序需要填0)
#ifdef NGE_INPUT_BUTTON_SUPPORT
	InitInput(btn_down,NULL,1);
#endif
	//最后一个参数是psp swizzle优化,通常填1
	p_logo = image_load(RES_PATH("images/nge2logo.png"),DISPLAY_PIXEL_FORMAT_8888,1);
	if(p_logo == NULL) {
		nge_print("can not open file\n");
	}
	p_par = image_load(RES_PATH("par/particles.png"),DISPLAY_PIXEL_FORMAT_8888,1);
	if(p_par == NULL) {
		nge_print("can not open file\n");
	}
	//设置sprite子图
	mParticle = (sprite_p)malloc(sizeof(sprite_t));
	memset(mParticle,0,sizeof(sprite_t));
	mParticle->sprite_image = p_par;
	mParticle->sprite_clip.left= 0.0f;
	mParticle->sprite_clip.top= 0.0f;
	mParticle->sprite_clip.right= 32.0f;
	mParticle->sprite_clip.bottom = 32.0f;
	mParticle->sprite_center.x = 16.0f;
	mParticle->sprite_center.y = 16.0f;

	mParticleSys = new hgeParticleSystem(RES_PATH("par/particle1.psi"), mParticle);
	mParticleSys->MoveTo(480.0f/2, 272.0f/2,0);
	mParticleSys->Fire();
	timer = timer_create();
	timer->start(timer);

	return 0;
}
Ejemplo n.º 29
0
void InitGraphics(const CmdLineArgs& args, int flags)
{
	const bool setup_vmode = (flags & INIT_HAVE_VMODE) == 0;

	if(setup_vmode)
	{
		InitSDL();

		if (!g_VideoMode.InitSDL())
			throw PSERROR_System_VmodeFailed(); // abort startup

#if !SDL_VERSION_ATLEAST(2, 0, 0)
		SDL_WM_SetCaption("0 A.D.", "0 A.D.");
#endif
	}

	RunHardwareDetection();

	const int quality = SANE_TEX_QUALITY_DEFAULT;	// TODO: set value from config file
	SetTextureQuality(quality);

	ogl_WarnIfError();

	// Optionally start profiler GPU timings automatically
	// (By default it's only enabled by a hotkey, for performance/compatibility)
	bool profilerGPUEnable = false;
	CFG_GET_VAL("profiler2.autoenable", profilerGPUEnable);
	if (profilerGPUEnable)
		g_Profiler2.EnableGPU();

	if(!g_Quickstart)
	{
		WriteSystemInfo();
		// note: no longer vfs_display here. it's dog-slow due to unbuffered
		// file output and very rarely needed.
	}

	if(g_DisableAudio)
		ISoundManager::SetEnabled(false);

	g_GUI = new CGUIManager();

	// (must come after SetVideoMode, since it calls ogl_Init)
	if (ogl_HaveExtensions(0, "GL_ARB_vertex_program", "GL_ARB_fragment_program", NULL) != 0 // ARB
		&& ogl_HaveExtensions(0, "GL_ARB_vertex_shader", "GL_ARB_fragment_shader", NULL) != 0) // GLSL
	{
		DEBUG_DISPLAY_ERROR(
			L"Your graphics card doesn't appear to be fully compatible with OpenGL shaders."
			L" In the future, the game will not support pre-shader graphics cards."
			L" You are advised to try installing newer drivers and/or upgrade your graphics card."
			L" For more information, please see http://www.wildfiregames.com/forum/index.php?showtopic=16734"
		);
		// TODO: actually quit once fixed function support is dropped
	}

	const char* missing = ogl_HaveExtensions(0,
		"GL_ARB_multitexture",
		"GL_EXT_draw_range_elements",
		"GL_ARB_texture_env_combine",
		"GL_ARB_texture_env_dot3",
		NULL);
	if(missing)
	{
		wchar_t buf[500];
		swprintf_s(buf, ARRAY_SIZE(buf),
			L"The %hs extension doesn't appear to be available on your computer."
			L" The game may still work, though - you are welcome to try at your own risk."
			L" If not or it doesn't look right, upgrade your graphics card.",
			missing
		);
		DEBUG_DISPLAY_ERROR(buf);
		// TODO: i18n
	}

	if (!ogl_HaveExtension("GL_ARB_texture_env_crossbar"))
	{
		DEBUG_DISPLAY_ERROR(
			L"The GL_ARB_texture_env_crossbar extension doesn't appear to be available on your computer."
			L" Shadows are not available and overall graphics quality might suffer."
			L" You are advised to try installing newer drivers and/or upgrade your graphics card.");
		g_Shadows = false;
	}

	ogl_WarnIfError();
	InitRenderer();

	InitInput();

	ogl_WarnIfError();

	try
	{
		if (!Autostart(args))
		{
			const bool setup_gui = ((flags & INIT_NO_GUI) == 0);
			// We only want to display the splash screen at startup
			shared_ptr<ScriptInterface> scriptInterface = g_GUI->GetScriptInterface();
			JSContext* cx = scriptInterface->GetContext();
			JSAutoRequest rq(cx);
			JS::RootedValue data(cx);
			if (g_GUI)
			{
				scriptInterface->Eval("({})", &data);
				scriptInterface->SetProperty(data, "isStartup", true);
			}
			InitPs(setup_gui, L"page_pregame.xml", g_GUI->GetScriptInterface().get(), data);
		}
	}
	catch (PSERROR_Game_World_MapLoadFailed& e)
	{
		// Map Loading failed

		// Start the engine so we have a GUI
		InitPs(true, L"page_pregame.xml", NULL, JS::UndefinedHandleValue);

		// Call script function to do the actual work
		//	(delete game data, switch GUI page, show error, etc.)
		CancelLoad(CStr(e.what()).FromUTF8());
	}
}
Ejemplo n.º 30
0
void DLLEXPORT HUD_Init( void )
{
	InitInput();
	gHUD.Init();
	Scheme_Init();
}