Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 21 ++++++++++++++ dlls/dinput/device_private.h | 2 ++ dlls/dinput/joystick_hid.c | 54 +++++++++++++----------------------- dlls/dinput/keyboard.c | 42 ++++------------------------ dlls/dinput/mouse.c | 42 ++++------------------------ dlls/dinput8/tests/hid.c | 1 - 6 files changed, 53 insertions(+), 109 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 93236cf6bd0..6c2fe7737d5 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1243,6 +1243,25 @@ ULONG WINAPI IDirectInputDevice2WImpl_Release(LPDIRECTINPUTDEVICE8W iface) return ref; }
+HRESULT WINAPI IDirectInputDevice2WImpl_GetCapabilities( IDirectInputDevice8W *iface, DIDEVCAPS *caps ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8W( iface ); + DWORD size; + + TRACE( "iface %p, caps %p.\n", iface, caps ); + + if (!caps) return E_POINTER; + if (caps->dwSize != sizeof(DIDEVCAPS_DX3) && + caps->dwSize != sizeof(DIDEVCAPS)) + return DIERR_INVALIDPARAM; + + size = caps->dwSize; + memcpy( caps, &impl->caps, size ); + caps->dwSize = size; + + return DI_OK; +} + HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(LPDIRECTINPUTDEVICE8W iface, REFIID riid, LPVOID *ppobj) { IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface); @@ -1760,6 +1779,8 @@ HRESULT direct_input_device_alloc( SIZE_T size, const IDirectInputDevice8WVtbl * This->ref = 1; This->guid = *guid; This->instance.dwSize = sizeof(DIDEVICEINSTANCEW); + This->caps.dwSize = sizeof(DIDEVCAPS); + This->caps.dwFlags = DIDC_ATTACHED | DIDC_EMULATED; This->data_format.wine_df = format; InitializeCriticalSection( &This->crit ); This->dinput = dinput; diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h index 683db8d35ab..3fcb9240581 100644 --- a/dlls/dinput/device_private.h +++ b/dlls/dinput/device_private.h @@ -68,6 +68,7 @@ struct IDirectInputDeviceImpl struct list entry; /* entry into acquired device list */ HANDLE hEvent; DIDEVICEINSTANCEW instance; + DIDEVCAPS caps; DWORD dwCoopLevel; HWND win; int acquired; @@ -119,6 +120,7 @@ extern HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lp /* And the stubs */ extern HRESULT WINAPI IDirectInputDevice2WImpl_Acquire(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN; +extern HRESULT WINAPI IDirectInputDevice2WImpl_GetCapabilities( IDirectInputDevice8W *iface, DIDEVCAPS *caps ); extern HRESULT WINAPI IDirectInputDevice2WImpl_SetDataFormat(LPDIRECTINPUTDEVICE8W iface, LPCDIDATAFORMAT df) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8W iface, HWND hwnd, DWORD dwflags) DECLSPEC_HIDDEN; extern HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceInfo( IDirectInputDevice8W *iface, diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 4b0a4861fb7..65b9a809e5c 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -163,7 +163,6 @@ struct hid_joystick
WCHAR device_path[MAX_PATH]; HIDD_ATTRIBUTES attrs; - DIDEVCAPS dev_caps; HIDP_CAPS caps;
struct extra_caps *input_extra_caps; @@ -621,19 +620,6 @@ static ULONG WINAPI hid_joystick_Release( IDirectInputDevice8W *iface ) return ref; }
-static HRESULT WINAPI hid_joystick_GetCapabilities( IDirectInputDevice8W *iface, DIDEVCAPS *caps ) -{ - struct hid_joystick *impl = impl_from_IDirectInputDevice8W( iface ); - - TRACE( "iface %p, caps %p.\n", iface, caps ); - - if (!caps) return E_POINTER; - - *caps = impl->dev_caps; - - return DI_OK; -} - struct enum_objects_params { LPDIENUMDEVICEOBJECTSCALLBACKW callback; @@ -1075,7 +1061,7 @@ static HRESULT WINAPI hid_joystick_CreateEffect( IDirectInputDevice8W *iface, co if (!out) return E_POINTER; *out = NULL;
- if (!(impl->dev_caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_UNSUPPORTED; + if (!(impl->base.caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_UNSUPPORTED; if (FAILED(hr = hid_joystick_effect_create( impl, out ))) return hr;
hr = IDirectInputEffect_Initialize( *out, DINPUT_instance, impl->base.dinput->dwVersion, guid ); @@ -1184,7 +1170,7 @@ static HRESULT WINAPI hid_joystick_GetEffectInfo( IDirectInputDevice8W *iface, D
if (!info) return E_POINTER; if (info->dwSize != sizeof(DIEFFECTINFOW)) return DIERR_INVALIDPARAM; - if (!(impl->dev_caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_DEVICENOTREG; + if (!(impl->base.caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_DEVICENOTREG;
switch ((usage = effect_guid_to_usage( guid ))) { @@ -1345,7 +1331,7 @@ static HRESULT WINAPI hid_joystick_SendForceFeedbackCommand( IDirectInputDevice8 default: return DIERR_INVALIDPARAM; }
- if (!(impl->dev_caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_UNSUPPORTED; + if (!(impl->base.caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_UNSUPPORTED;
EnterCriticalSection( &impl->base.crit ); if (!impl->base.acquired || !(impl->base.dwCoopLevel & DISCL_EXCLUSIVE)) @@ -1428,7 +1414,7 @@ static const IDirectInputDevice8WVtbl hid_joystick_vtbl = hid_joystick_AddRef, hid_joystick_Release, /*** IDirectInputDevice methods ***/ - hid_joystick_GetCapabilities, + IDirectInputDevice2WImpl_GetCapabilities, hid_joystick_EnumObjects, hid_joystick_GetProperty, hid_joystick_SetProperty, @@ -1917,9 +1903,9 @@ static BOOL init_objects( struct hid_joystick *impl, struct hid_value_caps *caps
format->dwNumObjs++; format->dwDataSize = max( format->dwDataSize, instance->dwOfs + sizeof(LONG) ); - if (instance->dwType & DIDFT_BUTTON) impl->dev_caps.dwButtons++; - if (instance->dwType & DIDFT_AXIS) impl->dev_caps.dwAxes++; - if (instance->dwType & DIDFT_POV) impl->dev_caps.dwPOVs++; + if (instance->dwType & DIDFT_BUTTON) impl->base.caps.dwButtons++; + if (instance->dwType & DIDFT_AXIS) impl->base.caps.dwAxes++; + if (instance->dwType & DIDFT_POV) impl->base.caps.dwPOVs++;
if (instance->dwType & (DIDFT_BUTTON|DIDFT_AXIS|DIDFT_POV) && (instance->wUsagePage == HID_USAGE_PAGE_GENERIC || @@ -2261,10 +2247,8 @@ static HRESULT hid_joystick_create_device( IDirectInputImpl *dinput, const GUID
impl->ref = 1; impl->base.instance = instance; + impl->base.caps.dwDevType = instance.dwDevType; impl->attrs = attrs; - impl->dev_caps.dwSize = sizeof(impl->dev_caps); - impl->dev_caps.dwFlags = DIDC_ATTACHED | DIDC_EMULATED; - impl->dev_caps.dwDevType = instance.dwDevType; list_init( &impl->effect_list );
preparsed = (struct hid_preparsed_data *)impl->preparsed; @@ -2302,27 +2286,27 @@ static HRESULT hid_joystick_create_device( IDirectInputImpl *dinput, const GUID
if (impl->pid_device_control.id) { - impl->dev_caps.dwFlags |= DIDC_FORCEFEEDBACK; + impl->base.caps.dwFlags |= DIDC_FORCEFEEDBACK; if (impl->pid_effect_update.start_delay_caps) - impl->dev_caps.dwFlags |= DIDC_STARTDELAY; + impl->base.caps.dwFlags |= DIDC_STARTDELAY; if (impl->pid_set_envelope.attack_level_caps || impl->pid_set_envelope.attack_time_caps) - impl->dev_caps.dwFlags |= DIDC_FFATTACK; + impl->base.caps.dwFlags |= DIDC_FFATTACK; if (impl->pid_set_envelope.fade_level_caps || impl->pid_set_envelope.fade_time_caps) - impl->dev_caps.dwFlags |= DIDC_FFFADE; + impl->base.caps.dwFlags |= DIDC_FFFADE; if (impl->pid_set_condition.positive_coefficient_caps || impl->pid_set_condition.negative_coefficient_caps) - impl->dev_caps.dwFlags |= DIDC_POSNEGCOEFFICIENTS; + impl->base.caps.dwFlags |= DIDC_POSNEGCOEFFICIENTS; if (impl->pid_set_condition.positive_saturation_caps || impl->pid_set_condition.negative_saturation_caps) - impl->dev_caps.dwFlags |= DIDC_SATURATION|DIDC_POSNEGSATURATION; + impl->base.caps.dwFlags |= DIDC_SATURATION|DIDC_POSNEGSATURATION; if (impl->pid_set_condition.dead_band_caps) - impl->dev_caps.dwFlags |= DIDC_DEADBAND; - impl->dev_caps.dwFFSamplePeriod = 1000000; - impl->dev_caps.dwFFMinTimeResolution = 1000000; - impl->dev_caps.dwHardwareRevision = 1; - impl->dev_caps.dwFFDriverVersion = 1; + impl->base.caps.dwFlags |= DIDC_DEADBAND; + impl->base.caps.dwFFSamplePeriod = 1000000; + impl->base.caps.dwFFMinTimeResolution = 1000000; + impl->base.caps.dwHardwareRevision = 1; + impl->base.caps.dwFFDriverVersion = 1; }
format = impl->base.data_format.wine_df; diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index 3d78fd4de54..0a8c5b282ba 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -205,6 +205,9 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, SysKeyboar newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SysKeyboardImpl*->base.crit");
fill_keyboard_dideviceinstanceW( &newDevice->base.instance, newDevice->base.dinput->dwVersion, subtype ); + newDevice->base.caps.dwDevType = newDevice->base.instance.dwDevType; + newDevice->base.caps.dwFirmwareRevision = 100; + newDevice->base.caps.dwHardwareRevision = 100;
/* Create copy of default data format */ memcpy(df, &c_dfDIKeyboard, c_dfDIKeyboard.dwSize); @@ -223,6 +226,7 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, SysKeyboar df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(dik_code) | DIDFT_PSHBUTTON; } df->dwNumObjs = idx; + newDevice->base.caps.dwButtons = idx;
*out = newDevice; return DI_OK; @@ -289,42 +293,6 @@ static HRESULT WINAPI SysKeyboardWImpl_GetDeviceState(LPDIRECTINPUTDEVICE8W ifac return DI_OK; }
-/****************************************************************************** - * GetCapabilities : get the device capabilities - */ -static HRESULT WINAPI SysKeyboardWImpl_GetCapabilities(LPDIRECTINPUTDEVICE8W iface, LPDIDEVCAPS lpDIDevCaps) -{ - SysKeyboardImpl *This = impl_from_IDirectInputDevice8W(iface); - BYTE subtype = GET_DIDEVICE_SUBTYPE( This->base.instance.dwDevType ); - DIDEVCAPS devcaps; - - TRACE("(this=%p,%p)\n",This,lpDIDevCaps); - - if ((lpDIDevCaps->dwSize != sizeof(DIDEVCAPS)) && (lpDIDevCaps->dwSize != sizeof(DIDEVCAPS_DX3))) { - WARN("invalid parameter\n"); - return DIERR_INVALIDPARAM; - } - - devcaps.dwSize = lpDIDevCaps->dwSize; - devcaps.dwFlags = DIDC_ATTACHED | DIDC_EMULATED; - if (This->base.dinput->dwVersion >= 0x0800) - devcaps.dwDevType = DI8DEVTYPE_KEYBOARD | (subtype << 8); - else - devcaps.dwDevType = DIDEVTYPE_KEYBOARD | (subtype << 8); - devcaps.dwAxes = 0; - devcaps.dwButtons = This->base.data_format.wine_df->dwNumObjs; - devcaps.dwPOVs = 0; - devcaps.dwFFSamplePeriod = 0; - devcaps.dwFFMinTimeResolution = 0; - devcaps.dwFirmwareRevision = 100; - devcaps.dwHardwareRevision = 100; - devcaps.dwFFDriverVersion = 0; - - memcpy(lpDIDevCaps, &devcaps, lpDIDevCaps->dwSize); - - return DI_OK; -} - static DWORD map_dik_to_scan(DWORD dik_code, DWORD subtype) { if (dik_code == DIK_PAUSE || dik_code == DIK_NUMLOCK) dik_code ^= 0x80; @@ -469,7 +437,7 @@ static const IDirectInputDevice8WVtbl SysKeyboardWvt = IDirectInputDevice2WImpl_QueryInterface, IDirectInputDevice2WImpl_AddRef, IDirectInputDevice2WImpl_Release, - SysKeyboardWImpl_GetCapabilities, + IDirectInputDevice2WImpl_GetCapabilities, IDirectInputDevice2WImpl_EnumObjects, SysKeyboardWImpl_GetProperty, IDirectInputDevice2WImpl_SetProperty, diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index e11a9260fb2..6901cc09a31 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -149,6 +149,11 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, SysMouseIm newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SysMouseImpl*->base.crit");
fill_mouse_dideviceinstanceW( &newDevice->base.instance, newDevice->base.dinput->dwVersion ); + newDevice->base.caps.dwDevType = newDevice->base.instance.dwDevType; + newDevice->base.caps.dwAxes = 3; + newDevice->base.caps.dwButtons = 8; + newDevice->base.caps.dwFirmwareRevision = 100; + newDevice->base.caps.dwHardwareRevision = 100; newDevice->base.dwCoopLevel = DISCL_NONEXCLUSIVE | DISCL_BACKGROUND;
get_app_key(&hkey, &appkey); @@ -643,41 +648,6 @@ static HRESULT WINAPI SysMouseWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REF return DI_OK; }
-/****************************************************************************** - * GetCapabilities : get the device capabilities - */ -static HRESULT WINAPI SysMouseWImpl_GetCapabilities(LPDIRECTINPUTDEVICE8W iface, LPDIDEVCAPS lpDIDevCaps) -{ - SysMouseImpl *This = impl_from_IDirectInputDevice8W(iface); - DIDEVCAPS devcaps; - - TRACE("(this=%p,%p)\n",This,lpDIDevCaps); - - if ((lpDIDevCaps->dwSize != sizeof(DIDEVCAPS)) && (lpDIDevCaps->dwSize != sizeof(DIDEVCAPS_DX3))) { - WARN("invalid parameter\n"); - return DIERR_INVALIDPARAM; - } - - devcaps.dwSize = lpDIDevCaps->dwSize; - devcaps.dwFlags = DIDC_ATTACHED | DIDC_EMULATED; - if (This->base.dinput->dwVersion >= 0x0800) - devcaps.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8); - else - devcaps.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8); - devcaps.dwAxes = 3; - devcaps.dwButtons = 8; - devcaps.dwPOVs = 0; - devcaps.dwFFSamplePeriod = 0; - devcaps.dwFFMinTimeResolution = 0; - devcaps.dwFirmwareRevision = 100; - devcaps.dwHardwareRevision = 100; - devcaps.dwFFDriverVersion = 0; - - memcpy(lpDIDevCaps, &devcaps, lpDIDevCaps->dwSize); - - return DI_OK; -} - /****************************************************************************** * GetObjectInfo : get information about a device object such as a button * or axis @@ -732,7 +702,7 @@ static const IDirectInputDevice8WVtbl SysMouseWvt = IDirectInputDevice2WImpl_QueryInterface, IDirectInputDevice2WImpl_AddRef, IDirectInputDevice2WImpl_Release, - SysMouseWImpl_GetCapabilities, + IDirectInputDevice2WImpl_GetCapabilities, IDirectInputDevice2WImpl_EnumObjects, SysMouseWImpl_GetProperty, IDirectInputDevice2WImpl_SetProperty, diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index a2719f65488..cf50dd32fb9 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -3867,7 +3867,6 @@ static void test_simple_joystick(void) hr = IDirectInputDevice8_GetCapabilities( device, NULL ); ok( hr == E_POINTER, "GetCapabilities returned %#x\n", hr ); hr = IDirectInputDevice8_GetCapabilities( device, &caps ); - todo_wine ok( hr == DIERR_INVALIDPARAM, "GetCapabilities returned %#x\n", hr ); caps.dwSize = sizeof(DIDEVCAPS); hr = IDirectInputDevice8_GetCapabilities( device, &caps );