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

Alexandre Julliard julliard at winehq.org
Thu Nov 18 16:19:38 CST 2021


Module: wine
Branch: master
Commit: b793fb54573166f33d0304ec4b542a4b272ac357
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b793fb54573166f33d0304ec4b542a4b272ac357

Author: Ivo Ivanov <logos128 at gmail.com>
Date:   Thu Nov 18 09:53:19 2021 +0100

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 at gmail.com>
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dinput/device.c         | 27 +++++++++++++++++++++++++++
 dlls/dinput/device_private.h |  2 ++
 dlls/dinput/joystick_hid.c   |  2 ++
 dlls/dinput8/tests/hid.c     |  8 --------
 4 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
index f70b7e549c0..6240d640e0d 100644
--- a/dlls/dinput/device.c
+++ b/dlls/dinput/device.c
@@ -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:
diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h
index c12cc92bc70..e2cae26aea2 100644
--- a/dlls/dinput/device_private.h
+++ b/dlls/dinput/device_private.h
@@ -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;
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c
index 2ad3462ca42..70c761267f7 100644
--- a/dlls/dinput/joystick_hid.c
+++ b/dlls/dinput/joystick_hid.c
@@ -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;
 
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c
index 3beabc4b03b..9e21ccdb713 100644
--- a/dlls/dinput8/tests/hid.c
+++ b/dlls/dinput8/tests/hid.c
@@ -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 );




More information about the wine-cvs mailing list