[PATCH 03/11] dinput: Implement HID joystick IDirectInputEffect_Initialize.
Rémi Bernon
rbernon at codeweavers.com
Thu Oct 7 03:40:00 CDT 2021
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
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 bcc13c21ff2..924438daf7c 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 );
--
2.33.0
More information about the wine-devel
mailing list