From 70b25ccfaae48172278800f660fd92e40735ec69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Wed, 26 May 2021 11:23:05 +0200 Subject: [PATCH] dinput: Implement IDirectInputDevice_GetEffectInfo WtoA conversion. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: RĂ©mi Bernon Signed-off-by: Alexandre Julliard --- 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,