Commit dd174c54 authored by Mike Frysinger's avatar Mike Frysinger Committed by Alexandre Julliard

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

parent 162d9cb6
...@@ -69,7 +69,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(dinput); ...@@ -69,7 +69,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(dinput);
#ifdef HAVE_LINUX_22_JOYSTICK_API #ifdef HAVE_LINUX_22_JOYSTICK_API
#define JOYDEV "/dev/js" #define JOYDEV_NEW "/dev/input/js"
#define JOYDEV_OLD "/dev/js"
typedef struct { typedef struct {
LONG lMin; LONG lMin;
...@@ -148,6 +149,19 @@ static void _dump_DIDEVCAPS(LPDIDEVCAPS lpDIDevCaps) ...@@ -148,6 +149,19 @@ static void _dump_DIDEVCAPS(LPDIDEVCAPS 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) static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
{ {
int fd = -1; int fd = -1;
...@@ -162,8 +176,7 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN ...@@ -162,8 +176,7 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) || ((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) { (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) {
/* check whether we have a joystick */ /* check whether we have a joystick */
sprintf(dev, "%s%d", JOYDEV, id); if ((fd = joydev_get_device(dev, id)) < 0) {
if ((fd = open(dev,O_RDONLY)) < 0) {
WARN("open(%s,O_RDONLY) failed: %s\n", dev, strerror(errno)); WARN("open(%s,O_RDONLY) failed: %s\n", dev, strerror(errno));
return FALSE; return FALSE;
} }
...@@ -212,8 +225,7 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN ...@@ -212,8 +225,7 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) || ((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) { (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) {
/* check whether we have a joystick */ /* check whether we have a joystick */
sprintf(dev, "%s%d", JOYDEV, id); if ((fd = joydev_get_device(dev, id)) < 0) {
if ((fd = open(dev,O_RDONLY)) < 0) {
WARN("open(%s,O_RDONLY) failed: %s\n", dev, strerror(errno)); WARN("open(%s,O_RDONLY) failed: %s\n", dev, strerror(errno));
return FALSE; return FALSE;
} }
...@@ -450,9 +462,7 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di ...@@ -450,9 +462,7 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
return DIERR_OUTOFMEMORY; return DIERR_OUTOFMEMORY;
} }
sprintf(newDevice->dev, "%s%d", JOYDEV, rguid->Data3); if ((newDevice->joyfd = joydev_get_device(newDevice->dev, rguid->Data3)) < 0) {
if ((newDevice->joyfd = open(newDevice->dev,O_RDONLY)) < 0) {
WARN("open(%s,O_RDONLY) failed: %s\n", newDevice->dev, strerror(errno)); WARN("open(%s,O_RDONLY) failed: %s\n", newDevice->dev, strerror(errno));
HeapFree(GetProcessHeap(), 0, newDevice); HeapFree(GetProcessHeap(), 0, newDevice);
return DIERR_DEVICENOTREG; return DIERR_DEVICENOTREG;
......
...@@ -54,7 +54,8 @@ ...@@ -54,7 +54,8 @@
#endif #endif
#ifdef HAVE_LINUX_JOYSTICK_H #ifdef HAVE_LINUX_JOYSTICK_H
#include <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 #endif
#ifdef HAVE_SYS_ERRNO_H #ifdef HAVE_SYS_ERRNO_H
#include <sys/errno.h> #include <sys/errno.h>
...@@ -166,12 +167,15 @@ static int JSTCK_OpenDevice(WINE_JSTCK* jstick) ...@@ -166,12 +167,15 @@ static int JSTCK_OpenDevice(WINE_JSTCK* jstick)
if (jstick->dev > 0) if (jstick->dev > 0)
return jstick->dev; return jstick->dev;
sprintf(buf, JOYDEV, jstick->joyIntf); sprintf(buf, JOYDEV_NEW, jstick->joyIntf);
#ifdef HAVE_LINUX_22_JOYSTICK_API #ifdef HAVE_LINUX_22_JOYSTICK_API
flags = O_RDONLY | O_NONBLOCK; flags = O_RDONLY | O_NONBLOCK;
#else #else
flags = O_RDONLY; flags = O_RDONLY;
#endif #endif
if ((jstick->dev = open(buf, flags)) < 0) {
sprintf(buf, JOYDEV_OLD, jstick->joyIntf);
}
return (jstick->dev = open(buf, flags)); return (jstick->dev = open(buf, flags));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment