dinput: EnumDevicesBySemantics enumerating keyboard and mouse with priority flags.

This commit is contained in:
Lucas Fialho Zawacki 2011-06-28 13:54:36 -03:00 committed by Alexandre Julliard
parent 3ed476caac
commit 0f17c828f7
3 changed files with 76 additions and 10 deletions

View File

@ -681,8 +681,13 @@ static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics(
)
{
IDirectInputImpl *This = impl_from_IDirectInput8A( iface );
DIDEVICEINSTANCEA didevi;
LPDIRECTINPUTDEVICE8A lpdid;
BOOL ret;
DWORD callbackFlags = 0;
int i;
FIXME("(this=%p,%s,%p,%p,%p,%04x): stub\n", This, ptszUserName, lpdiActionFormat,
FIXME("(this=%p,%s,%p,%p,%p,%04x): semi-stub\n", This, ptszUserName, lpdiActionFormat,
lpCallback, pvRef, dwFlags);
#define X(x) if (dwFlags & x) FIXME("\tdwFlags |= "#x"\n");
X(DIEDBSFL_ATTACHEDONLY)
@ -695,6 +700,32 @@ static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics(
_dump_diactionformatA(lpdiActionFormat);
didevi.dwSize = sizeof(didevi);
/* enum the keyboard first */
IDirectInput_CreateDevice(iface, &GUID_SysKeyboard, &lpdid, NULL);
IDirectInputDevice_GetDeviceInfo(lpdid, &didevi);
/* if there's any DIKEYBOARD action, keyboard is priority 1*/
for(i=0; i < lpdiActionFormat->dwActionSize; i++)
if ((lpdiActionFormat->rgoAction[i].dwSemantic & DIKEYBOARD_MASK) == DIKEYBOARD_MASK)
callbackFlags |= DIEDBS_MAPPEDPRI1;
ret = lpCallback(&didevi, lpdid, callbackFlags, 1, pvRef);
if (ret == DIENUM_STOP) return DI_OK;
callbackFlags = 0;
/* and then the mouse */
IDirectInput_CreateDevice(iface, &GUID_SysMouse, &lpdid, NULL);
IDirectInputDevice_GetDeviceInfo(lpdid, &didevi);
/* same as above, but for the mouse */
for(i=0; i < lpdiActionFormat->dwActionSize; i++)
if ((lpdiActionFormat->rgoAction[i].dwSemantic & DIMOUSE_MASK) == DIMOUSE_MASK)
callbackFlags |= DIEDBS_MAPPEDPRI1;
lpCallback(&didevi, lpdid, callbackFlags, 0, pvRef);
return DI_OK;
}
@ -704,11 +735,43 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics(
LPVOID pvRef, DWORD dwFlags
)
{
IDirectInputImpl *This = impl_from_IDirectInput8W( iface );
IDirectInputImpl *This = impl_from_IDirectInput8W(iface);
DIDEVICEINSTANCEW didevi;
LPDIRECTINPUTDEVICE8W lpdid;
BOOL ret;
DWORD callbackFlags = 0;
int i;
FIXME("(this=%p,%s,%p,%p,%p,%04x): stub\n", This, debugstr_w(ptszUserName), lpdiActionFormat,
FIXME("(this=%p,%s,%p,%p,%p,%04x): semi-stub\n", This, debugstr_w(ptszUserName), lpdiActionFormat,
lpCallback, pvRef, dwFlags);
return 0;
didevi.dwSize = sizeof(didevi);
/* enum the keyboard first */
IDirectInput_CreateDevice(iface, &GUID_SysKeyboard, &lpdid, NULL);
IDirectInputDevice_GetDeviceInfo(lpdid, &didevi);
/* if there's any DIKEYBOARD action, keyboard is priority 1*/
for(i=0; i < lpdiActionFormat->dwActionSize; i++)
if ((lpdiActionFormat->rgoAction[i].dwSemantic & DIKEYBOARD_MASK) == DIKEYBOARD_MASK)
callbackFlags |= DIEDBS_MAPPEDPRI1;
ret = lpCallback(&didevi, lpdid, callbackFlags, 1, pvRef);
if (ret == DIENUM_STOP) return DI_OK;
callbackFlags = 0;
/* and then the mouse */
IDirectInput_CreateDevice(iface, &GUID_SysMouse, &lpdid, NULL);
IDirectInputDevice_GetDeviceInfo(lpdid, &didevi);
/* same as above, but for the mouse */
for(i=0; i < lpdiActionFormat->dwActionSize; i++)
if ((lpdiActionFormat->rgoAction[i].dwSemantic & DIMOUSE_MASK) == DIMOUSE_MASK)
callbackFlags |= DIEDBS_MAPPEDPRI1;
lpCallback(&didevi, lpdid, callbackFlags, 0, pvRef);
return DI_OK;
}
static HRESULT WINAPI IDirectInput8AImpl_ConfigureDevices(

View File

@ -66,4 +66,7 @@ extern void _dump_diactionformatA(LPDIACTIONFORMATA) DECLSPEC_HIDDEN;
#define IS_DIPROP(x) (((ULONG_PTR)(x) >> 16) == 0)
#define DIKEYBOARD_MASK 0x81000000
#define DIMOUSE_MASK 0x82000000
#endif /* __WINE_DLLS_DINPUT_DINPUT_PRIVATE_H */

View File

@ -68,7 +68,7 @@ static BOOL CALLBACK enumeration_callback(
IDirectInputDevice_AddRef(lpdid);
data->keyboard = lpdid;
todo_wine ok (dwFlags & DIEDBS_MAPPEDPRI1, "Keyboard should be mapped as pri1 dwFlags=%08x\n", dwFlags);
ok (dwFlags & DIEDBS_MAPPEDPRI1, "Keyboard should be mapped as pri1 dwFlags=%08x\n", dwFlags);
}
if (IsEqualGUID(&lpddi->guidInstance, &GUID_SysMouse))
@ -76,7 +76,7 @@ static BOOL CALLBACK enumeration_callback(
IDirectInputDevice_AddRef(lpdid);
data->mouse = lpdid;
todo_wine ok (dwFlags & DIEDBS_MAPPEDPRI1, "Mouse should be mapped as pri1 dwFlags=%08x\n", dwFlags);
ok (dwFlags & DIEDBS_MAPPEDPRI1, "Mouse should be mapped as pri1 dwFlags=%08x\n", dwFlags);
}
return DIENUM_CONTINUE;
@ -122,9 +122,9 @@ static void test_action_mapping(void)
hr = IDirectInput8_EnumDevicesBySemantics(pDI, 0, &af, enumeration_callback, &data, 0);
ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed: hr=%08x\n", hr);
todo_wine ok (data.ndevices > 0, "EnumDevicesBySemantics did not call the callback hr=%08x\n", hr);
todo_wine ok (data.keyboard != NULL, "EnumDevicesBySemantics should enumerate the keyboard\n");
todo_wine ok (data.mouse != NULL, "EnumDevicesBySemantics should enumerate the mouse\n");
ok (data.ndevices > 0, "EnumDevicesBySemantics did not call the callback hr=%08x\n", hr);
ok (data.keyboard != NULL, "EnumDevicesBySemantics should enumerate the keyboard\n");
ok (data.mouse != NULL, "EnumDevicesBySemantics should enumerate the mouse\n");
/* The call fails with a zeroed GUID */
memset(&af.guidActionMap, 0, sizeof(GUID));