Mike Frysinger : joystick: Search for /dev/input/js as well as /dev/js.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Apr 19 13:15:17 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: dd174c54e13e5d3cf27c396128d179dcbf1e5560
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=dd174c54e13e5d3cf27c396128d179dcbf1e5560

Author: Mike Frysinger <vapier at gentoo.org>
Date:   Tue Apr 18 18:58:44 2006 -0400

joystick: Search for /dev/input/js as well as /dev/js.

---

 dlls/dinput/joystick_linux.c   |   26 ++++++++++++++++++--------
 dlls/winmm/joystick/joystick.c |    8 ++++++--
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c
index 13b8c77..6404da6 100644
--- a/dlls/dinput/joystick_linux.c
+++ b/dlls/dinput/joystick_linux.c
@@ -69,7 +69,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(dinput);
 
 #ifdef HAVE_LINUX_22_JOYSTICK_API
 
-#define JOYDEV "/dev/js"
+#define JOYDEV_NEW "/dev/input/js"
+#define JOYDEV_OLD "/dev/js"
 
 typedef struct {
     LONG lMin;
@@ -148,6 +149,19 @@ static void _dump_DIDEVCAPS(LPDIDEVCAPS 
     }
 }
 
+static int joydev_get_device(char *dev, int id)
+{
+    int ret;
+    sprintf(dev, "%s%d", JOYDEV_NEW, id);
+    if ((ret = open(dev, O_RDONLY)) < 0) {
+        sprintf(dev, "%s%d", JOYDEV_OLD, id);
+        if ((ret = open(dev, O_RDONLY)) < 0) {
+            return -1;
+        }
+    }
+    return ret;
+}
+
 static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
 {
     int fd = -1;
@@ -162,8 +176,7 @@ static BOOL joydev_enum_deviceA(DWORD dw
 	((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) ||
 	(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) {
         /* check whether we have a joystick */
-        sprintf(dev, "%s%d", JOYDEV, id);
-        if ((fd = open(dev,O_RDONLY)) < 0) {
+        if ((fd = joydev_get_device(dev, id)) < 0) {
             WARN("open(%s,O_RDONLY) failed: %s\n", dev, strerror(errno));
             return FALSE;
         }
@@ -212,8 +225,7 @@ static BOOL joydev_enum_deviceW(DWORD dw
 	((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) ||
 	(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) {
         /* check whether we have a joystick */
-        sprintf(dev, "%s%d", JOYDEV, id);
-        if ((fd = open(dev,O_RDONLY)) < 0) {
+        if ((fd = joydev_get_device(dev, id)) < 0) {
             WARN("open(%s,O_RDONLY) failed: %s\n", dev, strerror(errno));
             return FALSE;
         }
@@ -450,9 +462,7 @@ static HRESULT alloc_device(REFGUID rgui
         return DIERR_OUTOFMEMORY;
     }
 
-    sprintf(newDevice->dev, "%s%d", JOYDEV, rguid->Data3);
-
-    if ((newDevice->joyfd = open(newDevice->dev,O_RDONLY)) < 0) {
+    if ((newDevice->joyfd = joydev_get_device(newDevice->dev, rguid->Data3)) < 0) {
         WARN("open(%s,O_RDONLY) failed: %s\n", newDevice->dev, strerror(errno));
         HeapFree(GetProcessHeap(), 0, newDevice);
         return DIERR_DEVICENOTREG;
diff --git a/dlls/winmm/joystick/joystick.c b/dlls/winmm/joystick/joystick.c
index a5914e9..2e04e31 100644
--- a/dlls/winmm/joystick/joystick.c
+++ b/dlls/winmm/joystick/joystick.c
@@ -54,7 +54,8 @@ #include <linux/ioctl.h>
 #endif
 #ifdef HAVE_LINUX_JOYSTICK_H
 #include <linux/joystick.h>
-#define JOYDEV "/dev/js%d"
+#define JOYDEV_NEW "/dev/input/js%d"
+#define JOYDEV_OLD "/dev/js%d"
 #endif
 #ifdef HAVE_SYS_ERRNO_H
 #include <sys/errno.h>
@@ -166,12 +167,15 @@ static	int	JSTCK_OpenDevice(WINE_JSTCK* 
     if (jstick->dev > 0)
       return jstick->dev;
 
-    sprintf(buf, JOYDEV, jstick->joyIntf);
+    sprintf(buf, JOYDEV_NEW, jstick->joyIntf);
 #ifdef HAVE_LINUX_22_JOYSTICK_API
     flags = O_RDONLY | O_NONBLOCK;
 #else
     flags = O_RDONLY;
 #endif
+    if ((jstick->dev = open(buf, flags)) < 0) {
+        sprintf(buf, JOYDEV_OLD, jstick->joyIntf);
+    }
     return (jstick->dev = open(buf, flags));
 }
 




More information about the wine-cvs mailing list