[PATCH 0/1] MR11057: winexinput.sys: Fix handling of non-32-bit axis
The previous axis direction inversion (`-ly - 1`) assumes `ly` is a signed, 32-bit, 2's complement value. It broke with the change 88e775db, which changed the size to 16-bit from 32-bit. Fix it by using simple arithmetic rather than relying on the 2's complement logic. This is a fix for the following regressions (@tinozzo123 [commented](https://gitlab.winehq.org/wine/wine/-/merge_requests/9886#note_129716)): * https://bugs.winehq.org/show_bug.cgi?id=59317 * https://bugs.winehq.org/show_bug.cgi?id=59386 * https://bugs.winehq.org/show_bug.cgi?id=59406 The regression only affected XInput devices converted to DInput. DInput-only devices were not affected. I have reproduced the regression in `wine control joy.cpl`, and confirmed the fix with my GuliKit KingKong 2 Pro controller. It can switch between XInput mode and DInput mode when connected with USB. The regression was reproduced only in XInput mode. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11057
From: SeongChan Lee <foriequal@gmail.com> The previous axis direction inversion (`-ly - 1`) assumes `ly` is a signed, 32-bit, 2's complement value. It broke with the change 88e775db, which changed the size to 16-bit from 32-bit. Fix it by using simple arithmetic rather than relying on the 2's complement logic. --- dlls/winexinput.sys/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/winexinput.sys/main.c b/dlls/winexinput.sys/main.c index f8d1fab1332..e79bb314c5b 100644 --- a/dlls/winexinput.sys/main.c +++ b/dlls/winexinput.sys/main.c @@ -235,9 +235,9 @@ static void translate_report_to_xinput_state(struct func_device *fdo) fdo->xinput_state.buttons |= (1 << (usages[i] - 1)); } fdo->xinput_state.lx_axis = scale_value(lx, &fdo->lx_caps, 0, 65535); - fdo->xinput_state.ly_axis = scale_value(-ly - 1, &fdo->ly_caps, 0, 65535); + fdo->xinput_state.ly_axis = 65535 - scale_value(ly, &fdo->ly_caps, 0, 65535); fdo->xinput_state.rx_axis = scale_value(rx, &fdo->rx_caps, 0, 65535); - fdo->xinput_state.ry_axis = scale_value(-ry - 1, &fdo->ry_caps, 0, 65535); + fdo->xinput_state.ry_axis = 65535 - scale_value(ry, &fdo->ry_caps, 0, 65535); rt = scale_value(rt, &fdo->rt_caps, 0, 255); lt = scale_value(lt, &fdo->lt_caps, 0, 255); fdo->xinput_state.trigger = 0x8000 + (lt - rt) * 128; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11057
This merge request was approved by Rémi Bernon. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11057
Can confirm that it fixes https://bugs.winehq.org/show_bug.cgi?id=59406. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11057#note_142080
participants (4)
-
Martino Fontana (@tinozzo123) -
Rémi Bernon (@rbernon) -
SeongChan Lee -
SeongChan Lee (@foriequal0)