Rémi Bernon : dinput: Replace stub EnumEffects with generic implementation.

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


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

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

dinput: Replace stub EnumEffects with generic implementation.

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

---

 dlls/dinput/device.c       | 73 +++++++++++++++++++++++++++++++++++++++++-----
 dlls/dinput/joystick_hid.c | 73 +---------------------------------------------
 2 files changed, 67 insertions(+), 79 deletions(-)

diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
index 8858bfa26bb..e5713f4713d 100644
--- a/dlls/dinput/device.c
+++ b/dlls/dinput/device.c
@@ -1661,14 +1661,73 @@ HRESULT WINAPI IDirectInputDevice2WImpl_CreateEffect(LPDIRECTINPUTDEVICE8W iface
     return DIERR_UNSUPPORTED;
 }
 
-HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects(
-	LPDIRECTINPUTDEVICE8W iface,
-	LPDIENUMEFFECTSCALLBACKW lpCallback,
-	LPVOID lpvRef,
-	DWORD dwFlags)
+HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects( IDirectInputDevice8W *iface, LPDIENUMEFFECTSCALLBACKW callback,
+                                                     void *context, DWORD type )
 {
-    IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
-    FIXME("(%p)->(%p,%p,0x%08x): stub!\n", This, lpCallback, lpvRef, dwFlags);
+    DIEFFECTINFOW info = {.dwSize = sizeof(info)};
+    HRESULT hr;
+
+    TRACE( "iface %p, callback %p, context %p, type %#x.\n", iface, callback, context, type );
+
+    if (!callback) return DIERR_INVALIDPARAM;
+
+    type = DIEFT_GETTYPE( type );
+
+    if (type == DIEFT_ALL || type == DIEFT_CONSTANTFORCE)
+    {
+        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_ConstantForce );
+        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
+        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
+    }
+
+    if (type == DIEFT_ALL || type == DIEFT_RAMPFORCE)
+    {
+        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_RampForce );
+        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
+        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
+    }
+
+    if (type == DIEFT_ALL || type == DIEFT_PERIODIC)
+    {
+        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Square );
+        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
+        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
+
+        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Sine );
+        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
+        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
+
+        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Triangle );
+        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
+        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
+
+        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_SawtoothUp );
+        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
+        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
+
+        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_SawtoothDown );
+        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
+        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
+    }
+
+    if (type == DIEFT_ALL || type == DIEFT_CONDITION)
+    {
+        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Spring );
+        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
+        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
+
+        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Damper );
+        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
+        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
+
+        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Inertia );
+        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
+        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
+
+        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Friction );
+        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
+        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
+    }
 
     return DI_OK;
 }
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c
index 766e022ebe0..91b6020d1f1 100644
--- a/dlls/dinput/joystick_hid.c
+++ b/dlls/dinput/joystick_hid.c
@@ -838,77 +838,6 @@ failed:
     return hr;
 }
 
-static HRESULT WINAPI hid_joystick_EnumEffects( IDirectInputDevice8W *iface, LPDIENUMEFFECTSCALLBACKW callback,
-                                                void *context, DWORD type )
-{
-    DIEFFECTINFOW info = {.dwSize = sizeof(info)};
-    HRESULT hr;
-
-    TRACE( "iface %p, callback %p, context %p, type %#x.\n", iface, callback, context, type );
-
-    if (!callback) return DIERR_INVALIDPARAM;
-
-    type = DIEFT_GETTYPE( type );
-
-    if (type == DIEFT_ALL || type == DIEFT_CONSTANTFORCE)
-    {
-        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_ConstantForce );
-        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
-        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
-    }
-
-    if (type == DIEFT_ALL || type == DIEFT_RAMPFORCE)
-    {
-        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_RampForce );
-        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
-        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
-    }
-
-    if (type == DIEFT_ALL || type == DIEFT_PERIODIC)
-    {
-        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Square );
-        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
-        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
-
-        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Sine );
-        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
-        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
-
-        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Triangle );
-        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
-        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
-
-        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_SawtoothUp );
-        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
-        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
-
-        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_SawtoothDown );
-        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
-        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
-    }
-
-    if (type == DIEFT_ALL || type == DIEFT_CONDITION)
-    {
-        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Spring );
-        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
-        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
-
-        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Damper );
-        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
-        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
-
-        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Inertia );
-        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
-        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
-
-        hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Friction );
-        if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr;
-        if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK;
-    }
-
-    return DI_OK;
-}
-
 static HRESULT WINAPI hid_joystick_GetEffectInfo( IDirectInputDevice8W *iface, DIEFFECTINFOW *info,
                                                   const GUID *guid )
 {
@@ -1155,7 +1084,7 @@ static const IDirectInputDevice8WVtbl hid_joystick_vtbl =
     IDirectInputDevice2WImpl_Initialize,
     /*** IDirectInputDevice2 methods ***/
     hid_joystick_CreateEffect,
-    hid_joystick_EnumEffects,
+    IDirectInputDevice2WImpl_EnumEffects,
     hid_joystick_GetEffectInfo,
     hid_joystick_GetForceFeedbackState,
     hid_joystick_SendForceFeedbackCommand,




More information about the wine-cvs mailing list