From: Tyson Whitehead twhitehead@gmail.com
Autocenter is turned off by default unless the device is a joystick. Joysticks were detected by looking for the word "joystick" in their name. This was less than ideal. This commit switches to checking if the`DIDEVICE_TYPE` is `DI8DEVTYPE_JOYSTICK` instead.
`DIDEVICE_TYPE` classification should be quite good for the for SDL and udev hidraw backends. For the udev input backends, there is no distinguishing of devices beyond `ID_INPUT_JOYSTICK`, which becomes `DI8DEVTYPE_GAMEPAD`, so autocenter is going to be always off.
Should udev implement a more granular classification than `ID_INPUT_JOYSTICK` this situation would improve. For now it can still be override by the user app key "Autocenter". --- dlls/dinput/device.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 543495d7a09..b415eb7bbb5 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -154,15 +154,20 @@ static BOOL device_instance_autocenter_initial( DIDEVICEINSTANCEW *instance ) HKEY hkey, appkey, temp; BOOL autocenter = DIPROPAUTOCENTER_OFF;
- /* Default devices with joysticks in their name to on */ - wcscpy_s( buffer, sizeof(buffer)/sizeof(buffer[0]), instance->tszProductName ); - _wcslwr_s( buffer, sizeof(buffer)/sizeof(buffer[0]) ); - if ( wcsstr(buffer, L"joystick") != NULL ) + /* Autocenter default based on type (joystick is on, anything fancier is off) */ + switch ( GET_DIDEVICE_TYPE(instance->dwDevType) ) { + case DI8DEVTYPE_JOYSTICK: autocenter = DIPROPAUTOCENTER_ON; + break; + default: + autocenter = DIPROPAUTOCENTER_OFF; + break; } - TRACE( "Joystick '%s' autocenter default is %s.\n", debugstr_w(instance->tszInstanceName), - autocenter == DIPROPAUTOCENTER_ON ? "on" : "off" ); + TRACE( "Joystick '%s' autocenter default is %s due to device type 0x%02x.\n", + debugstr_w(instance->tszInstanceName), + autocenter == DIPROPAUTOCENTER_ON ? "on" : "off" , + GET_DIDEVICE_TYPE(instance->dwDevType) );
/* Autocenter settings are in the 'Autocenter' subkey */ get_app_key( &hkey, &appkey );