Rémi Bernon : dinput: Implement HID joystick IDirectInputEffect_Initialize.
Alexandre Julliard
julliard at winehq.org
Thu Oct 7 16:21:19 CDT 2021
Module: wine
Branch: master
Commit: cbd9fe2586d7449c0aba5271683b1290ed78f16f
URL: https://source.winehq.org/git/wine.git/?a=commit;h=cbd9fe2586d7449c0aba5271683b1290ed78f16f
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Thu Oct 7 10:40:00 2021 +0200
dinput: Implement HID joystick IDirectInputEffect_Initialize.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dinput/joystick_hid.c | 25 ++++++++++++++++++++++++-
dlls/dinput8/tests/hid.c | 7 -------
2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c
index c3d202bd9bd..1ecb24260bf 100644
--- a/dlls/dinput/joystick_hid.c
+++ b/dlls/dinput/joystick_hid.c
@@ -144,6 +144,7 @@ struct hid_joystick_effect
{
IDirectInputEffect IDirectInputEffect_iface;
LONG ref;
+ USAGE type;
struct list entry;
struct hid_joystick *joystick;
@@ -2061,7 +2062,29 @@ static ULONG WINAPI hid_joystick_effect_Release( IDirectInputEffect *iface )
static HRESULT WINAPI hid_joystick_effect_Initialize( IDirectInputEffect *iface, HINSTANCE inst,
DWORD version, REFGUID guid )
{
- FIXME( "iface %p, inst %p, version %u, guid %s stub!\n", iface, inst, version, debugstr_guid( guid ) );
+ struct hid_joystick_effect *impl = impl_from_IDirectInputEffect( iface );
+ struct hid_joystick *joystick = impl->joystick;
+ ULONG report_len = joystick->caps.OutputReportByteLength;
+ NTSTATUS status;
+ ULONG count;
+ USAGE type;
+
+ TRACE( "iface %p, inst %p, version %u, guid %s\n", iface, inst, version, debugstr_guid( guid ) );
+
+ if (!inst) return DIERR_INVALIDPARAM;
+ if (!guid) return E_POINTER;
+ if (!(type = effect_guid_to_usage( guid ))) return DIERR_DEVICENOTREG;
+
+ status = HidP_InitializeReportForID( HidP_Output, joystick->pid_effect_update.id,
+ joystick->preparsed, impl->effect_update_buf, report_len );
+ if (status != HIDP_STATUS_SUCCESS) return DIERR_DEVICENOTREG;
+
+ count = 1;
+ status = HidP_SetUsages( HidP_Output, HID_USAGE_PAGE_PID, joystick->pid_effect_update.type_coll,
+ &type, &count, joystick->preparsed, impl->effect_update_buf, report_len );
+ if (status != HIDP_STATUS_SUCCESS) return DIERR_DEVICENOTREG;
+
+ impl->type = type;
return DI_OK;
}
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c
index e55adb0aa56..35a7d4b3bb7 100644
--- a/dlls/dinput8/tests/hid.c
+++ b/dlls/dinput8/tests/hid.c
@@ -5159,13 +5159,9 @@ static void test_periodic_effect( IDirectInputDevice8W *device, HANDLE file )
hr = IDirectInputDevice8_CreateEffect( device, &GUID_Sine, NULL, NULL, NULL );
ok( hr == E_POINTER, "CreateEffect returned %#x\n", hr );
hr = IDirectInputDevice8_CreateEffect( device, NULL, NULL, &effect, NULL );
- todo_wine
ok( hr == E_POINTER, "CreateEffect returned %#x\n", hr );
- if (hr == DI_OK) IDirectInputEffect_Release( effect );
hr = IDirectInputDevice8_CreateEffect( device, &GUID_NULL, NULL, &effect, NULL );
- todo_wine
ok( hr == DIERR_DEVICENOTREG, "CreateEffect returned %#x\n", hr );
- if (hr == DI_OK) IDirectInputEffect_Release( effect );
hr = IDirectInputDevice8_CreateEffect( device, &GUID_Sine, NULL, &effect, NULL );
ok( hr == DI_OK, "CreateEffect returned %#x\n", hr );
@@ -5179,17 +5175,14 @@ static void test_periodic_effect( IDirectInputDevice8W *device, HANDLE file )
ok( check_params.count == 1, "got count %u, expected 1\n", check_params.count );
hr = IDirectInputEffect_Initialize( effect, NULL, DIRECTINPUT_VERSION, &GUID_Sine );
- todo_wine
ok( hr == DIERR_INVALIDPARAM, "Initialize returned %#x\n", hr );
hr = IDirectInputEffect_Initialize( effect, instance, 0, &GUID_Sine );
todo_wine
ok( hr == DIERR_NOTINITIALIZED, "Initialize returned %#x\n", hr );
hr = IDirectInputEffect_Initialize( effect, instance, DIRECTINPUT_VERSION, NULL );
- todo_wine
ok( hr == E_POINTER, "Initialize returned %#x\n", hr );
hr = IDirectInputEffect_Initialize( effect, instance, DIRECTINPUT_VERSION, &GUID_NULL );
- todo_wine
ok( hr == DIERR_DEVICENOTREG, "Initialize returned %#x\n", hr );
hr = IDirectInputEffect_Initialize( effect, instance, DIRECTINPUT_VERSION, &GUID_Sine );
ok( hr == DI_OK, "Initialize returned %#x\n", hr );
More information about the wine-cvs
mailing list