Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 19 ++++++++++++++++--- dlls/dinput8/tests/hid.c | 16 ++++++---------- 2 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 6d70e188dbe..e20d02224fe 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -20,6 +20,7 @@ #include <assert.h> #include <stdarg.h> #include <string.h> +#include <math.h>
#include "windef.h" #include "winbase.h" @@ -585,11 +586,23 @@ static BOOL set_property_prop_range( struct hid_joystick *impl, struct hid_caps { HIDP_VALUE_CAPS *value_caps = caps->value; DIPROPRANGE *value = data; - LONG range = value_caps->LogicalMax - value_caps->LogicalMin; + LONG tmp; + value_caps->PhysicalMin = value->lMin; value_caps->PhysicalMax = value->lMax; - if (instance->dwType & DIDFT_POV && range > 0) - value_caps->PhysicalMax -= value->lMax / (range + 1); + + if (instance->dwType & DIDFT_AXIS) + { + if (!value_caps->PhysicalMin) tmp = value_caps->PhysicalMax / 2; + else tmp = round( (value_caps->PhysicalMin + value_caps->PhysicalMax) / 2.0 ); + *(LONG *)(impl->device_state + instance->dwOfs) = tmp; + } + else if (instance->dwType & DIDFT_POV) + { + tmp = value_caps->LogicalMax - value_caps->LogicalMin; + if (tmp > 0) value_caps->PhysicalMax -= value->lMax / (tmp + 1); + *(LONG *)(impl->device_state + instance->dwOfs) = -1; + } return DIENUM_CONTINUE; }
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index 0270467dea8..ae758837d36 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -4098,14 +4098,13 @@ static void test_simple_joystick(void) winetest_push_context( "state[%d]", i ); hr = IDirectInputDevice8_GetDeviceState( device, sizeof(DIJOYSTATE2), &state ); ok( hr == DI_OK, "IDirectInputDevice8_GetDeviceState returned: %#x\n", hr ); - todo_wine_if( i != 2 ) + todo_wine_if( i != 0 && i != 2 ) check_member( state, expect_state[i], "%d", lX ); - todo_wine_if( i != 2 ) + todo_wine_if( i != 0 && i != 2 ) check_member( state, expect_state[i], "%d", lY ); - todo_wine + todo_wine_if( i != 0 ) check_member( state, expect_state[i], "%d", lZ ); check_member( state, expect_state[i], "%d", lRx ); - todo_wine_if( i == 0 ) check_member( state, expect_state[i], "%#x", rgdwPOV[0] ); check_member( state, expect_state[i], "%#x", rgdwPOV[1] ); check_member( state, expect_state[i], "%#x", rgbButtons[0] ); @@ -4306,11 +4305,8 @@ static void test_simple_joystick(void)
hr = IDirectInputDevice8_GetDeviceState( device, sizeof(DIJOYSTATE2), &state ); ok( hr == DI_OK, "IDirectInputDevice8_GetDeviceState returned: %#x\n", hr ); - todo_wine check_member( state, expect_state_abs[1], "%d", lX ); - todo_wine check_member( state, expect_state_abs[1], "%d", lY ); - todo_wine check_member( state, expect_state_abs[1], "%d", lZ ); check_member( state, expect_state_abs[1], "%d", lRx ); check_member( state, expect_state_abs[1], "%d", rgdwPOV[0] ); @@ -4452,12 +4448,12 @@ static void test_simple_joystick(void) if (broken( state.lX == -10750 )) win_skip( "Ignoring 32-bit rounding\n" ); else { - todo_wine_if( i != 2 ) + todo_wine_if( i != 0 && i != 2 ) check_member( state, expect_state_abs[i], "%d", lX ); - todo_wine_if( i != 2 ) + todo_wine_if( i != 0 && i != 2 ) check_member( state, expect_state_abs[i], "%d", lY ); } - todo_wine + todo_wine_if( i != 0 ) check_member( state, expect_state_abs[i], "%d", lZ ); check_member( state, expect_state_abs[i], "%d", lRx ); check_member( state, expect_state_abs[i], "%d", rgdwPOV[0] );