From: Tyson Whitehead twhitehead@gmail.com
While ideally programs should check and turn autocenter off, it is likely that many do not. The default autocenter under Wine has been on. Tomasz Pakuta reported in !8744 that this is the wrong default for wheels and it has been causing a problem for many in the sim racing community.
This commit makes `DIPROPAUTOCENTER_OFF` the default value for `DIPROP_AUTOCENTER` unless the device name contains "joystick". Although this will miss some joysticks (those without joystick in their name, like the "Logitech WingMan"), it should hopefully be an overall win to have joysticks be the exception and not the default as I read there are more wheels than joysticks.
Wrongly classified devices can still be overriden by the new user app key "Autocenter". As in
[Software\Wine\DirectInput\Autocenter] "Device instance name"="on"
or
[Software\Wine\AppDefaults\app.exe\DirectInput\Autocenter] "Device instance name"="on" --- dlls/dinput/device.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 6985a6b279a..543495d7a09 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -152,13 +152,21 @@ static BOOL device_instance_autocenter_initial( DIDEVICEINSTANCEW *instance ) static const WCHAR joystick_key[] = {'A', 'u', 't', 'o', 'c', 'e', 'n', 't', 'e', 'r', 0}; WCHAR buffer[MAX_PATH]; HKEY hkey, appkey, temp; - BOOL autocenter = DIPROPAUTOCENTER_ON; /* MS Sidewinder 2 initial value. No others known yet. There is - a project to collect other device defaults to improved this - https://github.com/twhitehead/issue-wine-ff-autocenter */ + BOOL autocenter = DIPROPAUTOCENTER_OFF;
- get_app_key( &hkey, &appkey ); + /* 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 = DIPROPAUTOCENTER_ON; + } + TRACE( "Joystick '%s' autocenter default is %s.\n", debugstr_w(instance->tszInstanceName), + autocenter == DIPROPAUTOCENTER_ON ? "on" : "off" );
/* Autocenter settings are in the 'Autocenter' subkey */ + get_app_key( &hkey, &appkey ); + if (appkey) { if (RegOpenKeyW( appkey, joystick_key, &temp )) temp = 0; @@ -178,12 +186,12 @@ static BOOL device_instance_autocenter_initial( DIDEVICEINSTANCEW *instance ) { if (!wcscmp( on_str, buffer )) { - TRACE( "Joystick '%s' autocenter on based on registry key.\n", debugstr_w(instance->tszInstanceName) ); + TRACE( "Joystick '%s' autocenter default overridden to on based on registry key.\n", debugstr_w(instance->tszInstanceName) ); autocenter = DIPROPAUTOCENTER_ON; } else if (!wcscmp( off_str, buffer )) { - TRACE( "Joystick '%s' autocenter off based on registry key.\n", debugstr_w(instance->tszInstanceName) ); + TRACE( "Joystick '%s' autocenter default overridden to off based on registry key.\n", debugstr_w(instance->tszInstanceName) ); autocenter = DIPROPAUTOCENTER_OFF; } else