Skip to content

Commit

Permalink
Implemented Linux joystick blacklist
Browse files Browse the repository at this point in the history
Based on https://raw.githubusercontent.com/denilsonsa/udev-joystick-blacklist/master/generate_rules.py

This fixes a few devices that are not actually joysticks showing up as such in SDL
  • Loading branch information
slouken committed Apr 6, 2017
1 parent a4dbf56 commit 1eb92f6
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/joystick/SDL_joystick.c
Expand Up @@ -32,7 +32,6 @@
#include "../events/SDL_events_c.h"
#endif

#define MAKE_VIDPID(VID, PID) (((Uint32)(VID))<<16|(PID))

static SDL_bool SDL_joystick_allows_background_events = SDL_FALSE;
static SDL_Joystick *SDL_joysticks = NULL;
Expand Down
3 changes: 3 additions & 0 deletions src/joystick/SDL_sysjoystick.h
Expand Up @@ -68,6 +68,9 @@ struct _SDL_Joystick
struct _SDL_Joystick *next; /* pointer to next joystick we have allocated */
};

/* Macro to combine a USB vendor ID and product ID into a single Uint32 value */
#define MAKE_VIDPID(VID, PID) (((Uint32)(VID))<<16|(PID))

/* Function to scan the system for joysticks.
* Joystick 0 should be the system default joystick.
* This function should return the number of available joysticks, or -1
Expand Down
102 changes: 102 additions & 0 deletions src/joystick/linux/SDL_sysjoystick.c
Expand Up @@ -80,7 +80,101 @@ static int instance_counter = 0;
static int
IsJoystick(int fd, char *namebuf, const size_t namebuflen, SDL_JoystickGUID *guid)
{
/* This list is taken from:
https://raw.githubusercontent.com/denilsonsa/udev-joystick-blacklist/master/generate_rules.py
*/
static Uint32 joystick_blacklist[] = {
/* Microsoft Microsoft Wireless Optical Desktop® 2.10 */
/* Microsoft Wireless Desktop - Comfort Edition */
MAKE_VIDPID(0x045e, 0x009d),

/* Microsoft Microsoft® Digital Media Pro Keyboard */
/* Microsoft Corp. Digital Media Pro Keyboard */
MAKE_VIDPID(0x045e, 0x00b0),

/* Microsoft Microsoft® Digital Media Keyboard */
/* Microsoft Corp. Digital Media Keyboard 1.0A */
MAKE_VIDPID(0x045e, 0x00b4),

/* Microsoft Microsoft® Digital Media Keyboard 3000 */
MAKE_VIDPID(0x045e, 0x0730),

/* Microsoft Microsoft® 2.4GHz Transceiver v6.0 */
/* Microsoft Microsoft® 2.4GHz Transceiver v8.0 */
/* Microsoft Corp. Nano Transceiver v1.0 for Bluetooth */
/* Microsoft Wireless Mobile Mouse 1000 */
/* Microsoft Wireless Desktop 3000 */
MAKE_VIDPID(0x045e, 0x0745),

/* Microsoft® SideWinder(TM) 2.4GHz Transceiver */
MAKE_VIDPID(0x045e, 0x0748),

/* Microsoft Corp. Wired Keyboard 600 */
MAKE_VIDPID(0x045e, 0x0750),

/* Microsoft Corp. Sidewinder X4 keyboard */
MAKE_VIDPID(0x045e, 0x0768),

/* Microsoft Corp. Arc Touch Mouse Transceiver */
MAKE_VIDPID(0x045e, 0x0773),

/* Microsoft® 2.4GHz Transceiver v9.0 */
/* Microsoft® Nano Transceiver v2.1 */
/* Microsoft Sculpt Ergonomic Keyboard (5KV-00001) */
MAKE_VIDPID(0x045e, 0x07a5),

/* Microsoft® Nano Transceiver v1.0 */
/* Microsoft Wireless Keyboard 800 */
MAKE_VIDPID(0x045e, 0x07b2),

/* Microsoft® Nano Transceiver v2.0 */
MAKE_VIDPID(0x045e, 0x0800),

/* List of Wacom devices at: http://linuxwacom.sourceforge.net/wiki/index.php/Device_IDs */
MAKE_VIDPID(0x056a, 0x0010), /* Wacom ET-0405 Graphire */
MAKE_VIDPID(0x056a, 0x0011), /* Wacom ET-0405A Graphire2 (4x5) */
MAKE_VIDPID(0x056a, 0x0012), /* Wacom ET-0507A Graphire2 (5x7) */
MAKE_VIDPID(0x056a, 0x0013), /* Wacom CTE-430 Graphire3 (4x5) */
MAKE_VIDPID(0x056a, 0x0014), /* Wacom CTE-630 Graphire3 (6x8) */
MAKE_VIDPID(0x056a, 0x0015), /* Wacom CTE-440 Graphire4 (4x5) */
MAKE_VIDPID(0x056a, 0x0016), /* Wacom CTE-640 Graphire4 (6x8) */
MAKE_VIDPID(0x056a, 0x0017), /* Wacom CTE-450 Bamboo Fun (4x5) */
MAKE_VIDPID(0x056a, 0x0016), /* Wacom CTE-640 Graphire 4 6x8 */
MAKE_VIDPID(0x056a, 0x0017), /* Wacom CTE-450 Bamboo Fun 4x5 */
MAKE_VIDPID(0x056a, 0x0018), /* Wacom CTE-650 Bamboo Fun 6x8 */
MAKE_VIDPID(0x056a, 0x0019), /* Wacom CTE-631 Bamboo One */
MAKE_VIDPID(0x056a, 0x00d1), /* Wacom Bamboo Pen and Touch CTH-460 */

MAKE_VIDPID(0x09da, 0x054f), /* A4 Tech Co., G7 750 mouse */
MAKE_VIDPID(0x09da, 0x3043), /* A4 Tech Co., Ltd Bloody R8A Gaming Mouse */
MAKE_VIDPID(0x09da, 0x31b5), /* A4 Tech Co., Ltd Bloody TL80 Terminator Laser Gaming Mouse */
MAKE_VIDPID(0x09da, 0x3997), /* A4 Tech Co., Ltd Bloody RT7 Terminator Wireless */
MAKE_VIDPID(0x09da, 0x3f8b), /* A4 Tech Co., Ltd Bloody V8 mouse */
MAKE_VIDPID(0x09da, 0x51f4), /* Modecom MC-5006 Keyboard */
MAKE_VIDPID(0x09da, 0x5589), /* A4 Tech Co., Ltd Terminator TL9 Laser Gaming Mouse */
MAKE_VIDPID(0x09da, 0x7b22), /* A4 Tech Co., Ltd Bloody V5 */
MAKE_VIDPID(0x09da, 0x7f2d), /* A4 Tech Co., Ltd Bloody R3 mouse */
MAKE_VIDPID(0x09da, 0x8090), /* A4 Tech Co., Ltd X-718BK Oscar Optical Gaming Mouse */
MAKE_VIDPID(0x09da, 0x9066), /* A4 Tech Co., Sharkoon Fireglider Optical */
MAKE_VIDPID(0x09da, 0x9090), /* A4 Tech Co., Ltd XL-730K / XL-750BK / XL-755BK Laser Mouse */
MAKE_VIDPID(0x09da, 0x90c0), /* A4 Tech Co., Ltd X7 G800V keyboard */
MAKE_VIDPID(0x09da, 0xf012), /* A4 Tech Co., Ltd Bloody V7 mouse */
MAKE_VIDPID(0x09da, 0xf32a), /* A4 Tech Co., Ltd Bloody B540 keyboard */
MAKE_VIDPID(0x09da, 0xf613), /* A4 Tech Co., Ltd Bloody V2 mouse */
MAKE_VIDPID(0x09da, 0xf624), /* A4 Tech Co., Ltd Bloody B120 Keyboard */

MAKE_VIDPID(0x1d57, 0xad03), /* [T3] 2.4GHz and IR Air Mouse Remote Control */

MAKE_VIDPID(0x1e7d, 0x2e4a), /* Roccat Tyon Mouse */

MAKE_VIDPID(0x20a0, 0x422d), /* Winkeyless.kr Keyboards */

MAKE_VIDPID(0x2516, 0x001f), /* Cooler Master Storm Mizar Mouse */
MAKE_VIDPID(0x2516, 0x0028), /* Cooler Master Storm Alcor Mouse */
};
struct input_id inpid;
int i;
Uint32 id;
Uint16 *guid16 = (Uint16 *)guid->data;

#if !SDL_USE_LIBUDEV
Expand Down Expand Up @@ -109,6 +203,14 @@ IsJoystick(int fd, char *namebuf, const size_t namebuflen, SDL_JoystickGUID *gui
return 0;
}

/* Check the joystick blacklist */
id = MAKE_VIDPID(inpid.vendor, inpid.product);
for (i = 0; i < SDL_arraysize(joystick_blacklist); ++i) {
if (id == joystick_blacklist[i]) {
return 0;
}
}

#ifdef DEBUG_JOYSTICK
printf("Joystick: %s, bustype = %d, vendor = 0x%.4x, product = 0x%.4x, version = %d\n", namebuf, inpid.bustype, inpid.vendor, inpid.product, inpid.version);
#endif
Expand Down

0 comments on commit 1eb92f6

Please sign in to comment.