dinput: Reset the HID joystick state values on DIPROP_RANGE changes.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
844db6e53e
commit
3886634c82
|
@ -20,6 +20,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
#include "winbase.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;
|
HIDP_VALUE_CAPS *value_caps = caps->value;
|
||||||
DIPROPRANGE *value = data;
|
DIPROPRANGE *value = data;
|
||||||
LONG range = value_caps->LogicalMax - value_caps->LogicalMin;
|
LONG tmp;
|
||||||
|
|
||||||
value_caps->PhysicalMin = value->lMin;
|
value_caps->PhysicalMin = value->lMin;
|
||||||
value_caps->PhysicalMax = value->lMax;
|
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;
|
return DIENUM_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4098,14 +4098,13 @@ static void test_simple_joystick(void)
|
||||||
winetest_push_context( "state[%d]", i );
|
winetest_push_context( "state[%d]", i );
|
||||||
hr = IDirectInputDevice8_GetDeviceState( device, sizeof(DIJOYSTATE2), &state );
|
hr = IDirectInputDevice8_GetDeviceState( device, sizeof(DIJOYSTATE2), &state );
|
||||||
ok( hr == DI_OK, "IDirectInputDevice8_GetDeviceState returned: %#x\n", hr );
|
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 );
|
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 );
|
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", lZ );
|
||||||
check_member( state, expect_state[i], "%d", lRx );
|
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[0] );
|
||||||
check_member( state, expect_state[i], "%#x", rgdwPOV[1] );
|
check_member( state, expect_state[i], "%#x", rgdwPOV[1] );
|
||||||
check_member( state, expect_state[i], "%#x", rgbButtons[0] );
|
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 );
|
hr = IDirectInputDevice8_GetDeviceState( device, sizeof(DIJOYSTATE2), &state );
|
||||||
ok( hr == DI_OK, "IDirectInputDevice8_GetDeviceState returned: %#x\n", hr );
|
ok( hr == DI_OK, "IDirectInputDevice8_GetDeviceState returned: %#x\n", hr );
|
||||||
todo_wine
|
|
||||||
check_member( state, expect_state_abs[1], "%d", lX );
|
check_member( state, expect_state_abs[1], "%d", lX );
|
||||||
todo_wine
|
|
||||||
check_member( state, expect_state_abs[1], "%d", lY );
|
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", lZ );
|
||||||
check_member( state, expect_state_abs[1], "%d", lRx );
|
check_member( state, expect_state_abs[1], "%d", lRx );
|
||||||
check_member( state, expect_state_abs[1], "%d", rgdwPOV[0] );
|
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" );
|
if (broken( state.lX == -10750 )) win_skip( "Ignoring 32-bit rounding\n" );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
todo_wine_if( i != 2 )
|
todo_wine_if( i != 0 && i != 2 )
|
||||||
check_member( state, expect_state_abs[i], "%d", lX );
|
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 );
|
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", lZ );
|
||||||
check_member( state, expect_state_abs[i], "%d", lRx );
|
check_member( state, expect_state_abs[i], "%d", lRx );
|
||||||
check_member( state, expect_state_abs[i], "%d", rgdwPOV[0] );
|
check_member( state, expect_state_abs[i], "%d", rgdwPOV[0] );
|
||||||
|
|
Loading…
Reference in New Issue