Ejemplo n.º 1
0
void di_cleanup()
{
    /*
     *  Destroy any lingering IDirectInputDevice object.
     */
    if (Di_keyboard) {

        /*
         *  Cleanliness is next to godliness.  Unacquire the device
         *  one last time just in case we got really confused and tried
         *  to exit while the device is still acquired.
         */
        Di_keyboard->Unacquire();

        Di_keyboard->Release();
        Di_keyboard = NULL;
    }

    /*
     *  Destroy any lingering IDirectInput object.
     */
    if (Di_object) {
        Di_object->Release();
        Di_object = NULL;
    }

	if ( Di_event )	{
		CloseHandle(Di_event);
		Di_event = NULL;
	}

}
void ReleaseDirectInput(void)

{
    if (lpdi!= NULL)
	  {
       lpdi->Release();
	   lpdi = NULL;
	  }
}
Ejemplo n.º 3
0
int HookDirectInput(HMODULE module, int version)
{
	HINSTANCE hinst;
	void *tmp;
	LPDIRECTINPUT lpdi;
	const GUID di7 = {0x9A4CB684,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE};
	const GUID di8 = {0xBF798030,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00};

	tmp = HookAPI(module, "dinput.dll", NULL, "DirectInputCreateA", extDirectInputCreate);
	if(tmp) pDirectInputCreate = (DirectInputCreate_Type)tmp;
	tmp = HookAPI(module, "dinput.dll", NULL, "DirectInputCreateW", extDirectInputCreate);
	if(tmp) pDirectInputCreate = (DirectInputCreate_Type)tmp;
	tmp = HookAPI(module, "dinput.dll", NULL, "DirectInputCreateEx", extDirectInputCreateEx);
	if(tmp) pDirectInputCreateEx = (DirectInputCreateEx_Type)tmp;
	tmp = HookAPI(module, "dinput8.dll", NULL, "DirectInput8Create", extDirectInput8Create);
	if(tmp) pDirectInputCreateEx = (DirectInputCreateEx_Type)tmp;
	if(!pDirectInputCreate && !pDirectInputCreateEx){
		if(version < 8){
			hinst = LoadLibrary("dinput.dll");
			pDirectInputCreate =
				(DirectInputCreate_Type)GetProcAddress(hinst, "DirectInputCreateA");
			if(pDirectInputCreate)
				if(!extDirectInputCreate(GetModuleHandle(0), DIRECTINPUT_VERSION,
					&lpdi, 0)) lpdi->Release();
			pDirectInputCreateEx =
				(DirectInputCreateEx_Type)GetProcAddress(hinst, "DirectInputCreateEx");
			if(pDirectInputCreateEx)
				if(!extDirectInputCreateEx(GetModuleHandle(0), DIRECTINPUT_VERSION,
					di7, (void **)&lpdi, 0)) lpdi->Release();
		}
		else{
			hinst = LoadLibrary("dinput8.dll");
			pDirectInputCreateEx =
				(DirectInputCreateEx_Type)GetProcAddress(hinst, "DirectInput8Create");
			if(pDirectInputCreateEx)
				if(!extDirectInputCreateEx(GetModuleHandle(0), DIRECTINPUT_VERSION,
					di8, (void **)&lpdi, 0)) lpdi->Release();
		}
	}
	if(pDirectInputCreate || pDirectInputCreateEx) return 1;
	return 0;
}
Ejemplo n.º 4
0
void Input::Exit (bool fReInit_/*=false*/)
{
    TRACE("Input::Exit(%d)\n", fReInit_);

    if (pdiKeyboard) { pdiKeyboard->Unacquire(); pdiKeyboard->Release(); pdiKeyboard = NULL; }
    if (pdidJoystick1) { pdidJoystick1->Unacquire(); pdidJoystick1->Release(); pdidJoystick1 = NULL; }
    if (pdidJoystick2) { pdidJoystick2->Unacquire(); pdidJoystick2->Release(); pdidJoystick2 = NULL; }
    if (pdi) { pdi->Release(); pdi = NULL; }

    Keyboard::Exit(fReInit_);
}
Ejemplo n.º 5
0
void DXGame::release(){
	if(lpDirectDrawObject != NULL){		//if DD object exists
		if(lpPrimary != NULL)				//if primary surface exists
			lpPrimary->Release();			//release primary surface
		lpDirectDrawObject->Release();	//release DD object
	}	
	if(lpDirectInput != NULL){
		if(lpKeyboard){
			lpKeyboard->Unacquire();
			lpKeyboard->Release();
		} 
		lpDirectInput->Release();
	}
}
Ejemplo n.º 6
0
void di_cleanup()
{
	// Destroy any lingering IDirectInputDevice object.
	if (Di_mouse) {
		// Unacquire the device one last time just in case we got really confused
		// and tried to exit while the device is still acquired.
		Di_mouse->Unacquire();

		Di_mouse->Release();
		Di_mouse = NULL;
	}

	// Destroy any lingering IDirectInput object.
	if (Di_mouse_obj) {
		Di_mouse_obj->Release();
		Di_mouse_obj = NULL;
	}

	Di_mouse_inited = 0;
}
Ejemplo n.º 7
0
/**
 * input_dinput_end(): Shut down the DirectInput subsystem.
 * @return 0 on success; non-zero on error.
 */
int input_dinput_end(void)
{
	// If any joysticks were opened, close them.
	if (!lpDI)
		return 0;
	
	if (lpDIDMouse)
	{
		lpDIDMouse->Release();
		lpDIDMouse = NULL;
	}
	
	if (lpDIDKeyboard)
	{
		lpDIDKeyboard->Release();
		lpDIDKeyboard = NULL;
	}
	
	for (int i = 0; i < MAX_JOYS; i++)
	{
		if (input_dinput_joy_id[i])
		{
			input_dinput_joy_id[i]->Unacquire();
			input_dinput_joy_id[i]->Release();
			input_dinput_joy_id[i] = NULL;
		}
	}
	
	input_dinput_num_joysticks = 0;
	lpDI->Release();
	lpDI = NULL;
	
	// Clear the DirectInput version variable.
	input_dinput_version = 0;
	
	// DirectInput shut down.
	return 0;
}
Ejemplo n.º 8
0
int PisteInput_Lopeta()
{
	if (!PI_unload) {
		for (int i=0;i<PI_MAX_PELIOHJAIMIA;i++)
			if (PI_joysticks[i].lpdijoy)
			{
				PI_joysticks[i].lpdijoy->Unacquire();
				PI_joysticks[i].lpdijoy->Release();
				PI_joysticks[i].lpdijoy = NULL;
			}
		
		if (PI_lpdimouse)
		{
			PI_lpdimouse->Unacquire();
			PI_lpdimouse->Release();
			PI_lpdimouse = NULL;
		}

		if (PI_lpdikey)
		{
			PI_lpdikey->Unacquire();
			PI_lpdikey->Release();
			PI_lpdikey = NULL;
		}

		if (PI_lpdi)
		{
			PI_lpdi->Release();
			PI_lpdi = NULL;
		}

		PI_unload = true;
	}

	return 0;
}