Vitaliy Margolen : dinput: Get default axes configuration from the device for joydev.

Alexandre Julliard julliard at winehq.org
Wed Aug 19 11:32:00 CDT 2009


Module: wine
Branch: master
Commit: 0932f4a1137974f4326fbba8b2d68d8e9b2aed70
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0932f4a1137974f4326fbba8b2d68d8e9b2aed70

Author: Vitaliy Margolen <wine-patches at kievinfo.com>
Date:   Sat Aug 15 11:59:05 2009 -0600

dinput: Get default axes configuration from the device for joydev.

---

 dlls/dinput/joystick_linux.c |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c
index 32f0314..d5f28a3 100644
--- a/dlls/dinput/joystick_linux.c
+++ b/dlls/dinput/joystick_linux.c
@@ -79,6 +79,9 @@ struct JoyDev
 {
     char device[MAX_PATH];
     char name[MAX_PATH];
+
+    BYTE dev_axes_map[ABS_MAX + 1];
+    int  have_axes_map;
 };
 
 typedef struct JoystickImpl JoystickImpl;
@@ -133,6 +136,29 @@ static INT find_joystick_devices(void)
             WARN("ioctl(%s,JSIOCGNAME) failed: %s\n", joydev.device, strerror(errno));
 #endif
 
+        if (ioctl(fd, JSIOCGAXMAP, joydev.dev_axes_map) < 0)
+        {
+            WARN("ioctl(%s,JSIOCGNAME) failed: %s\n", joydev.device, strerror(errno));
+            joydev.have_axes_map = 0;
+        }
+        else
+        {
+            INT j;
+            joydev.have_axes_map = 1;
+
+            /* Remap to DI numbers */
+            for (j = 0; j < ABS_MAX; j++)
+                if (joydev.dev_axes_map[j] < 8)
+                    /* Axis match 1-to-1 */
+                    joydev.dev_axes_map[j] = j;
+                else if (joydev.dev_axes_map[j] == 16 ||
+                         joydev.dev_axes_map[j] == 17)
+                    /* POV axis */
+                    joydev.dev_axes_map[j] = 8;
+                else
+                    joydev.dev_axes_map[j] = -1;
+        }
+
         close(fd);
 
         if (!joystick_devices_count)
@@ -296,7 +322,8 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
     newDevice->generic.deadzone = 0;
 
     /* do any user specified configuration */
-    hr = setup_dinput_options(&newDevice->generic, NULL);
+    hr = setup_dinput_options(&newDevice->generic, newDevice->joydev->have_axes_map ?
+                              newDevice->joydev->dev_axes_map : NULL);
     if (hr != DI_OK)
         goto FAILED1;
 




More information about the wine-cvs mailing list