Rémi Bernon : dinput: Implement HID joystick IDirectInputDevice8_EnumObjects.

Alexandre Julliard julliard at winehq.org
Fri Aug 27 15:03:34 CDT 2021


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

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Fri Aug 27 12:45:28 2021 +0200

dinput: Implement HID joystick IDirectInputDevice8_EnumObjects.

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

---

 dlls/dinput/joystick_hid.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c
index 4a05afe30c7..3e706dea0b1 100644
--- a/dlls/dinput/joystick_hid.c
+++ b/dlls/dinput/joystick_hid.c
@@ -427,6 +427,49 @@ static HRESULT WINAPI hid_joystick_GetCapabilities( IDirectInputDevice8W *iface,
     return DI_OK;
 }
 
+struct enum_objects_params
+{
+    LPDIENUMDEVICEOBJECTSCALLBACKW callback;
+    void *context;
+};
+
+static BOOL enum_objects_callback( struct hid_joystick *impl, struct hid_caps *caps,
+                                   DIDEVICEOBJECTINSTANCEW *instance, void *data )
+{
+    struct enum_objects_params *params = data;
+    return params->callback( instance, params->context );
+}
+
+static HRESULT WINAPI hid_joystick_EnumObjects( IDirectInputDevice8W *iface, LPDIENUMDEVICEOBJECTSCALLBACKW callback,
+                                                void *context, DWORD flags )
+{
+    static const DIPROPHEADER filter =
+    {
+        .dwSize = sizeof(filter),
+        .dwHeaderSize = sizeof(filter),
+        .dwHow = DIPH_DEVICE,
+    };
+    struct hid_joystick *impl = impl_from_IDirectInputDevice8W( iface );
+    struct enum_objects_params params =
+    {
+        .callback = callback,
+        .context = context,
+    };
+    BOOL ret;
+
+    TRACE( "iface %p, callback %p, context %p, flags %#x.\n", iface, callback, context, flags );
+
+    if (!callback) return DIERR_INVALIDPARAM;
+
+    ret = enum_value_objects( impl, &filter, flags, enum_objects_callback, &params );
+    if (ret != DIENUM_CONTINUE) return S_OK;
+    ret = enum_button_objects( impl, &filter, flags, enum_objects_callback, &params );
+    if (ret != DIENUM_CONTINUE) return S_OK;
+    enum_collections_objects( impl, &filter, flags, enum_objects_callback, &params );
+
+    return S_OK;
+}
+
 static BOOL get_property_prop_range( struct hid_joystick *impl, struct hid_caps *caps,
                                      DIDEVICEOBJECTINSTANCEW *instance, void *data )
 {
@@ -619,7 +662,7 @@ static const IDirectInputDevice8WVtbl hid_joystick_vtbl =
     hid_joystick_Release,
     /*** IDirectInputDevice methods ***/
     hid_joystick_GetCapabilities,
-    IDirectInputDevice2WImpl_EnumObjects,
+    hid_joystick_EnumObjects,
     hid_joystick_GetProperty,
     hid_joystick_SetProperty,
     IDirectInputDevice2WImpl_Acquire,




More information about the wine-cvs mailing list