Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fix for keyboard/mouse/tablet being detected as joystick in Linux — Moved to https://github.com/denilsonsa/udev-joystick-blacklist
#
# ███╗ ███╗ ██████╗ ██╗ ██╗███████╗██████╗ ████████╗ ██████╗
# ████╗ ████║██╔═══██╗██║ ██║██╔════╝██╔══██╗ ╚══██╔══╝██╔═══██╗
# ██╔████╔██║██║ ██║██║ ██║█████╗ ██║ ██║ ██║ ██║ ██║
# ██║╚██╔╝██║██║ ██║╚██╗ ██╔╝██╔══╝ ██║ ██║ ██║ ██║ ██║
# ██║ ╚═╝ ██║╚██████╔╝ ╚████╔╝ ███████╗██████╔╝ ██║ ╚██████╔╝
# ╚═╝ ╚═╝ ╚═════╝ ╚═══╝ ╚══════╝╚═════╝ ╚═╝ ╚═════╝
#
# ╔═════════════════════════════════════════════════════════════════╗
# ║ https://github.com/denilsonsa/udev-joystick-blacklist ║
# ╚═════════════════════════════════════════════════════════════════╝
#
# These rules are now hosted in a full GitHub repository. This Gist will not be updated anymore.
#
#
# Credit: FIGlet font "ANSI Shadow", generated at http://patorjk.com/software/taag/
#
#####################################################################
#
# /etc/udev/rules.d/51-these-are-not-joysticks.rules
# https://gist.github.com/denilsonsa/978f1d842cf5430f57f6
#
# These are devices that, although recognized by kernel as joysticks, are not
# joysticks. These rules will prevent the non-functional /dev/input/js* and
# /dev/input/event* devices from being used, by removing read/write permissions
# from them.
#
# This is just a blacklist, which will always be incomplete (until the actual
# bug gets fixed). Feel free to add more devices to this list.
#
#
# MODE="0000" prevents the device from being used.
#
# Clearing ID_INPUT_JOYSTICK prevents some /lib/udev/rules.d/* rules from running.
#
# It is not possible to rename a device, so NAME="not-a-joystick%n" does not work.
#
#
# HOW TO INSTALL:
#
# sudo curl -o /etc/udev/rules.d/51-these-are-not-joysticks.rules https://gist.githubusercontent.com/denilsonsa/978f1d842cf5430f57f6/raw
#
#
# There are several reports of this issue on several distros and on the Linux kernel:
# https://bugzilla.kernel.org/show_bug.cgi?id=28912
# https://bugzilla.kernel.org/show_bug.cgi?id=37982
# https://bugs.launchpad.net/ubuntu/+source/linux/+bug/390959
# https://askubuntu.com/questions/173376/how-do-i-disable-joystick-input
# https://ryort.wordpress.com/2011/12/04/udev-and-the-microsoft-digital-media-keyboard-3000-wha/
# https://forum.manjaro.org/index.php?topic=15275.msg144519#msg144519
# https://bbs.archlinux.org/viewtopic.php?id=190485
# https://bbs.archlinux.org/viewtopic.php?id=142469
# https://forums.gentoo.org/viewtopic-t-362032.html
# https://bugs.winehq.org/show_bug.cgi?id=35954
# https://github.com/ValveSoftware/steam-for-linux/issues/3943
#
# A nice (but outdated) udev tutoral:
# http://www.reactivated.net/writing_udev_rules.html
# Microsoft Microsoft Wireless Optical Desktop® 2.10
# Microsoft Wireless Desktop - Comfort Edition
SUBSYSTEM=="input", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="009d", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
# Microsoft Microsoft® Digital Media Pro Keyboard
# Microsoft Corp. Digital Media Pro Keyboard
SUBSYSTEM=="input", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="00b0", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
# Microsoft Microsoft® Digital Media Keyboard
# Microsoft Corp. Digital Media Keyboard 1.0A
SUBSYSTEM=="input", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="00b4", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
# Microsoft Microsoft® Digital Media Keyboard 3000
SUBSYSTEM=="input", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="0730", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
# 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
SUBSYSTEM=="input", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="0745", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
# Microsoft Corp. Wired Keyboard 600
SUBSYSTEM=="input", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="0750", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
# Microsoft Corp. Sidewinder X4 keyboard
SUBSYSTEM=="input", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="0768", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
# Microsoft® 2.4GHz Transceiver v9.0
SUBSYSTEM=="input", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="07a5", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
# Microsoft® Nano Transceiver v1.0
# Microsoft Wireless Keyboard 800
SUBSYSTEM=="input", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="07b2", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
# Microsoft® Nano Transceiver v2.0
SUBSYSTEM=="input", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="0800", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
# WACOM CTE-640-U V4.0-3
# Wacom Co., Ltd Graphire 4 6x8
SUBSYSTEM=="input", ATTRS{idVendor}=="056a", ATTRS{idProduct}=="0016", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
# Wacom Bamboo Pen and Touch CTH-460
SUBSYSTEM=="input", ATTRS{idVendor}=="056a", ATTRS{idProduct}=="00d1", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
# A4 Tech Co., G7 750 mouse
SUBSYSTEM=="input", ATTRS{idVendor}=="09da", ATTRS{idProduct}=="054f", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
# A4 Tech Co., Ltd Bloody RT7 Terminator Wireless
SUBSYSTEM=="input", ATTRS{idVendor}=="09da", ATTRS{idProduct}=="3997", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
# Modecom MC-5006 Keyboard
SUBSYSTEM=="input", ATTRS{idVendor}=="09da", ATTRS{idProduct}=="51f4", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
# A4 Tech Co., Ltd Bloody V5
SUBSYSTEM=="input", ATTRS{idVendor}=="09da", ATTRS{idProduct}=="7b22", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
# A4 Tech Co., Ltd X-718BK Oscar Optical Gaming Mouse
SUBSYSTEM=="input", ATTRS{idVendor}=="09da", ATTRS{idProduct}=="8090", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
# A4 Tech Co., Ltd XL-750BK Laser Mouse
SUBSYSTEM=="input", ATTRS{idVendor}=="09da", ATTRS{idProduct}=="9090", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
# A4 Tech Co., Sharkoon Fireglider Optical
SUBSYSTEM=="input", ATTRS{idVendor}=="09da", ATTRS{idProduct}=="9066", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
# Cooler Master Storm Mizar Mouse
SUBSYSTEM=="input", ATTRS{idVendor}=="2516", ATTRS{idProduct}=="001f", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
@dobrMAN

This comment has been minimized.

Copy link

dobrMAN commented May 22, 2015

# A4Tech X7 mouse
SUBSYSTEM=="input", ATTRS{idVendor}=="09da", ATTRS{idProduct}=="8090", KERNEL=="js[0-9]*", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
@denilsonsa

This comment has been minimized.

Copy link
Owner Author

denilsonsa commented May 22, 2015

@dobrMAN, added! Thanks!

@MeGA-ct

This comment has been minimized.

Copy link

MeGA-ct commented Jun 24, 2015

# A4 Tech Co., Ltd XL-750BK Laser Mouse
SUBSYSTEM=="input", ATTRS{idVendor}=="09da", ATTRS{idProduct}=="9090", KERNEL=="js[0-9]*", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
@ShadowKyogre

This comment has been minimized.

Copy link

ShadowKyogre commented Jul 1, 2015

# Wacom Bamboo Pen and Touch CTH-460

SUBSYSTEM=="input", ATTRS{idVendor}=="056a", ATTRS{idProduct}=="00d1", KERNEL=="js[0-9]*",  MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
@steamlinux

This comment has been minimized.

Copy link

steamlinux commented Jul 6, 2015

I create my mouse

# A4 Tech Co., Ltd Bloody V5
SUBSYSTEM=="input", ATTRS{idVendor}=="09da", ATTRS{idProduct}=="7b22", KERNEL=="js[0-9]*", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""

and doesn't work
http://pastebin.com/cJNFqxcm
can you help me?

@hylkevds

This comment has been minimized.

Copy link

hylkevds commented Aug 11, 2015

# Sharkoon Fireglider Optical (A4 Tech Co.)
SUBSYSTEM=="input", ATTRS{idVendor}=="09da", ATTRS{idProduct}=="9066", KERNEL=="js[0-9]*", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
@doraskayo

This comment has been minimized.

Copy link

doraskayo commented Aug 15, 2015

Thanks for the workaround, @denilsonsa.

I've noticed that it only works for /dev/input/js* devices, while some software (including SDL2) only interfaces with joysticks through /dev/input/event* devices.
In order to make this workaround handle these cases as well, and since event IDs aren't persistent, we need to completely remove the KERNEL requirement. Only doing that is obviously not a good idea, since these blacklisted devices also offer other device inputs which we don't want to block, like a mouse and/or a keyboard. Therefore, we can do this:

SUBSYSTEM=="input", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="0745", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""

By using ENV{ID_INPUT_JOYSTICK}=="1", we'll only target device inputs that claim to be joysticks.

@steamlinux, this may be the reason the workaround didn't work for you. Try it again using this fix.

@Bgumble

This comment has been minimized.

Copy link

Bgumble commented Aug 17, 2015

Hey. This device was giving me trouble (Microsoft Nano transceiver 2.0):

SUBSYSTEM=="input", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="0800", KERNEL=="js[0-9]*", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
@radekula

This comment has been minimized.

Copy link

radekula commented Sep 14, 2015

Thanks for a file @denilsonsa and also thanks @xtor91 for info about /dev/input/event*.

This line worked with my mouse:

# A4 Tech Co., Ltd Bloody RT7 Terminator Wireless
SUBSYSTEM=="input", ATTRS{idVendor}=="09da", ATTRS{idProduct}=="3997", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
@ghost

This comment has been minimized.

Copy link

ghost commented Oct 9, 2015

# Modecom MC-5006 Keyboard
SUBSYSTEM=="input", ATTRS{idVendor}=="09da", ATTRS{idProduct}=="51f4", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
@alexhultman

This comment has been minimized.

Copy link

alexhultman commented Oct 23, 2015

# Cooler Master Storm Mizar Mouse
SUBSYSTEM=="input", ATTRS{idVendor}=="2516", ATTRS{idProduct}=="001f", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""
@denilsonsa

This comment has been minimized.

Copy link
Owner Author

denilsonsa commented Oct 23, 2015

Thanks everyone for the contributions! I've updated this gist with all of them. Sorry it took so long, but for some reason GitHub is not sending notifications for Gist comments. Please, feel free to contact me elsewhere whenever you make a contribution here.

@denilsonsa

This comment has been minimized.

Copy link
Owner Author

denilsonsa commented Oct 25, 2015

I've moved this solution to a GitHub repository. This Gist will not be maintained anymore.

Go to: https://github.com/denilsonsa/udev-joystick-blacklist

@ramaxa9

This comment has been minimized.

Copy link

ramaxa9 commented Apr 26, 2016

Bloody B120 Keyboard

SUBSYSTEM=="input", ATTRS{idVendor}=="09da", ATTRS{idProduct}=="f624", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""

@ezra-s

This comment has been minimized.

Copy link

ezra-s commented Dec 8, 2017

Not sure what to do here.

My mouse identifies itself with two devices:
cat /proc/bus/input/devices

...
I: Bus=0003 Vendor=1b1c Product=1b12 Version=0111
N: Name="Corsair Corsair M65 RGB Gaming Mouse"
P: Phys=usb-0000:00:1d.0-1.6/input0
S: Sysfs=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.6/4-1.6:1.0/0003:1B1C:1B12.0004/input/input10
U: Uniq=0D00502EAE3D8C6953998B42F5001943
H: Handlers=event10 mouse0
B: PROP=0
B: EV=17
B: KEY=1f0000 0 0 0 0
B: REL=103
B: MSC=10

I: Bus=0003 Vendor=1b1c Product=1b12 Version=0111
N: Name="Corsair Corsair M65 RGB Gaming Mouse"
P: Phys=usb-0000:00:1d.0-1.6/input1
S: Sysfs=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.6/4-1.6:1.1/0003:1B1C:1B12.0005/input/input11
U: Uniq=0D00502EAE3D8C6953998B42F5001943
H: Handlers=kbd event11 js0 mouse1
B: PROP=0
B: EV=1f
B: KEY=ffffffff0000 0 3800000000 2000000000000 0
B: REL=103
B: ABS=ffffff0000000000
B: MSC=10

I tried this but the devices are still generated as joystick under /dev

Corsair M65 RGB is not a joystick

SUBSYSTEM=="input", ATTRS{idVendor}=="1b1c", ATTRS{idProduct}=="1b12", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0000", ENV{ID_INPUT_JOYSTICK}=""

with this js0 is succesfully removed but mouse is still detected as a joystick by applications (mouse1 and event11?):
SUBSYSTEM=="input", ATTRS{idVendor}=="1b1c", ATTRS{idProduct}=="1b12", ENV{ID_INPUT_JOYSTICK}=="?*", ENV{ID_INPUT_JOYSTICK}=""
SUBSYSTEM=="input", ATTRS{idVendor}=="1b1c", ATTRS{idProduct}=="1b12", KERNEL=="js0", RUN+="/bin/rm %E{DEVNAME}", ENV{ID_INPUT_JOYSTICK}=""

or tried removing all that are detected as joysticks (but using the last two will make my mouse not recognized when X starts):

Corsair M65 RGB is not a joystick

SUBSYSTEM=="input", ATTRS{idVendor}=="1b1c", ATTRS{idProduct}=="1b12", ENV{ID_INPUT_JOYSTICK}=="?*", ENV{ID_INPUT_JOYSTICK}=""
SUBSYSTEM=="input", ATTRS{idVendor}=="1b1c", ATTRS{idProduct}=="1b12", KERNEL=="js0", RUN+="/bin/rm %E{DEVNAME}", ENV{ID_INPUT_JOYSTICK}=""
SUBSYSTEM=="input", ATTRS{idVendor}=="1b1c", ATTRS{idProduct}=="1b12", KERNEL=="event11", RUN+="/bin/rm %E{DEVNAME}", ENV{ID_INPUT_JOYSTICK}=""
SUBSYSTEM=="input", ATTRS{idVendor}=="1b1c", ATTRS{idProduct}=="1b12", KERNEL=="mouse1", RUN+="/bin/rm %E{DEVNAME}", ENV{ID_INPUT_JOYSTICK}=""

$ ls -l /dev/input/by-id/
total 0
lrwxrwxrwx 1 root root 9 dic 8 19:10 usb-Corsair_Corsair_K70R_Gaming_Keyboard-event-if01 -> ../event8
lrwxrwxrwx 1 root root 9 dic 8 19:10 usb-Corsair_Corsair_K70R_Gaming_Keyboard-event-kbd -> ../event7
lrwxrwxrwx 1 root root 9 dic 8 19:10 usb-Corsair_Corsair_K70R_Gaming_Keyboard-if02-event-kbd -> ../event9
lrwxrwxrwx 1 root root 10 dic 8 19:10 usb-Corsair_Corsair_M65_RGB_Gaming_Mouse_0D00502EAE3D8C6953998B42F5001943-event-mouse -> ../event10
lrwxrwxrwx 1 root root 10 dic 8 19:10 usb-Corsair_Corsair_M65_RGB_Gaming_Mouse_0D00502EAE3D8C6953998B42F5001943-if01-event-joystick -> ../event11
lrwxrwxrwx 1 root root 6 dic 8 19:10 usb-Corsair_Corsair_M65_RGB_Gaming_Mouse_0D00502EAE3D8C6953998B42F5001943-if01-joystick -> ../js0
lrwxrwxrwx 1 root root 9 dic 8 19:10 usb-Corsair_Corsair_M65_RGB_Gaming_Mouse_0D00502EAE3D8C6953998B42F5001943-mouse -> ../mouse0

Any tips will be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.