Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 12 ++++++------ dlls/dinput/joystick.c | 8 +++++++- dlls/dinput/mouse.c | 8 +++++++- dlls/dinput/tests/device.c | 10 ++++++++++ 4 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 31b859801c7..c1388551644 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1457,9 +1457,9 @@ HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo( DIDEVICEOBJECTINSTANCEW didoiW; HRESULT res;
- if (!pdidoi || - (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA) && - pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A))) + if (!pdidoi) return E_POINTER; + if (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA) && + pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A)) return DIERR_INVALIDPARAM;
didoiW.dwSize = sizeof(didoiW); @@ -1492,9 +1492,9 @@ HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(
TRACE("(%p) %d(0x%08x) -> %p\n", This, dwHow, dwObj, pdidoi);
- if (!pdidoi || - (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEW) && - pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3W))) + if (!pdidoi) return E_POINTER; + if (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEW) && + pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3W)) return DIERR_INVALIDPARAM;
switch (dwHow) diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c index 3749eed7efe..ab8b87f552b 100644 --- a/dlls/dinput/joystick.c +++ b/dlls/dinput/joystick.c @@ -580,12 +580,18 @@ HRESULT WINAPI JoystickAGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface, JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface); HRESULT res; DIDEVICEOBJECTINSTANCEW didoiW; - DWORD dwSize = pdidoi->dwSize; + DWORD dwSize; + + if (!pdidoi) return E_POINTER; + if (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA) && + pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A)) + return DIERR_INVALIDPARAM;
didoiW.dwSize = sizeof(didoiW); res = JoystickWGenericImpl_GetObjectInfo(IDirectInputDevice8W_from_impl(This), &didoiW, dwObj, dwHow); if (res != DI_OK) return res;
+ dwSize = pdidoi->dwSize; memset(pdidoi, 0, pdidoi->dwSize); memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName)); pdidoi->dwSize = dwSize; diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index 65f173daa81..bc99ea37c68 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -802,12 +802,18 @@ static HRESULT WINAPI SysMouseAImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface, SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface); HRESULT res; DIDEVICEOBJECTINSTANCEW didoiW; - DWORD dwSize = pdidoi->dwSize; + DWORD dwSize; + + if (!pdidoi) return E_POINTER; + if (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA) && + pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A)) + return DIERR_INVALIDPARAM;
didoiW.dwSize = sizeof(didoiW); res = SysMouseWImpl_GetObjectInfo(IDirectInputDevice8W_from_impl(This), &didoiW, dwObj, dwHow); if (res != DI_OK) return res;
+ dwSize = pdidoi->dwSize; memset(pdidoi, 0, pdidoi->dwSize); memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName)); pdidoi->dwSize = dwSize; diff --git a/dlls/dinput/tests/device.c b/dlls/dinput/tests/device.c index 9be00a671fb..485acca4f61 100644 --- a/dlls/dinput/tests/device.c +++ b/dlls/dinput/tests/device.c @@ -158,6 +158,16 @@ static void test_object_info(IDirectInputDeviceA *device, HWND hwnd) hr = IDirectInputDevice_GetDeviceData(device, sizeof(buffer[0]), buffer, &cnt, 0); ok(hr == DI_OK, "GetDeviceData() failed: %08x\n", hr);
+ hr = IDirectInputDevice_GetObjectInfo(device, NULL, 16, DIPH_BYOFFSET); + ok(hr == E_POINTER, "IDirectInputDevice_GetObjectInfo returned %08x, expected %08x\n", hr, E_POINTER); + + obj_info.dwSize = 1; + hr = IDirectInputDevice_GetObjectInfo(device, &obj_info, 16, DIPH_BYOFFSET); + ok(hr == DIERR_INVALIDPARAM, "IDirectInputDevice_GetObjectInfo returned %08x, expected %08x\n", hr, DIERR_INVALIDPARAM); + obj_info.dwSize = 0xdeadbeef; + hr = IDirectInputDevice_GetObjectInfo(device, &obj_info, 16, DIPH_BYOFFSET); + ok(hr == DIERR_INVALIDPARAM, "IDirectInputDevice_GetObjectInfo returned %08x, expected %08x\n", hr, DIERR_INVALIDPARAM); + /* No need to test devices without axis */ obj_info.dwSize = sizeof(obj_info); hr = IDirectInputDevice_GetObjectInfo(device, &obj_info, 16, DIPH_BYOFFSET);
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/ansi.c | 19 ++++++++++++++++++ dlls/dinput/device.c | 32 ------------------------------- dlls/dinput/joystick.c | 27 -------------------------- dlls/dinput/joystick_linux.c | 2 +- dlls/dinput/joystick_linuxinput.c | 2 +- dlls/dinput/joystick_osx.c | 2 +- dlls/dinput/joystick_private.h | 3 --- dlls/dinput/keyboard.c | 25 +----------------------- dlls/dinput/mouse.c | 29 +--------------------------- 9 files changed, 24 insertions(+), 117 deletions(-)
diff --git a/dlls/dinput/ansi.c b/dlls/dinput/ansi.c index 5158d326073..eafbeafbf18 100644 --- a/dlls/dinput/ansi.c +++ b/dlls/dinput/ansi.c @@ -169,6 +169,25 @@ HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel( IDirectInputDevice8 return IDirectInputDevice8_SetCooperativeLevel( iface_w, window, flags ); }
+HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo( IDirectInputDevice8A *iface_a, DIDEVICEOBJECTINSTANCEA *instance_a, + DWORD obj, DWORD how ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + DIDEVICEOBJECTINSTANCEW instance_w = {sizeof(instance_w)}; + HRESULT hr; + + if (!instance_a) return E_POINTER; + if (instance_a->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA) && + instance_a->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A)) + return DIERR_INVALIDPARAM; + + hr = IDirectInputDevice8_GetObjectInfo( iface_w, &instance_w, obj, how ); + dideviceobjectinstance_wtoa( &instance_w, instance_a ); + + return hr; +} + HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel( IDirectInputDevice8A *iface_a, HWND owner, DWORD flags ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index c1388551644..16bf4c663a1 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1447,38 +1447,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetProperty( return DI_OK; }
-HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo( - LPDIRECTINPUTDEVICE8A iface, - LPDIDEVICEOBJECTINSTANCEA pdidoi, - DWORD dwObj, - DWORD dwHow) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - DIDEVICEOBJECTINSTANCEW didoiW; - HRESULT res; - - if (!pdidoi) return E_POINTER; - if (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA) && - pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A)) - return DIERR_INVALIDPARAM; - - didoiW.dwSize = sizeof(didoiW); - res = IDirectInputDevice2WImpl_GetObjectInfo(IDirectInputDevice8W_from_impl(This), &didoiW, dwObj, dwHow); - if (res == DI_OK) - { - DWORD dwSize = pdidoi->dwSize; - - memset(pdidoi, 0, pdidoi->dwSize); - pdidoi->dwSize = dwSize; - pdidoi->guidType = didoiW.guidType; - pdidoi->dwOfs = didoiW.dwOfs; - pdidoi->dwType = didoiW.dwType; - pdidoi->dwFlags = didoiW.dwFlags; - } - - return res; -} - HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo( LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEOBJECTINSTANCEW pdidoi, diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c index ab8b87f552b..b79935ede7c 100644 --- a/dlls/dinput/joystick.c +++ b/dlls/dinput/joystick.c @@ -574,33 +574,6 @@ HRESULT WINAPI JoystickWGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, return res; }
-HRESULT WINAPI JoystickAGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface, - LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) -{ - JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface); - HRESULT res; - DIDEVICEOBJECTINSTANCEW didoiW; - DWORD dwSize; - - if (!pdidoi) return E_POINTER; - if (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA) && - pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A)) - return DIERR_INVALIDPARAM; - - didoiW.dwSize = sizeof(didoiW); - res = JoystickWGenericImpl_GetObjectInfo(IDirectInputDevice8W_from_impl(This), &didoiW, dwObj, dwHow); - if (res != DI_OK) return res; - - dwSize = pdidoi->dwSize; - memset(pdidoi, 0, pdidoi->dwSize); - memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName)); - pdidoi->dwSize = dwSize; - WideCharToMultiByte(CP_ACP, 0, didoiW.tszName, -1, pdidoi->tszName, - sizeof(pdidoi->tszName), NULL, NULL); - - return res; -} - /****************************************************************************** * GetProperty : get input device properties */ diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index ec4cb94c034..091e1f2152e 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -918,7 +918,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt = IDirectInputDevice2AImpl_SetDataFormat, IDirectInputDevice2AImpl_SetEventNotification, IDirectInputDevice2AImpl_SetCooperativeLevel, - JoystickAGenericImpl_GetObjectInfo, + IDirectInputDevice2AImpl_GetObjectInfo, JoystickLinuxAImpl_GetDeviceInfo, IDirectInputDevice2AImpl_RunControlPanel, IDirectInputDevice2AImpl_Initialize, diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 14acbb5cd8c..49eaf3ed44d 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -1439,7 +1439,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt = IDirectInputDevice2AImpl_SetDataFormat, IDirectInputDevice2AImpl_SetEventNotification, IDirectInputDevice2AImpl_SetCooperativeLevel, - JoystickAGenericImpl_GetObjectInfo, + IDirectInputDevice2AImpl_GetObjectInfo, JoystickAImpl_GetDeviceInfo, IDirectInputDevice2AImpl_RunControlPanel, IDirectInputDevice2AImpl_Initialize, diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c index 174a78b7fd4..78e041daf92 100644 --- a/dlls/dinput/joystick_osx.c +++ b/dlls/dinput/joystick_osx.c @@ -1590,7 +1590,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt = IDirectInputDevice2AImpl_SetDataFormat, IDirectInputDevice2AImpl_SetEventNotification, IDirectInputDevice2AImpl_SetCooperativeLevel, - JoystickAGenericImpl_GetObjectInfo, + IDirectInputDevice2AImpl_GetObjectInfo, JoystickAGenericImpl_GetDeviceInfo, IDirectInputDevice2AImpl_RunControlPanel, IDirectInputDevice2AImpl_Initialize, diff --git a/dlls/dinput/joystick_private.h b/dlls/dinput/joystick_private.h index 0f191787158..2a25bf4eb23 100644 --- a/dlls/dinput/joystick_private.h +++ b/dlls/dinput/joystick_private.h @@ -62,9 +62,6 @@ BOOL device_disabled_registry(const char* name) DECLSPEC_HIDDEN; HRESULT WINAPI JoystickWGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) DECLSPEC_HIDDEN;
-HRESULT WINAPI JoystickAGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface, - LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) DECLSPEC_HIDDEN; - HRESULT WINAPI JoystickWGenericImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph) DECLSPEC_HIDDEN;
HRESULT WINAPI JoystickAGenericImpl_GetCapabilities(LPDIRECTINPUTDEVICE8A iface, LPDIDEVCAPS lpDIDevCaps) DECLSPEC_HIDDEN; diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index ca3b1dad669..b1914d057bd 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -463,29 +463,6 @@ static DWORD map_dik_to_scan(DWORD dik_code, DWORD subtype) * GetObjectInfo : get information about a device object such as a button * or axis */ -static HRESULT WINAPI -SysKeyboardAImpl_GetObjectInfo( - LPDIRECTINPUTDEVICE8A iface, - LPDIDEVICEOBJECTINSTANCEA pdidoi, - DWORD dwObj, - DWORD dwHow) -{ - SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface); - HRESULT res; - LONG scan; - - res = IDirectInputDevice2AImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow); - if (res != DI_OK) return res; - - scan = map_dik_to_scan(DIDFT_GETINSTANCE(pdidoi->dwType), This->subtype); - if (!GetKeyNameTextA((scan & 0x80) << 17 | (scan & 0x7f) << 16, - pdidoi->tszName, sizeof(pdidoi->tszName))) - return DIERR_OBJECTNOTFOUND; - - _dump_OBJECTINSTANCEA(pdidoi); - return res; -} - static HRESULT WINAPI SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, @@ -691,7 +668,7 @@ static const IDirectInputDevice8AVtbl SysKeyboardAvt = IDirectInputDevice2AImpl_SetDataFormat, IDirectInputDevice2AImpl_SetEventNotification, IDirectInputDevice2AImpl_SetCooperativeLevel, - SysKeyboardAImpl_GetObjectInfo, + IDirectInputDevice2AImpl_GetObjectInfo, SysKeyboardAImpl_GetDeviceInfo, IDirectInputDevice2AImpl_RunControlPanel, IDirectInputDevice2AImpl_Initialize, diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index bc99ea37c68..9267d92d6e9 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -796,33 +796,6 @@ static HRESULT WINAPI SysMouseWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, return res; }
-static HRESULT WINAPI SysMouseAImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface, - LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) -{ - SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface); - HRESULT res; - DIDEVICEOBJECTINSTANCEW didoiW; - DWORD dwSize; - - if (!pdidoi) return E_POINTER; - if (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA) && - pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A)) - return DIERR_INVALIDPARAM; - - didoiW.dwSize = sizeof(didoiW); - res = SysMouseWImpl_GetObjectInfo(IDirectInputDevice8W_from_impl(This), &didoiW, dwObj, dwHow); - if (res != DI_OK) return res; - - dwSize = pdidoi->dwSize; - memset(pdidoi, 0, pdidoi->dwSize); - memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName)); - pdidoi->dwSize = dwSize; - WideCharToMultiByte(CP_ACP, 0, didoiW.tszName, -1, pdidoi->tszName, - sizeof(pdidoi->tszName), NULL, NULL); - - return res; -} - /****************************************************************************** * GetDeviceInfo : get information about a device's identity */ @@ -949,7 +922,7 @@ static const IDirectInputDevice8AVtbl SysMouseAvt = IDirectInputDevice2AImpl_SetDataFormat, IDirectInputDevice2AImpl_SetEventNotification, IDirectInputDevice2AImpl_SetCooperativeLevel, - SysMouseAImpl_GetObjectInfo, + IDirectInputDevice2AImpl_GetObjectInfo, SysMouseAImpl_GetDeviceInfo, IDirectInputDevice2AImpl_RunControlPanel, IDirectInputDevice2AImpl_Initialize,
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/ansi.c | 25 +++++++++++++++++++++++ dlls/dinput/device.c | 10 --------- dlls/dinput/effect_linuxinput.c | 34 ------------------------------- dlls/dinput/joystick_linuxinput.c | 18 +--------------- 4 files changed, 26 insertions(+), 61 deletions(-)
diff --git a/dlls/dinput/ansi.c b/dlls/dinput/ansi.c index eafbeafbf18..36b17812f32 100644 --- a/dlls/dinput/ansi.c +++ b/dlls/dinput/ansi.c @@ -64,6 +64,15 @@ static void dideviceobjectinstance_wtoa( const DIDEVICEOBJECTINSTANCEW *in, DIDE out->wReserved = in->wReserved; }
+static void dieffectinfo_wtoa( const DIEFFECTINFOW *in, DIEFFECTINFOA *out ) +{ + out->guid = in->guid; + out->dwEffType = in->dwEffType; + out->dwStaticParams = in->dwStaticParams; + out->dwDynamicParams = in->dwDynamicParams; + WideCharToMultiByte( CP_ACP, 0, in->tszName, -1, out->tszName, sizeof(out->tszName), NULL, NULL ); +} + HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface( IDirectInputDevice8A *iface_a, REFIID iid, void **out ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); @@ -210,6 +219,22 @@ HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect( IDirectInputDevice8A *ifac return IDirectInputDevice8_CreateEffect( iface_w, guid, effect, out, outer ); }
+HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo( IDirectInputDevice8A *iface_a, DIEFFECTINFOA *info_a, REFGUID guid ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + DIEFFECTINFOW info_w = {sizeof(info_w)}; + HRESULT hr; + + if (!info_a) return E_POINTER; + if (info_a->dwSize != sizeof(DIEFFECTINFOA)) return DIERR_INVALIDPARAM; + + hr = IDirectInputDevice8_GetEffectInfo( iface_w, &info_w, guid ); + dieffectinfo_wtoa( &info_w, info_a ); + + return hr; +} + HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState( IDirectInputDevice8A *iface_a, DWORD *state ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 16bf4c663a1..850a4a09c37 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1611,16 +1611,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects( return DI_OK; }
-HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo( - LPDIRECTINPUTDEVICE8A iface, - LPDIEFFECTINFOA lpdei, - REFGUID rguid) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - FIXME("(%p)->(%p,%s): stub!\n", This, lpdei, debugstr_guid(rguid)); - return DI_OK; -} - HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo( LPDIRECTINPUTDEVICE8W iface, LPDIEFFECTINFOW lpdei, diff --git a/dlls/dinput/effect_linuxinput.c b/dlls/dinput/effect_linuxinput.c index ec4b00b873a..486163aeffa 100644 --- a/dlls/dinput/effect_linuxinput.c +++ b/dlls/dinput/effect_linuxinput.c @@ -852,40 +852,6 @@ DECLSPEC_HIDDEN HRESULT linuxinput_create_effect( return DI_OK; }
-DECLSPEC_HIDDEN HRESULT linuxinput_get_info_A( - int fd, - REFGUID rguid, - LPDIEFFECTINFOA info) -{ - DWORD type = typeFromGUID(rguid); - - TRACE("(%d, %s, %p) type=%d\n", fd, _dump_dinput_GUID(rguid), info, type); - - if (!info) return E_POINTER; - - if (info->dwSize != sizeof(DIEFFECTINFOA)) return DIERR_INVALIDPARAM; - - info->guid = *rguid; - - info->dwEffType = type; - /* the event device API does not support querying for all these things - * therefore we assume that we have support for them - * that's not as dangerous as it sounds, since drivers are allowed to - * ignore parameters they claim to support anyway */ - info->dwEffType |= DIEFT_DEADBAND | DIEFT_FFATTACK | DIEFT_FFFADE - | DIEFT_POSNEGCOEFFICIENTS | DIEFT_POSNEGSATURATION - | DIEFT_SATURATION | DIEFT_STARTDELAY; - - /* again, assume we have support for everything */ - info->dwStaticParams = DIEP_ALLPARAMS; - info->dwDynamicParams = info->dwStaticParams; - - /* yes, this is windows behavior (print the GUID_Name for name) */ - strcpy(info->tszName, _dump_dinput_GUID(rguid)); - - return DI_OK; -} - DECLSPEC_HIDDEN HRESULT linuxinput_get_info_W( int fd, REFGUID rguid, diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 49eaf3ed44d..dc7f5491c81 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -86,7 +86,6 @@ struct wine_input_absinfo {
/* implemented in effect_linuxinput.c */ HRESULT linuxinput_create_effect(int* fd, REFGUID rguid, struct list *parent_list_entry, LPDIRECTINPUTEFFECT* peff); -HRESULT linuxinput_get_info_A(int fd, REFGUID rguid, LPDIEFFECTINFOA info); HRESULT linuxinput_get_info_W(int fd, REFGUID rguid, LPDIEFFECTINFOW info);
static HRESULT WINAPI JoystickWImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8W iface, DWORD dwFlags); @@ -1251,21 +1250,6 @@ static HRESULT WINAPI JoystickWImpl_EnumEffects(LPDIRECTINPUTDEVICE8W iface, /******************************************************************************* * GetEffectInfo - Get information about a particular effect */ -static HRESULT WINAPI JoystickAImpl_GetEffectInfo(LPDIRECTINPUTDEVICE8A iface, - LPDIEFFECTINFOA pdei, - REFGUID guid) -{ - JoystickImpl* This = impl_from_IDirectInputDevice8A(iface); - - TRACE("(this=%p,%p,%s)\n", This, pdei, _dump_dinput_GUID(guid)); - -#ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION - return linuxinput_get_info_A(This->joyfd, guid, pdei); -#else - return DI_OK; -#endif -} - static HRESULT WINAPI JoystickWImpl_GetEffectInfo(LPDIRECTINPUTDEVICE8W iface, LPDIEFFECTINFOW pdei, REFGUID guid) @@ -1445,7 +1429,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt = IDirectInputDevice2AImpl_Initialize, IDirectInputDevice2AImpl_CreateEffect, JoystickAImpl_EnumEffects, - JoystickAImpl_GetEffectInfo, + IDirectInputDevice2AImpl_GetEffectInfo, IDirectInputDevice2AImpl_GetForceFeedbackState, IDirectInputDevice2AImpl_SendForceFeedbackCommand, IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/ansi.c | 27 +++++++++++ dlls/dinput/device.c | 12 ----- dlls/dinput/joystick_linuxinput.c | 76 +------------------------------ 3 files changed, 28 insertions(+), 87 deletions(-)
diff --git a/dlls/dinput/ansi.c b/dlls/dinput/ansi.c index 36b17812f32..eb331891f25 100644 --- a/dlls/dinput/ansi.c +++ b/dlls/dinput/ansi.c @@ -219,6 +219,33 @@ HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect( IDirectInputDevice8A *ifac return IDirectInputDevice8_CreateEffect( iface_w, guid, effect, out, outer ); }
+struct enum_effects_wtoa_params +{ + LPDIENUMEFFECTSCALLBACKA callback; + void *ref; +}; + +static BOOL CALLBACK enum_effects_wtoa_callback( const DIEFFECTINFOW *info_w, void *ref ) +{ + struct enum_effects_wtoa_params *params = ref; + DIEFFECTINFOA info_a = {sizeof(info_a)}; + + dieffectinfo_wtoa( info_w, &info_a ); + return params->callback( &info_a, params->ref ); +} + +HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects( IDirectInputDevice8A *iface_a, LPDIENUMEFFECTSCALLBACKA callback, + void *ref, DWORD type ) +{ + struct enum_effects_wtoa_params params = {callback, ref}; + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + + if (!callback) return DIERR_INVALIDPARAM; + + return IDirectInputDevice8_EnumEffects( iface_w, enum_effects_wtoa_callback, ¶ms, type ); +} + HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo( IDirectInputDevice8A *iface_a, DIEFFECTINFOA *info_a, REFGUID guid ) { IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 850a4a09c37..abdb235c097 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1587,18 +1587,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_CreateEffect(LPDIRECTINPUTDEVICE8W iface return DIERR_UNSUPPORTED; }
-HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects( - LPDIRECTINPUTDEVICE8A iface, - LPDIENUMEFFECTSCALLBACKA lpCallback, - LPVOID lpvRef, - DWORD dwFlags) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - FIXME("%p)->(%p,%p,0x%08x): stub!\n", This, lpCallback, lpvRef, dwFlags); - - return DI_OK; -} - HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects( LPDIRECTINPUTDEVICE8W iface, LPDIENUMEFFECTSCALLBACKW lpCallback, diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index dc7f5491c81..307b447d237 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -1093,80 +1093,6 @@ static HRESULT WINAPI JoystickWImpl_CreateEffect(LPDIRECTINPUTDEVICE8W iface, RE /******************************************************************************* * EnumEffects - Enumerate available FF effects */ -static HRESULT WINAPI JoystickAImpl_EnumEffects(LPDIRECTINPUTDEVICE8A iface, - LPDIENUMEFFECTSCALLBACKA lpCallback, - LPVOID pvRef, - DWORD dwEffType) -{ -#ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION - DIEFFECTINFOA dei; /* feif */ - DWORD type = DIEFT_GETTYPE(dwEffType); - JoystickImpl* This = impl_from_IDirectInputDevice8A(iface); - - TRACE("(this=%p,%p,%d) type=%d\n", This, pvRef, dwEffType, type); - - dei.dwSize = sizeof(DIEFFECTINFOA); - - if ((type == DIEFT_ALL || type == DIEFT_CONSTANTFORCE) - && test_bit(This->joydev->ffbits, FF_CONSTANT)) { - IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_ConstantForce); - (*lpCallback)(&dei, pvRef); - } - - if ((type == DIEFT_ALL || type == DIEFT_PERIODIC) - && test_bit(This->joydev->ffbits, FF_PERIODIC)) { - if (test_bit(This->joydev->ffbits, FF_SQUARE)) { - IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Square); - (*lpCallback)(&dei, pvRef); - } - if (test_bit(This->joydev->ffbits, FF_SINE)) { - IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Sine); - (*lpCallback)(&dei, pvRef); - } - if (test_bit(This->joydev->ffbits, FF_TRIANGLE)) { - IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Triangle); - (*lpCallback)(&dei, pvRef); - } - if (test_bit(This->joydev->ffbits, FF_SAW_UP)) { - IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_SawtoothUp); - (*lpCallback)(&dei, pvRef); - } - if (test_bit(This->joydev->ffbits, FF_SAW_DOWN)) { - IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_SawtoothDown); - (*lpCallback)(&dei, pvRef); - } - } - - if ((type == DIEFT_ALL || type == DIEFT_RAMPFORCE) - && test_bit(This->joydev->ffbits, FF_RAMP)) { - IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_RampForce); - (*lpCallback)(&dei, pvRef); - } - - if (type == DIEFT_ALL || type == DIEFT_CONDITION) { - if (test_bit(This->joydev->ffbits, FF_SPRING)) { - IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Spring); - (*lpCallback)(&dei, pvRef); - } - if (test_bit(This->joydev->ffbits, FF_DAMPER)) { - IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Damper); - (*lpCallback)(&dei, pvRef); - } - if (test_bit(This->joydev->ffbits, FF_INERTIA)) { - IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Inertia); - (*lpCallback)(&dei, pvRef); - } - if (test_bit(This->joydev->ffbits, FF_FRICTION)) { - IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Friction); - (*lpCallback)(&dei, pvRef); - } - } - -#endif - - return DI_OK; -} - static HRESULT WINAPI JoystickWImpl_EnumEffects(LPDIRECTINPUTDEVICE8W iface, LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID pvRef, @@ -1428,7 +1354,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt = IDirectInputDevice2AImpl_RunControlPanel, IDirectInputDevice2AImpl_Initialize, IDirectInputDevice2AImpl_CreateEffect, - JoystickAImpl_EnumEffects, + IDirectInputDevice2AImpl_EnumEffects, IDirectInputDevice2AImpl_GetEffectInfo, IDirectInputDevice2AImpl_GetForceFeedbackState, IDirectInputDevice2AImpl_SendForceFeedbackCommand,
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/ansi.c | 13 +++++++++++++ dlls/dinput/device.c | 12 ------------ 2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/dlls/dinput/ansi.c b/dlls/dinput/ansi.c index eb331891f25..05fc42440d7 100644 --- a/dlls/dinput/ansi.c +++ b/dlls/dinput/ansi.c @@ -305,3 +305,16 @@ HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData( IDirectInputDevice8A *if IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); return IDirectInputDevice8_SendDeviceData( iface_w, count, data, inout, flags ); } + +HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile( IDirectInputDevice8A *iface_a, const char *filename_a, LPDIENUMEFFECTSINFILECALLBACK callback, + void *ref, DWORD flags ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + WCHAR buffer[MAX_PATH], *filename_w = buffer; + + if (!filename_a) filename_w = NULL; + else MultiByteToWideChar( CP_ACP, 0, filename_a, -1, buffer, MAX_PATH ); + + return IDirectInputDevice8_EnumEffectsInFile( iface_w, filename_w, callback, ref, flags ); +} diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index abdb235c097..fe9510d539d 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1658,18 +1658,6 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SendDeviceData(LPDIRECTINPUTDEVICE8W ifa return DI_OK; }
-HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8A iface, - LPCSTR lpszFileName, - LPDIENUMEFFECTSINFILECALLBACK pec, - LPVOID pvRef, - DWORD dwFlags) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - FIXME("(%p)->(%s,%p,%p,%08x): stub !\n", This, lpszFileName, pec, pvRef, dwFlags); - - return DI_OK; -} - HRESULT WINAPI IDirectInputDevice7WImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8W iface, LPCWSTR lpszFileName, LPDIENUMEFFECTSINFILECALLBACK pec,
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/ansi.c | 13 +++++++++++++ dlls/dinput/device.c | 12 ------------ 2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/dlls/dinput/ansi.c b/dlls/dinput/ansi.c index 05fc42440d7..5d1ea9f0b4e 100644 --- a/dlls/dinput/ansi.c +++ b/dlls/dinput/ansi.c @@ -318,3 +318,16 @@ HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile( IDirectInputDevice8A
return IDirectInputDevice8_EnumEffectsInFile( iface_w, filename_w, callback, ref, flags ); } + +HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile( IDirectInputDevice8A *iface_a, const char *filename_a, DWORD entries, + DIFILEEFFECT *file_effect, DWORD flags ) +{ + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8A( iface_a ); + IDirectInputDevice8W *iface_w = IDirectInputDevice8W_from_impl( impl ); + WCHAR buffer[MAX_PATH], *filename_w = buffer; + + if (!filename_a) filename_w = NULL; + else MultiByteToWideChar( CP_ACP, 0, filename_a, -1, buffer, MAX_PATH ); + + return IDirectInputDevice8_WriteEffectToFile( iface_w, filename_w, entries, file_effect, flags ); +} diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index fe9510d539d..541f39954f6 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1670,18 +1670,6 @@ HRESULT WINAPI IDirectInputDevice7WImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8W return DI_OK; }
-HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A iface, - LPCSTR lpszFileName, - DWORD dwEntries, - LPDIFILEEFFECT rgDiFileEft, - DWORD dwFlags) -{ - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface); - FIXME("(%p)->(%s,%08x,%p,%08x): stub !\n", This, lpszFileName, dwEntries, rgDiFileEft, dwFlags); - - return DI_OK; -} - HRESULT WINAPI IDirectInputDevice7WImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8W iface, LPCWSTR lpszFileName, DWORD dwEntries,