本文整理汇总了C++中LPDIRECTINPUTDEVICE::GetDeviceInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTINPUTDEVICE::GetDeviceInfo方法的具体用法?C++ LPDIRECTINPUTDEVICE::GetDeviceInfo怎么用?C++ LPDIRECTINPUTDEVICE::GetDeviceInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTINPUTDEVICE
的用法示例。
在下文中一共展示了LPDIRECTINPUTDEVICE::GetDeviceInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}