[PATCH v2 04/10] dinput: Stub support for the DIPROP_FFGAIN property.
Rémi Bernon
rbernon at codeweavers.com
Wed Nov 17 04:51:49 CST 2021
Based on a patch from Ivo Ivanov <logos128 at gmail.com>.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/dinput/device.c | 15 ++++++++++++++-
dlls/dinput/device_private.h | 2 ++
dlls/dinput/joystick_hid.c | 8 ++++++++
dlls/dinput/keyboard.c | 1 +
dlls/dinput/mouse.c | 1 +
dlls/dinput8/tests/hid.c | 6 ------
6 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
index 8d65d051a3b..449adaffde2 100644
--- a/dlls/dinput/device.c
+++ b/dlls/dinput/device.c
@@ -1008,7 +1008,7 @@ static HRESULT WINAPI dinput_device_GetProperty( IDirectInputDevice8W *iface, co
{
DIPROPDWORD *value = (DIPROPDWORD *)header;
if (header->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM;
- value->dwData = 10000;
+ value->dwData = impl->device_gain;
return DI_OK;
}
case (DWORD_PTR)DIPROP_CALIBRATION:
@@ -1094,6 +1094,18 @@ static HRESULT WINAPI dinput_device_SetProperty( IDirectInputDevice8W *iface, co
LeaveCriticalSection( &impl->crit );
return hr;
}
+ case (DWORD_PTR)DIPROP_FFGAIN:
+ {
+ const DIPROPDWORD *value = (const DIPROPDWORD *)header;
+ if (header->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM;
+ if (!impl->vtbl->send_device_gain) return DIERR_UNSUPPORTED;
+ if (header->dwHow != DIPH_DEVICE) return DIERR_UNSUPPORTED;
+ if (value->dwData > 10000) return DIERR_INVALIDPARAM;
+ EnterCriticalSection( &impl->crit );
+ impl->device_gain = value->dwData;
+ LeaveCriticalSection( &impl->crit );
+ return hr;
+ }
case (DWORD_PTR)DIPROP_FFLOAD:
case (DWORD_PTR)DIPROP_GRANULARITY:
case (DWORD_PTR)DIPROP_VIDPID:
@@ -1853,6 +1865,7 @@ HRESULT dinput_device_alloc( SIZE_T size, const struct dinput_device_vtbl *vtbl,
This->caps.dwSize = sizeof(DIDEVCAPS);
This->caps.dwFlags = DIDC_ATTACHED | DIDC_EMULATED;
This->device_format = format;
+ This->device_gain = 10000;
InitializeCriticalSection( &This->crit );
This->dinput = dinput;
IDirectInput_AddRef( &dinput->IDirectInput7A_iface );
diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h
index 02befc6e869..a2110942583 100644
--- a/dlls/dinput/device_private.h
+++ b/dlls/dinput/device_private.h
@@ -50,6 +50,7 @@ struct dinput_device_vtbl
HRESULT (*get_effect_info)( IDirectInputDevice8W *iface, DIEFFECTINFOW *info, const GUID *guid );
HRESULT (*create_effect)( IDirectInputDevice8W *iface, IDirectInputEffect **out );
HRESULT (*send_force_feedback_command)( IDirectInputDevice8W *iface, DWORD command );
+ HRESULT (*send_device_gain)( IDirectInputDevice8W *iface, LONG device_gain );
HRESULT (*enum_created_effect_objects)( IDirectInputDevice8W *iface, LPDIENUMCREATEDEFFECTOBJECTSCALLBACK callback,
void *context, DWORD flags );
};
@@ -98,6 +99,7 @@ struct dinput_device
BYTE device_state[DEVICE_STATE_MAX_SIZE];
BOOL autocenter;
+ LONG device_gain;
};
extern HRESULT dinput_device_alloc( SIZE_T size, const struct dinput_device_vtbl *vtbl, const GUID *guid,
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c
index 57e08025650..b1d19c2b57c 100644
--- a/dlls/dinput/joystick_hid.c
+++ b/dlls/dinput/joystick_hid.c
@@ -786,6 +786,13 @@ static void set_extra_caps_range( struct hid_joystick *impl, const DIDEVICEOBJEC
}
}
+static HRESULT hid_joystick_send_device_gain( IDirectInputDevice8W *iface, LONG device_gain )
+{
+ FIXME( "iface %p stub!\n", iface );
+
+ return DIERR_UNSUPPORTED;
+}
+
static HRESULT hid_joystick_set_property( IDirectInputDevice8W *iface, DWORD property,
const DIPROPHEADER *header, const DIDEVICEOBJECTINSTANCEW *instance )
{
@@ -1268,6 +1275,7 @@ static const struct dinput_device_vtbl hid_joystick_vtbl =
hid_joystick_get_effect_info,
hid_joystick_create_effect,
hid_joystick_send_force_feedback_command,
+ hid_joystick_send_device_gain,
hid_joystick_enum_created_effect_objects,
};
diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c
index f906e32a59d..916a1d43233 100644
--- a/dlls/dinput/keyboard.c
+++ b/dlls/dinput/keyboard.c
@@ -294,4 +294,5 @@ static const struct dinput_device_vtbl keyboard_vtbl =
NULL,
NULL,
NULL,
+ NULL,
};
diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c
index 1b45c8d5fd4..313ac070c86 100644
--- a/dlls/dinput/mouse.c
+++ b/dlls/dinput/mouse.c
@@ -596,4 +596,5 @@ static const struct dinput_device_vtbl mouse_vtbl =
NULL,
NULL,
NULL,
+ NULL,
};
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c
index 26b60fc21c6..ba5a26b3945 100644
--- a/dlls/dinput8/tests/hid.c
+++ b/dlls/dinput8/tests/hid.c
@@ -5015,11 +5015,9 @@ static void test_simple_joystick(void)
prop_dword.diph.dwObj = 0;
prop_dword.dwData = 0xdeadbeef;
hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph );
- todo_wine
ok( hr == DIERR_INVALIDPARAM, "SetProperty DIPROP_FFGAIN returned %#x\n", hr );
prop_dword.dwData = 1000;
hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph );
- todo_wine
ok( hr == DI_OK, "SetProperty DIPROP_FFGAIN returned %#x\n", hr );
prop_dword.dwData = 0xdeadbeef;
@@ -7847,11 +7845,9 @@ static void test_force_feedback_joystick( DWORD version )
prop_dword.dwData = 0xdeadbeef;
hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph );
- todo_wine
ok( hr == DIERR_INVALIDPARAM, "SetProperty DIPROP_FFGAIN returned %#x\n", hr );
prop_dword.dwData = 1000;
hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph );
- todo_wine
ok( hr == DI_OK, "SetProperty DIPROP_FFGAIN returned %#x\n", hr );
prop_dword.dwData = 0xdeadbeef;
@@ -7889,14 +7885,12 @@ static void test_force_feedback_joystick( DWORD version )
set_hid_expect( file, &expect_set_device_gain_2, sizeof(expect_set_device_gain_2) );
prop_dword.dwData = 2000;
hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph );
- todo_wine
ok( hr == DI_OK, "SetProperty DIPROP_FFGAIN returned %#x\n", hr );
wait_hid_expect( file, 100 ); /* device gain reports are written asynchronously */
set_hid_expect( file, &expect_set_device_gain_1, sizeof(expect_set_device_gain_1) );
prop_dword.dwData = 1000;
hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph );
- todo_wine
ok( hr == DI_OK, "SetProperty DIPROP_FFGAIN returned %#x\n", hr );
wait_hid_expect( file, 100 ); /* device gain reports are written asynchronously */
--
2.33.1
More information about the wine-devel
mailing list