dinput: Stub support for the DIPROP_FFGAIN property.

Based on a patch from Ivo Ivanov <logos128@gmail.com>.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2021-11-17 11:51:49 +01:00 committed by Alexandre Julliard
parent 3f110402f6
commit e7217a3287
6 changed files with 26 additions and 7 deletions

View File

@ -1008,7 +1008,7 @@ static HRESULT WINAPI dinput_device_GetProperty( IDirectInputDevice8W *iface, co
{ {
DIPROPDWORD *value = (DIPROPDWORD *)header; DIPROPDWORD *value = (DIPROPDWORD *)header;
if (header->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM; if (header->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM;
value->dwData = 10000; value->dwData = impl->device_gain;
return DI_OK; return DI_OK;
} }
case (DWORD_PTR)DIPROP_CALIBRATION: case (DWORD_PTR)DIPROP_CALIBRATION:
@ -1094,6 +1094,18 @@ static HRESULT WINAPI dinput_device_SetProperty( IDirectInputDevice8W *iface, co
LeaveCriticalSection( &impl->crit ); LeaveCriticalSection( &impl->crit );
return hr; 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_FFLOAD:
case (DWORD_PTR)DIPROP_GRANULARITY: case (DWORD_PTR)DIPROP_GRANULARITY:
case (DWORD_PTR)DIPROP_VIDPID: 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.dwSize = sizeof(DIDEVCAPS);
This->caps.dwFlags = DIDC_ATTACHED | DIDC_EMULATED; This->caps.dwFlags = DIDC_ATTACHED | DIDC_EMULATED;
This->device_format = format; This->device_format = format;
This->device_gain = 10000;
InitializeCriticalSection( &This->crit ); InitializeCriticalSection( &This->crit );
This->dinput = dinput; This->dinput = dinput;
IDirectInput_AddRef( &dinput->IDirectInput7A_iface ); IDirectInput_AddRef( &dinput->IDirectInput7A_iface );

View File

@ -50,6 +50,7 @@ struct dinput_device_vtbl
HRESULT (*get_effect_info)( IDirectInputDevice8W *iface, DIEFFECTINFOW *info, const GUID *guid ); HRESULT (*get_effect_info)( IDirectInputDevice8W *iface, DIEFFECTINFOW *info, const GUID *guid );
HRESULT (*create_effect)( IDirectInputDevice8W *iface, IDirectInputEffect **out ); HRESULT (*create_effect)( IDirectInputDevice8W *iface, IDirectInputEffect **out );
HRESULT (*send_force_feedback_command)( IDirectInputDevice8W *iface, DWORD command ); 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, HRESULT (*enum_created_effect_objects)( IDirectInputDevice8W *iface, LPDIENUMCREATEDEFFECTOBJECTSCALLBACK callback,
void *context, DWORD flags ); void *context, DWORD flags );
}; };
@ -98,6 +99,7 @@ struct dinput_device
BYTE device_state[DEVICE_STATE_MAX_SIZE]; BYTE device_state[DEVICE_STATE_MAX_SIZE];
BOOL autocenter; BOOL autocenter;
LONG device_gain;
}; };
extern HRESULT dinput_device_alloc( SIZE_T size, const struct dinput_device_vtbl *vtbl, const GUID *guid, extern HRESULT dinput_device_alloc( SIZE_T size, const struct dinput_device_vtbl *vtbl, const GUID *guid,

View File

@ -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, static HRESULT hid_joystick_set_property( IDirectInputDevice8W *iface, DWORD property,
const DIPROPHEADER *header, const DIDEVICEOBJECTINSTANCEW *instance ) 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_get_effect_info,
hid_joystick_create_effect, hid_joystick_create_effect,
hid_joystick_send_force_feedback_command, hid_joystick_send_force_feedback_command,
hid_joystick_send_device_gain,
hid_joystick_enum_created_effect_objects, hid_joystick_enum_created_effect_objects,
}; };

View File

@ -294,4 +294,5 @@ static const struct dinput_device_vtbl keyboard_vtbl =
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
}; };

View File

@ -596,4 +596,5 @@ static const struct dinput_device_vtbl mouse_vtbl =
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
}; };

View File

@ -5015,11 +5015,9 @@ static void test_simple_joystick(void)
prop_dword.diph.dwObj = 0; prop_dword.diph.dwObj = 0;
prop_dword.dwData = 0xdeadbeef; prop_dword.dwData = 0xdeadbeef;
hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph ); hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph );
todo_wine
ok( hr == DIERR_INVALIDPARAM, "SetProperty DIPROP_FFGAIN returned %#x\n", hr ); ok( hr == DIERR_INVALIDPARAM, "SetProperty DIPROP_FFGAIN returned %#x\n", hr );
prop_dword.dwData = 1000; prop_dword.dwData = 1000;
hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph ); hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph );
todo_wine
ok( hr == DI_OK, "SetProperty DIPROP_FFGAIN returned %#x\n", hr ); ok( hr == DI_OK, "SetProperty DIPROP_FFGAIN returned %#x\n", hr );
prop_dword.dwData = 0xdeadbeef; prop_dword.dwData = 0xdeadbeef;
@ -7847,11 +7845,9 @@ static void test_force_feedback_joystick( DWORD version )
prop_dword.dwData = 0xdeadbeef; prop_dword.dwData = 0xdeadbeef;
hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph ); hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph );
todo_wine
ok( hr == DIERR_INVALIDPARAM, "SetProperty DIPROP_FFGAIN returned %#x\n", hr ); ok( hr == DIERR_INVALIDPARAM, "SetProperty DIPROP_FFGAIN returned %#x\n", hr );
prop_dword.dwData = 1000; prop_dword.dwData = 1000;
hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph ); hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph );
todo_wine
ok( hr == DI_OK, "SetProperty DIPROP_FFGAIN returned %#x\n", hr ); ok( hr == DI_OK, "SetProperty DIPROP_FFGAIN returned %#x\n", hr );
prop_dword.dwData = 0xdeadbeef; 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) ); set_hid_expect( file, &expect_set_device_gain_2, sizeof(expect_set_device_gain_2) );
prop_dword.dwData = 2000; prop_dword.dwData = 2000;
hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph ); hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph );
todo_wine
ok( hr == DI_OK, "SetProperty DIPROP_FFGAIN returned %#x\n", hr ); ok( hr == DI_OK, "SetProperty DIPROP_FFGAIN returned %#x\n", hr );
wait_hid_expect( file, 100 ); /* device gain reports are written asynchronously */ 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) ); set_hid_expect( file, &expect_set_device_gain_1, sizeof(expect_set_device_gain_1) );
prop_dword.dwData = 1000; prop_dword.dwData = 1000;
hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph ); hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph );
todo_wine
ok( hr == DI_OK, "SetProperty DIPROP_FFGAIN returned %#x\n", hr ); ok( hr == DI_OK, "SetProperty DIPROP_FFGAIN returned %#x\n", hr );
wait_hid_expect( file, 100 ); /* device gain reports are written asynchronously */ wait_hid_expect( file, 100 ); /* device gain reports are written asynchronously */