From e87ccb8b055dc846211967e46ee2f17fbabef7a1 Mon Sep 17 00:00:00 2001 From: Bruno Jesus Date: Sun, 9 Apr 2017 22:25:35 -0300 Subject: [PATCH] dinput: Assume a 1-to-1 axes map when no axes match. The wiimote is a well known problematic device, mainly because it is not a joystick. It is a USB device. But the classic controller is at least advertised as a joystick with 6 axes and 11 buttons (js driver only, NO event). Signed-off-by: Bruno Jesus Signed-off-by: Alexandre Julliard --- dlls/dinput/joystick_linux.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 1f8f94d7382..1032659621e 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -228,19 +228,36 @@ static INT find_joystick_devices(void) else if ((joydev.dev_axes_map = HeapAlloc(GetProcessHeap(), 0, joydev.axis_count * sizeof(int)))) { - INT j; + INT j, found_axes = 0; /* Remap to DI numbers */ for (j = 0; j < joydev.axis_count; j++) + { if (axes_map[j] < 8) + { /* Axis match 1-to-1 */ joydev.dev_axes_map[j] = j; + found_axes++; + } else if (axes_map[j] == 16 || axes_map[j] == 17) + { /* POV axis */ joydev.dev_axes_map[j] = 8; + found_axes++; + } else joydev.dev_axes_map[j] = -1; + } + + /* If no axes were configured but there are axes assume a 1-to-1 (wii controller) */ + if (joydev.axis_count && !found_axes) + { + ERR("Incoherent joystick data, advertised %d axes, detected 0. Assuming 1-to-1.\n", + joydev.axis_count); + for (j = 0; j < joydev.axis_count; j++) + joydev.dev_axes_map[j] = j; + } } /* Find vendor_id and product_id in sysfs */