[dinput] Initialize all axis (from 0 to ABS_MAX) with -1

Lucas Zawacki lfzawacki at gmail.com
Wed Mar 20 17:35:08 CDT 2013


From: Lucas Zawacki <lfzawacki at gmail.com>

The array 'dev_axes_to_di' has ABS_MAX (63 according to linux/input.h) positions, but in the
initialization it's values are only set until WINE_JOYSTICK_MAX_AXES (8) is reached.

Even thought wine doesnt support more than this number of axis, some joysticks will
send events to them (for example the PS3 one which has lots of axis) and they'll be wrongly
interpreted as the value found in this uninitialized position.

Will help with bugs #31546 and #33150
---
 dlls/dinput/joystick_linuxinput.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c
index 0a044a5..5ed9bde 100644
--- a/dlls/dinput/joystick_linuxinput.c
+++ b/dlls/dinput/joystick_linuxinput.c
@@ -445,9 +445,10 @@ static JoystickImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput, unsig
     newDevice->generic.base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->base.crit");
 
     /* Count number of available axes - supported Axis & POVs */
-    for (i = 0; i < WINE_JOYSTICK_MAX_AXES; i++)
+    for (i = 0; i < ABS_MAX; i++)
     {
-        if (test_bit(newDevice->joydev->absbits, i))
+        if (i < WINE_JOYSTICK_MAX_AXES &&
+            test_bit(newDevice->joydev->absbits, i))
         {
             newDevice->generic.device_axis_count++;
             newDevice->dev_axes_to_di[i] = idx;
-- 
1.7.9.5




More information about the wine-patches mailing list