Rémi Bernon : dinput: Use the internal vtable for GetEffectInfo.

Alexandre Julliard julliard at winehq.org
Thu Oct 21 16:04:15 CDT 2021


Module: wine
Branch: master
Commit: f54210590f968d4fc8f22785c071514bb99400d2
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=f54210590f968d4fc8f22785c071514bb99400d2

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Thu Oct 21 09:53:43 2021 +0200

dinput: Use the internal vtable for GetEffectInfo.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dinput/device.c         | 18 +++++++++++-------
 dlls/dinput/device_private.h |  1 +
 dlls/dinput/joystick_hid.c   | 13 ++++---------
 dlls/dinput/keyboard.c       |  1 +
 dlls/dinput/mouse.c          |  1 +
 5 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
index e5713f4713d..ce163660e6c 100644
--- a/dlls/dinput/device.c
+++ b/dlls/dinput/device.c
@@ -1732,14 +1732,18 @@ HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects( IDirectInputDevice8W *iface
     return DI_OK;
 }
 
-HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo(
-	LPDIRECTINPUTDEVICE8W iface,
-	LPDIEFFECTINFOW lpdei,
-	REFGUID rguid)
+HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo( IDirectInputDevice8W *iface, DIEFFECTINFOW *info,
+                                                       const GUID *guid )
 {
-    IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
-    FIXME("(%p)->(%p,%s): stub!\n", This, lpdei, debugstr_guid(rguid));
-    return DI_OK;
+    IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8W( iface );
+
+    TRACE( "iface %p, info %p, guid %s.\n", iface, info, debugstr_guid( guid ) );
+
+    if (!info) return E_POINTER;
+    if (info->dwSize != sizeof(DIEFFECTINFOW)) return DIERR_INVALIDPARAM;
+    if (!(impl->caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_DEVICENOTREG;
+    if (!impl->vtbl->get_effect_info) return DIERR_UNSUPPORTED;
+    return impl->vtbl->get_effect_info( iface, info, guid );
 }
 
 HRESULT WINAPI IDirectInputDevice2WImpl_GetForceFeedbackState(LPDIRECTINPUTDEVICE8W iface, LPDWORD pdwOut)
diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h
index bdac5b4a378..0b5919c7ec6 100644
--- a/dlls/dinput/device_private.h
+++ b/dlls/dinput/device_private.h
@@ -68,6 +68,7 @@ struct dinput_device_vtbl
                              DIDEVICEOBJECTINSTANCEW *instance );
     HRESULT (*set_property)( IDirectInputDevice8W *iface, DWORD property, const DIPROPHEADER *header,
                              const DIDEVICEOBJECTINSTANCEW *instance );
+    HRESULT (*get_effect_info)( IDirectInputDevice8W *iface, DIEFFECTINFOW *info, const GUID *guid );
 };
 
 #define DEVICE_STATE_MAX_SIZE 1024
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c
index 91b6020d1f1..1e1f8c05e3f 100644
--- a/dlls/dinput/joystick_hid.c
+++ b/dlls/dinput/joystick_hid.c
@@ -838,8 +838,8 @@ failed:
     return hr;
 }
 
-static HRESULT WINAPI hid_joystick_GetEffectInfo( IDirectInputDevice8W *iface, DIEFFECTINFOW *info,
-                                                  const GUID *guid )
+static HRESULT hid_joystick_internal_get_effect_info( IDirectInputDevice8W *iface, DIEFFECTINFOW *info,
+                                                      const GUID *guid )
 {
     struct hid_joystick *impl = impl_from_IDirectInputDevice8W( iface );
     struct pid_effect_update *effect_update = &impl->pid_effect_update;
@@ -853,12 +853,6 @@ static HRESULT WINAPI hid_joystick_GetEffectInfo( IDirectInputDevice8W *iface, D
     USAGE usage = 0;
     USHORT count;
 
-    TRACE( "iface %p, info %p, guid %s.\n", iface, info, debugstr_guid( guid ) );
-
-    if (!info) return E_POINTER;
-    if (info->dwSize != sizeof(DIEFFECTINFOW)) return DIERR_INVALIDPARAM;
-    if (!(impl->base.caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_DEVICENOTREG;
-
     switch ((usage = effect_guid_to_usage( guid )))
     {
     case PID_USAGE_ET_SQUARE:
@@ -1085,7 +1079,7 @@ static const IDirectInputDevice8WVtbl hid_joystick_vtbl =
     /*** IDirectInputDevice2 methods ***/
     hid_joystick_CreateEffect,
     IDirectInputDevice2WImpl_EnumEffects,
-    hid_joystick_GetEffectInfo,
+    IDirectInputDevice2WImpl_GetEffectInfo,
     hid_joystick_GetForceFeedbackState,
     hid_joystick_SendForceFeedbackCommand,
     hid_joystick_EnumCreatedEffectObjects,
@@ -1326,6 +1320,7 @@ static const struct dinput_device_vtbl hid_joystick_internal_vtbl =
     hid_joystick_internal_enum_objects,
     hid_joystick_internal_get_property,
     hid_joystick_internal_set_property,
+    hid_joystick_internal_get_effect_info,
 };
 
 static DWORD device_type_for_version( DWORD type, DWORD version )
diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c
index f17dc89ac16..1127ec2aaea 100644
--- a/dlls/dinput/keyboard.c
+++ b/dlls/dinput/keyboard.c
@@ -338,6 +338,7 @@ static const struct dinput_device_vtbl keyboard_internal_vtbl =
     keyboard_internal_enum_objects,
     keyboard_internal_get_property,
     keyboard_internal_set_property,
+    NULL,
 };
 
 static const IDirectInputDevice8WVtbl SysKeyboardWvt =
diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c
index 7fafa7696a7..69348ad2c7f 100644
--- a/dlls/dinput/mouse.c
+++ b/dlls/dinput/mouse.c
@@ -651,6 +651,7 @@ static const struct dinput_device_vtbl mouse_internal_vtbl =
     mouse_internal_enum_objects,
     mouse_internal_get_property,
     mouse_internal_set_property,
+    NULL,
 };
 
 static const IDirectInputDevice8WVtbl SysMouseWvt =




More information about the wine-cvs mailing list