我正在尝试枚举 DirectInput 中的操纵杆。
unsigned int GetCount()
{
unsigned int counter;
LPDIRECTINPUT8 di;
HRESULT hr;
counter = 0;
di = NULL;
if (SUCCEEDED(hr = DirectInput8Create(GetModuleHandle(NULL),
DIRECTINPUT_VERSION,
IID_IDirectInput8,
(VOID**)&di, NULL)))
{
di->EnumDevices(DI8DEVCLASS_GAMECTRL, countCallback, &counter, DIEDFL_ATTACHEDONLY);
}
return counter;
}
仅供参考 - 这是使用 C 编译器的 ac 文件。
我收到了这些奇怪的错误。
error C2039: 'EnumDevices' : is not a member of 'IDirectInput8A'
error C2440: 'function' : cannot convert from 'const GUID' to 'const IID *const '
第一个是指开始的行di->EnumDevices...
第二个是指IID_IDirectInput8
in DirectInput8Create
。
我玩过 UNICODE 设置,看看它是否重要。没有。
这感觉像是非常基本的事情。