dinput: Add support for DIPROP_(PHYSICAL|LOGICAL)RANGE properties.

Fixes apps like WheelCheck, which rely on some of these properties
(DIPROP_PHYSICALRANGE) to correctly calculate the top center of the
wheel against their permitted range.

In particular the constant force test now works just like in Windows,
directing the wheel to the upper center and resisting any movement to
the left or right. Before that it would pull the steering wheel hard to
the left.

Signed-off-by: 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:
Ivo Ivanov 2021-11-18 09:53:19 +01:00 committed by Alexandre Julliard
parent e8d961b5c7
commit b793fb5457
4 changed files with 31 additions and 8 deletions

View File

@ -936,6 +936,8 @@ static HRESULT check_property( struct dinput_device *impl, const GUID *guid, con
if (header->dwSize != sizeof(DIPROPPOINTER)) return DIERR_INVALIDPARAM;
break;
case (DWORD_PTR)DIPROP_PHYSICALRANGE:
case (DWORD_PTR)DIPROP_LOGICALRANGE:
case (DWORD_PTR)DIPROP_RANGE:
if (header->dwSize != sizeof(DIPROPRANGE)) return DIERR_INVALIDPARAM;
break;
@ -963,6 +965,8 @@ static HRESULT check_property( struct dinput_device *impl, const GUID *guid, con
if (header->dwObj) return DIERR_INVALIDPARAM;
break;
case (DWORD_PTR)DIPROP_PHYSICALRANGE:
case (DWORD_PTR)DIPROP_LOGICALRANGE:
case (DWORD_PTR)DIPROP_RANGE:
case (DWORD_PTR)DIPROP_DEADZONE:
case (DWORD_PTR)DIPROP_SATURATION:
@ -988,6 +992,8 @@ static HRESULT check_property( struct dinput_device *impl, const GUID *guid, con
case (DWORD_PTR)DIPROP_AUTOCENTER:
case (DWORD_PTR)DIPROP_AXISMODE:
case (DWORD_PTR)DIPROP_BUFFERSIZE:
case (DWORD_PTR)DIPROP_PHYSICALRANGE:
case (DWORD_PTR)DIPROP_LOGICALRANGE:
if (impl->acquired) return DIERR_ACQUIRED;
break;
case (DWORD_PTR)DIPROP_FFLOAD:
@ -1023,6 +1029,9 @@ static HRESULT check_property( struct dinput_device *impl, const GUID *guid, con
if (value->dwData > 1) return DIERR_INVALIDPARAM;
break;
}
case (DWORD_PTR)DIPROP_PHYSICALRANGE:
case (DWORD_PTR)DIPROP_LOGICALRANGE:
return DIERR_UNSUPPORTED;
}
}
else
@ -1039,6 +1048,8 @@ static HRESULT check_property( struct dinput_device *impl, const GUID *guid, con
if (impl->caps.dwAxes && !(impl->caps.dwDevType & DIDEVTYPE_HID)) return DIERR_UNSUPPORTED;
break;
case (DWORD_PTR)DIPROP_PHYSICALRANGE:
case (DWORD_PTR)DIPROP_LOGICALRANGE:
case (DWORD_PTR)DIPROP_DEADZONE:
case (DWORD_PTR)DIPROP_SATURATION:
case (DWORD_PTR)DIPROP_CALIBRATIONMODE:
@ -1087,6 +1098,20 @@ static BOOL CALLBACK get_object_property( const DIDEVICEOBJECTINSTANCEW *instanc
switch (params->property)
{
case (DWORD_PTR)DIPROP_PHYSICALRANGE:
{
DIPROPRANGE *value = (DIPROPRANGE *)params->header;
value->lMin = properties->physical_min;
value->lMax = properties->physical_max;
return DI_OK;
}
case (DWORD_PTR)DIPROP_LOGICALRANGE:
{
DIPROPRANGE *value = (DIPROPRANGE *)params->header;
value->lMin = properties->logical_min;
value->lMax = properties->logical_max;
return DI_OK;
}
case (DWORD_PTR)DIPROP_RANGE:
{
DIPROPRANGE *value = (DIPROPRANGE *)params->header;
@ -1151,6 +1176,8 @@ static HRESULT dinput_device_get_property( IDirectInputDevice8W *iface, const GU
return impl->vtbl->get_property( iface, LOWORD( guid ), header, NULL );
case (DWORD_PTR)DIPROP_RANGE:
case (DWORD_PTR)DIPROP_PHYSICALRANGE:
case (DWORD_PTR)DIPROP_LOGICALRANGE:
case (DWORD_PTR)DIPROP_DEADZONE:
case (DWORD_PTR)DIPROP_SATURATION:
case (DWORD_PTR)DIPROP_GRANULARITY:

View File

@ -58,6 +58,8 @@ struct dinput_device_vtbl
struct object_properties
{
LONG bit_size;
LONG physical_min;
LONG physical_max;
LONG logical_min;
LONG logical_max;
LONG range_min;

View File

@ -1486,6 +1486,8 @@ static BOOL init_object_properties( struct hid_joystick *impl, struct hid_value_
LONG tmp;
properties->bit_size = caps->bit_size;
properties->physical_min = caps->physical_min;
properties->physical_max = caps->physical_max;
properties->logical_min = caps->logical_min;
properties->logical_max = caps->logical_max;

View File

@ -4253,18 +4253,12 @@ static void test_simple_joystick(void)
ok( prop_range.lMin == 0, "got %d expected %d\n", prop_range.lMin, 0 );
ok( prop_range.lMax == 65535, "got %d expected %d\n", prop_range.lMax, 65535 );
hr = IDirectInputDevice8_GetProperty( device, DIPROP_LOGICALRANGE, &prop_range.diph );
todo_wine
ok( hr == DI_OK, "GetProperty DIPROP_LOGICALRANGE returned %#x\n", hr );
todo_wine
ok( prop_range.lMin == -25, "got %d expected %d\n", prop_range.lMin, -25 );
todo_wine
ok( prop_range.lMax == 56, "got %d expected %d\n", prop_range.lMax, 56 );
hr = IDirectInputDevice8_GetProperty( device, DIPROP_PHYSICALRANGE, &prop_range.diph );
todo_wine
ok( hr == DI_OK, "GetProperty DIPROP_PHYSICALRANGE returned %#x\n", hr );
todo_wine
ok( prop_range.lMin == -25, "got %d expected %d\n", prop_range.lMin, -25 );
todo_wine
ok( prop_range.lMax == 56, "got %d expected %d\n", prop_range.lMax, 56 );
prop_pointer.diph.dwHow = DIPH_BYUSAGE;
@ -4810,10 +4804,8 @@ static void test_simple_joystick(void)
hr = IDirectInputDevice8_SetProperty( device, DIPROP_RANGE, &prop_range.diph );
ok( hr == DI_OK, "SetProperty DIPROP_RANGE returned %#x\n", hr );
hr = IDirectInputDevice8_SetProperty( device, DIPROP_LOGICALRANGE, &prop_range.diph );
todo_wine
ok( hr == DIERR_ACQUIRED, "SetProperty DIPROP_LOGICALRANGE returned %#x\n", hr );
hr = IDirectInputDevice8_SetProperty( device, DIPROP_PHYSICALRANGE, &prop_range.diph );
todo_wine
ok( hr == DIERR_ACQUIRED, "SetProperty DIPROP_PHYSICALRANGE returned %#x\n", hr );
hr = IDirectInputDevice8_Unacquire( device );