Module: wine
Branch: master
Commit: e87ccb8b055dc846211967e46ee2f17fbabef7a1
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e87ccb8b055dc846211967e46…
Author: Bruno Jesus <bjesus(a)codeweavers.com>
Date: Sun Apr 9 22:25:35 2017 -0300
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 <bjesus(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
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 1f8f94d..1032659 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 */