本文整理汇总了C++中LPDIRECTINPUTDEVICE::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTINPUTDEVICE::Release方法的具体用法?C++ LPDIRECTINPUTDEVICE::Release怎么用?C++ LPDIRECTINPUTDEVICE::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTINPUTDEVICE
的用法示例。
在下文中一共展示了LPDIRECTINPUTDEVICE::Release方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: di_cleanup
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;
}
}
示例2: ReleaseDirectMouse
void ReleaseDirectMouse(void)
{
if (lpdiMouse != NULL)
{
lpdiMouse->Release();
lpdiMouse = NULL;
}
}
示例3: Exit
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_);
}
示例4: input_dinput_end
/**
* 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;
}
示例5: ReleaseDirectKeyboard
void ReleaseDirectKeyboard(void)
{
if (DIKeyboardOkay)
{
lpdiKeyboard->Unacquire();
DIKeyboardOkay = FALSE;
}
if (lpdiKeyboard != NULL)
{
lpdiKeyboard->Release();
lpdiKeyboard = NULL;
}
}
示例6: release
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();
}
}
示例7: PisteInput_Lopeta
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;
}
示例8: EnumJoystickProc
BOOL CALLBACK EnumJoystickProc (LPCDIDEVICEINSTANCE pdiDevice_, LPVOID lpv_)
{
HRESULT hr;
LPDIRECTINPUTDEVICE pdiJoystick;
if (FAILED(hr = pdi->CreateDevice(pdiDevice_->guidInstance, &pdiJoystick, NULL)))
TRACE("!!! Failed to create joystick device (%#08lx)\n", hr);
else
{
DIDEVICEINSTANCE didi = { sizeof(didi) };
strcpy(didi.tszInstanceName, "<unknown>"); // WINE fix for missing implementation
if (FAILED(hr = pdiJoystick->GetDeviceInfo(&didi)))
TRACE("!!! Failed to get joystick device info (%#08lx)\n", hr);
// Overloaded use - if custom data was supplied, it's a combo box ID to add the string to
else if (lpv_)
SendMessage(reinterpret_cast<HWND>(lpv_), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(didi.tszInstanceName));
else
{
IDirectInputDevice2* pDevice;
// We need an IDirectInputDevice2 interface for polling, so query for it
if (FAILED(hr = pdiJoystick->QueryInterface(IID_IDirectInputDevice2, reinterpret_cast<void **>(&pDevice))))
TRACE("!!! Failed to query joystick for IID_IDirectInputDevice2 (%#08lx)\n", hr);
// If the device name matches the joystick 1 device name, save a pointer to it
else if (!lstrcmpi(didi.tszInstanceName, GetOption(joydev1)))
pdidJoystick1 = pDevice;
// If the device name matches the joystick 2 device name, save a pointer to it
else if (!lstrcmpi(didi.tszInstanceName, GetOption(joydev2)))
pdidJoystick2 = pDevice;
// No match
else
pDevice->Release();
pdiJoystick->Release();
}
}
// Continue looking for other devices, even tho we failed with the current one
return DIENUM_CONTINUE;
}
示例9: di_cleanup
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;
}
示例10: DIUtilCreateDevice2FromJoyConfig
//===========================================================================
// DIUtilCreateDevice2FromJoyConfig
//
// Helper function to create a DirectInputDevice2 object from a
// DirectInputJoyConfig object.
//
// Parameters:
// short nJoystickId - joystick id for creation
// HWND hWnd - window handle
// LPDIRECTINPUT pdi - ptr to base DInput object
// LPDIRECTINPUTJOYCONFIG pdiJoyCfg - ptr to joyconfig object
// LPDIRECTINPUTDEVICE *ppdiDevice2 - ptr to device object ptr
//
// Returns: HRESULT
//
//===========================================================================
HRESULT DIUtilCreateDevice2FromJoyConfig(short nJoystickId, HWND hWnd,
LPDIRECTINPUT pdi,
LPDIRECTINPUTJOYCONFIG pdiJoyCfg,
LPDIRECTINPUTDEVICE2 *ppdiDevice2)
{
HRESULT hRes = E_NOTIMPL;
LPDIRECTINPUTDEVICE pdiDevTemp = NULL;
DIJOYCONFIG dijc;
// validate pointers
if( (IsBadReadPtr((void*)pdi, sizeof(IDirectInput))) ||
(IsBadWritePtr((void*)pdi, sizeof(IDirectInput))) )
{
ERROUT(TEXT("DIUtilCreateDeviceFromJoyConfig() - invalid pdi\n"));
return E_POINTER;
}
if( (IsBadReadPtr((void*)pdiJoyCfg, sizeof(IDirectInputJoyConfig))) ||
(IsBadWritePtr((void*)pdiJoyCfg, sizeof(IDirectInputJoyConfig))) )
{
ERROUT(TEXT("DIUtilCreateDeviceFromJoyConfig() - invalid pdiJoyCfg\n"));
return E_POINTER;
}
if( (IsBadReadPtr((void*)ppdiDevice2, sizeof(LPDIRECTINPUTDEVICE2))) ||
(IsBadWritePtr((void*)ppdiDevice2, sizeof(LPDIRECTINPUTDEVICE2))) )
{
ERROUT(TEXT("DIUtilCreateDeviceFromJoyConfig() - invalid ppdiDevice2\n"));
return E_POINTER;
}
// get the instance GUID for device configured as nJoystickId
//
// GetConfig will provide this information
dijc.dwSize = sizeof(DIJOYCONFIG);
hRes = pdiJoyCfg->GetConfig(nJoystickId, &dijc, DIJC_GUIDINSTANCE);
if(FAILED(hRes))
{
ERROUT(TEXT("DIUtilCreateDeviceFromJoyConfig() - GetConfig() failed\n"));
return hRes;
}
// create temporary device object
//
// use the instance GUID returned by GetConfig()
hRes = pdi->CreateDevice(dijc.guidInstance, &pdiDevTemp, NULL);
if(FAILED(hRes))
{
ERROUT(TEXT("DIUtilCreateDeviceFromJoyConfig() - CreateDevice() failed\n"));
return hRes;
}
// query for a device2 object
hRes = pdiDevTemp->QueryInterface(IID_IDirectInputDevice2, (LPVOID*)ppdiDevice2);
// release the temporary object
pdiDevTemp->Release();
if(FAILED(hRes))
{
ERROUT(TEXT("DIUtilCreateDeviceFromJoyConfig() - QueryInterface(IDirectInputDevice2) failed\n"));
return hRes;
}
// set the desired data format
//
// we want to be a joystick
hRes = (*ppdiDevice2)->SetDataFormat(&c_dfDIJoystick);
if(FAILED(hRes))
{
ERROUT(TEXT("DIUtilCreateDeviceFromJoyConfig() - SetDataFormat(Joystick) failed\n"));
return hRes;
}
// set the cooperative level for the device
//
// want to set EXCLUSIVE | BACKGROUND
hRes = (*ppdiDevice2)->SetCooperativeLevel(hWnd, DISCL_EXCLUSIVE | DISCL_FOREGROUND);
if(FAILED(hRes))
{
ERROUT(TEXT("DIUtilCreateDeviceFromJoyConfig() - SetCooperativeLevel() failed\n"));
return hRes;
}
// all is well
return hRes;
//.........这里部分代码省略.........
示例11: PisteInput_Alusta_Ohjain
bool PisteInput_Alusta_Ohjain(int index)
{
LPDIRECTINPUTDEVICE temp;
if (FAILED(PI_lpdi->CreateDevice(PI_joysticks[index].joystickGUID, &temp, NULL))) {
PisteLog_Kirjoita("[Error] Piste Input: Gamepad - Create device failed! \n");
return false;
}
if (FAILED(temp->QueryInterface(IID_IDirectInputDevice2,(void**) &PI_joysticks[index].lpdijoy))) {
PisteLog_Kirjoita("[Error] Piste Input: Gamepad - Create device failed! \n");
return false;
}
if (FAILED(temp->Release())) {
PisteLog_Kirjoita("[Error] Piste Input: Gamepad - Releasing DirectInputDevice 1 failed! \n");
return false;
}
if (FAILED(PI_joysticks[index].lpdijoy->SetCooperativeLevel(PI_main_window_handle, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE ))) {
PisteLog_Kirjoita("[Error] Piste Input: Gamepad - Releasing DirectInputDevice 1 failed! \n");
return false;
}
if (FAILED(PI_joysticks[index].lpdijoy->SetDataFormat(&c_dfDIJoystick))) {
PisteLog_Kirjoita("[Error] Piste Input: Gamepad - Set dataformat failed! \n");
return false;
}
DIPROPRANGE joy_axis_range;
//Määritellään x-akseli
joy_axis_range.lMin = -PI_OHJAIN_XY;
joy_axis_range.lMax = PI_OHJAIN_XY;
joy_axis_range.diph.dwSize = sizeof(DIPROPRANGE);
joy_axis_range.diph.dwHeaderSize = sizeof(DIPROPHEADER);
joy_axis_range.diph.dwObj = DIJOFS_X;
joy_axis_range.diph.dwHow = DIPH_BYOFFSET;
PI_joysticks[index].lpdijoy->SetProperty(DIPROP_RANGE, &joy_axis_range.diph);
//Määritellään y-akseli
joy_axis_range.lMin = -PI_OHJAIN_XY;
joy_axis_range.lMax = PI_OHJAIN_XY;
joy_axis_range.diph.dwSize = sizeof(DIPROPRANGE);
joy_axis_range.diph.dwHeaderSize = sizeof(DIPROPHEADER);
joy_axis_range.diph.dwObj = DIJOFS_Y;
joy_axis_range.diph.dwHow = DIPH_BYOFFSET;
PI_joysticks[index].lpdijoy->SetProperty(DIPROP_RANGE, &joy_axis_range.diph);
DIPROPDWORD dead_angle;
dead_angle.diph.dwSize = sizeof(dead_angle);
dead_angle.diph.dwHeaderSize = sizeof(dead_angle.diph);
dead_angle.diph.dwObj = DIJOFS_X;
dead_angle.diph.dwHow = DIPH_BYOFFSET;
dead_angle.dwData = 5000; //= 10%
PI_joysticks[index].lpdijoy->SetProperty(DIPROP_DEADZONE, &dead_angle.diph);
dead_angle.diph.dwSize = sizeof(dead_angle);
dead_angle.diph.dwHeaderSize = sizeof(dead_angle.diph);
dead_angle.diph.dwObj = DIJOFS_Y;
dead_angle.diph.dwHow = DIPH_BYOFFSET;
dead_angle.dwData = 5000; //= 10%
PI_joysticks[index].lpdijoy->SetProperty(DIPROP_DEADZONE, &dead_angle.diph);
if (FAILED(PI_joysticks[index].lpdijoy->Acquire())) {
PisteLog_Kirjoita("[Error] Piste Input: Gamepad - Acquiring device failed! \n");
return false;
}
return true;
}
示例12:
/**
* input_dinput_callback_init_joysticks_enum(): EnumDevices callback for initializing joysticks.
* @param lpDIIJoy Joystick information.
* @param pvRef hWnd of the Gens window.
* @return DIENUM_CONTINUE to continue the enumeration; DIENUM_STOP to stop the enumeration.
*/
static BOOL CALLBACK input_dinput_callback_init_joysticks_enum(LPCDIDEVICEINSTANCE lpDIIJoy, LPVOID pvRef)
{
HRESULT rval;
LPDIRECTINPUTDEVICE lpDIJoy;
if (!lpDIIJoy || input_dinput_num_joysticks >= MAX_JOYS ||
input_dinput_callback_init_joysticks_enum_counter >= MAX_JOYS)
return DIENUM_STOP;
// Number of times this function has been called.
int cur_joystick = input_dinput_callback_init_joysticks_enum_counter;
input_dinput_callback_init_joysticks_enum_counter++;
rval = lpDI->CreateDevice(lpDIIJoy->guidInstance, &lpDIJoy, NULL);
if (rval != DI_OK)
{
LOG_MSG(input, LOG_MSG_LEVEL_CRITICAL,
"lpDI->CreateDevice() failed. (Joystick %d)", cur_joystick);
return DIENUM_CONTINUE;
}
IDirectInputDevice2 *pJoyDevice = NULL;
input_dinput_joy_id[input_dinput_num_joysticks] = NULL;
rval = lpDIJoy->QueryInterface(IID_IDirectInputDevice2, (void**)&pJoyDevice);
lpDIJoy->Release();
if (rval != DI_OK || !pJoyDevice)
{
LOG_MSG(input, LOG_MSG_LEVEL_CRITICAL,
"lpDIJoy->QueryInterface() failed. (Joystick %d)", cur_joystick);
return DIENUM_CONTINUE;
}
rval = pJoyDevice->SetDataFormat(&c_dfDIJoystick);
if (rval != DI_OK)
{
LOG_MSG(input, LOG_MSG_LEVEL_CRITICAL,
"pJoyDevice->SetDatFormat(&c_dfDIJoystick) failed. (Joystick %d)", cur_joystick);
pJoyDevice->Release();
return DIENUM_CONTINUE;
}
// TODO: Add an option to specify DISCL_FOREGROUND so the joysticks only work when the Gens window is active.
rval = pJoyDevice->SetCooperativeLevel((HWND)pvRef, DISCL_NONEXCLUSIVE | DISCL_BACKGROUND);
if (rval != DI_OK)
{
LOG_MSG(input, LOG_MSG_LEVEL_WARNING,
"pJoyDevice->SetCooperativeLevel() failed. (Joystick %d)", cur_joystick);
pJoyDevice->Release();
return DIENUM_CONTINUE;
}
// Attempt to acquire the joystick device.
for (unsigned int i = 10; i != 0; i--)
{
rval = pJoyDevice->Acquire();
if (rval == DI_OK)
break;
GensUI::sleep(10);
}
input_dinput_joy_id[input_dinput_num_joysticks] = pJoyDevice;
input_dinput_num_joysticks++;
return DIENUM_CONTINUE;
}