{"id":17058714,"url":"https://github.com/denilsonsa/udev-joystick-blacklist","last_synced_at":"2025-04-13T11:09:42.755Z","repository":{"id":53080119,"uuid":"44906856","full_name":"denilsonsa/udev-joystick-blacklist","owner":"denilsonsa","description":"Fix for keyboard/mouse/tablet being detected as joystick in Linux","archived":false,"fork":false,"pushed_at":"2025-03-23T20:02:03.000Z","size":127,"stargazers_count":124,"open_issues_count":13,"forks_count":28,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-13T11:09:38.473Z","etag":null,"topics":["joystick","linux-kernel","udev-rules","workaround"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/denilsonsa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-25T11:17:18.000Z","updated_at":"2025-03-23T20:02:06.000Z","dependencies_parsed_at":"2024-10-14T10:40:41.214Z","dependency_job_id":null,"html_url":"https://github.com/denilsonsa/udev-joystick-blacklist","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denilsonsa%2Fudev-joystick-blacklist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denilsonsa%2Fudev-joystick-blacklist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denilsonsa%2Fudev-joystick-blacklist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denilsonsa%2Fudev-joystick-blacklist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/denilsonsa","download_url":"https://codeload.github.com/denilsonsa/udev-joystick-blacklist/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248703199,"owners_count":21148118,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["joystick","linux-kernel","udev-rules","workaround"],"created_at":"2024-10-14T10:30:32.765Z","updated_at":"2025-04-13T11:09:42.729Z","avatar_url":"https://github.com/denilsonsa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# udev-joystick-blacklist\n\nFix for keyboard/mouse/tablet being detected as joystick in Linux.\n\nThere are several devices that, although recognized by kernel as joysticks, are not joysticks. This repository contains rules that will prevent the non-functional `/dev/input/js*` and `/dev/input/event*` devices from being recognized as joysticks.\n\nThis is just a blacklist, which will always be incomplete (until the actual bug gets fixed). Feel free to add more devices to this list.\n\n## Known devices\n\nFor the complete list, look at the [`generate_rules.py`](generate_rules.py) script.\n\n* A4 Tech mice and/or keyboards.\n* ASRock LED controller.\n* Cooler Master mice.\n* Corsair mice and/or keyboards.\n* Lenovo keyboard.\n* Microsoft mice and/or keyboards. ([Fixed in Linux kernel 4.9.](https://github.com/denilsonsa/udev-joystick-blacklist/issues/20))\n* Wacom tablets.\n* …and many others!\n\n## How to install\n\n### Version that changes permissions to 0000\n\n    sudo curl -o /etc/udev/rules.d/51-these-are-not-joysticks.rules \\\n      https://raw.githubusercontent.com/denilsonsa/udev-joystick-blacklist/master/51-these-are-not-joysticks.rules\n\n### Version that removes the device\n\n    sudo curl -o /etc/udev/rules.d/51-these-are-not-joysticks-rm.rules \\\n      https://raw.githubusercontent.com/denilsonsa/udev-joystick-blacklist/master/51-these-are-not-joysticks-rm.rules\n\n### Which version should I use?\n\nPersonally, I'd try the first version (that sets permissions to `0000`) first. If it does not work or if it gives trouble for some reason, I'd try the second version (that removes the device).\n\nThe first version (that sets permissions to `0000`) seems to work fine across several distros, but some distros ([such as OSMC](https://github.com/denilsonsa/udev-joystick-blacklist/issues/5#issuecomment-151872841), [see also issue #26](https://github.com/denilsonsa/udev-joystick-blacklist/issues/26)) may have additional rules that end up setting the permssions back to another value. In such case, the second version (that removes the device) should work.\n\nIn the end, it's up to you, and it's about what works best for you and your system.\n\n### What's different in `after_kernel_4_9/`?\n\nA patch has been accepted into Linux kernel 4.9, so that Microsoft devices will not be detected as joysticks anymore. Thus, those devices are not included in `after_kernel_4_9/*`. Read [issue #20](https://github.com/denilsonsa/udev-joystick-blacklist/issues/20) for details.\n\n## How it works\n\n### Matching\n\nA rule will match if:\n\n* The subsystem is `input`;\n* The pair `idVendor` and `idProduct` is in this list;\n* Either one of:\n    * The device property `ID_INPUT_JOYSTICK` is set;\n    * Or the device name matches `js[0-9]*`.\n\n### Actions\n\nThe following actions are taken on each matching rule:\n\n* Clears `ID_INPUT_JOYSTICK` property, which prevents [some `/lib/udev/rules.d/*` rules from running](https://github.com/denilsonsa/udev-joystick-blacklist/issues/5#issuecomment-151832071).\n* Depending on which version you installed, one of the following extra actions are applied only for `/dev/input/js*`:\n    * [Removes read and write permissions by setting `MODE=\"0000\"`](https://en.wikipedia.org/wiki/File_system_permissions#Numeric_notation). This effectively prevents the device from being used.\n    * Removes the device file from `/dev/input/`. This also prevents the device from being found or from being listed.\n\nIt is not possible to rename a device, so `NAME=\"not-a-joystick%n\"` will not work.\n\n### Learning more about udev rules\n\n* Documentation: \u003chttp://www.freedesktop.org/software/systemd/man/udev.html\u003e (and also the manpages installed on your system).\n* Debugging udev rules: \u003chttp://www.jpichon.net/blog/2011/12/debugging-udev-rules/\u003e.\n* Nice (but outdated) udev tutorial: \u003chttp://www.reactivated.net/writing_udev_rules.html\u003e.\n\n## Troubleshooting\n\nLook at the generated `/dev` files: `ls -l /dev/input/`\n\nUnplug and plug your USB device while monitoring for kernel and udev events: `udevadm monitor -p`\n\nLook for other udev rules that may interact with the same device: `grep -i '\\bjs\\b\\|joystick' /lib/udev/rules.d/* /usr/lib/udev/rules.d/* /etc/udev/rules.d/*`\n\n## Testing joystick detection\n\nThese tools list and interact with all available/detected joysticks:\n\n* **jstest-gtk**\n    * \u003chttps://github.com/Grumbel/jstest-gtk/\u003e\n    * [Directly interacts with `/dev/input/js*` devices. No library is used.](https://github.com/Grumbel/jstest-gtk/blob/17956d285fedcf476ea753ff850fa7adf51ba07c/src/joystick.cppL42)\n    * [Detects up to 32 devices with `/dev/input/js*` path.](https://github.com/Grumbel/jstest-gtk/blob/17956d285fedcf476ea753ff850fa7adf51ba07c/src/joystick.cpp#L152-L161)\n* **pygame-joystick-test.py**\n    * \u003chttps://github.com/denilsonsa/pygame-joystick-test/\u003e\n    * Uses Python (2.x or 3.x) and [Pygame](http://www.pygame.org/), which uses [SDL](https://www.libsdl.org/).\n* **sdl-jstest --list** and **sdl2-jstest --list**\n    * \u003chttps://gitlab.com/sdl-jstest/sdl-jstest\u003e\n    * \u003chttps://github.com/Grumbel/sdl-jstest\u003e\n    * Uses [SDL](https://www.libsdl.org/) and prints the detected joysticks to stdout.\n    * SDL1 looks at [the first 32 devices](https://github.com/libsdl-org/SDL-1.2/blob/52c714024e2d5a5383f64f9b119ea96cb46f9af2/src/joystick/linux/SDL_sysjoystick.c#L258-L259) named [`/dev/input/js*` or `/dev/js*`](https://github.com/libsdl-org/SDL-1.2/blob/52c714024e2d5a5383f64f9b119ea96cb46f9af2/src/joystick/linux/SDL_sysjoystick.c#L405-L411).\n        * [As a special case, it can also look at `/dev/input/event*`](https://github.com/libsdl-org/SDL-1.2/blob/52c714024e2d5a5383f64f9b119ea96cb46f9af2/src/joystick/linux/SDL_sysjoystick.c#L496-L506).\n    * SDL2 can either use [`libudev` or `inotify` or just plain polling](https://github.com/libsdl-org/SDL/blob/1bf7898ddf1e0d6a6dd391614fd86f3731349fe2/src/joystick/linux/SDL_sysjoystick.c#L878-L892) to read entries from `/dev/input/`.\n* **wine control.exe joy.cpl**\n    * \u003chttps://www.winehq.org/\u003e\n    * The [Wine control panel](http://wiki.winehq.org/control) includes a *Game Controllers* configuration.\n    * It can look at [the first 64 devices](https://source.winehq.org/git/wine.git/blob/dca0e38d82c737cd8aeab63e08cf1990d05d9671:/dlls/dinput/joystick_linux.c#l139) named [`/dev/input/js*` or `/dev/js*`](https://source.winehq.org/git/wine.git/blob/dca0e38d82c737cd8aeab63e08cf1990d05d9671:/dlls/dinput/joystick_linux.c#l72).\n    * It can look at [the first 64 devices](https://source.winehq.org/git/wine.git/blob/dca0e38d82c737cd8aeab63e08cf1990d05d9671:/dlls/dinput/joystick_linuxinput.c#l180) named [`/dev/input/event*`](https://source.winehq.org/git/wine.git/blob/dca0e38d82c737cd8aeab63e08cf1990d05d9671:/dlls/dinput/joystick_linuxinput.c#l70).\n* **steam -bigpicture**\n    * \u003chttp://store.steampowered.com/bigpicture\u003e\n    * Valve's Steam → Big Picture mode → ⚙ Settings → Controller.\n    * Uses SDL2 to detect joysticks.\n\n## Contributing\n\nThe best ways to contribute are by [creating a new issue][issues] or by [making a pull request][forking]. Make sure you mention the device name/description and the vendor/product IDs. The relevant line from `lsusb` output is usually enough.\n\nThis repository contains a list of devices compiled from contributions of several people. I cannot test every single device. If something does not work for you even after you have added the correct rules, please try debugging it on your own system. The output of `udevadm monitor -p` may prove very helpful. Also look at the output of `ls -l /dev/input/`.\n\n## Bug reports and mentions\n\nThere are reports of this issue on different distros and projects.\n\n* \u003chttps://bugzilla.kernel.org/show_bug.cgi?id=28912\u003e\n* \u003chttps://bugzilla.kernel.org/show_bug.cgi?id=37982\u003e\n* \u003chttps://bugs.launchpad.net/ubuntu/+source/linux/+bug/390959\u003e\n* \u003chttps://askubuntu.com/questions/173376/how-do-i-disable-joystick-input\u003e\n* \u003chttps://ryort.wordpress.com/2011/12/04/udev-and-the-microsoft-digital-media-keyboard-3000-wha/\u003e\n* \u003chttps://bbs.archlinux.org/viewtopic.php?id=190485\u003e\n* \u003chttps://bbs.archlinux.org/viewtopic.php?id=142469\u003e\n* \u003chttps://forums.gentoo.org/viewtopic-t-362032.html\u003e\n* \u003chttps://bugs.winehq.org/show_bug.cgi?id=35954\u003e\n* \u003chttps://bugzilla.redhat.com/show_bug.cgi?id=1325354\u003e\n* \u003chttps://github.com/ValveSoftware/steam-for-linux/issues/3943\u003e\n* \u003chttps://github.com/ValveSoftware/steam-for-linux/issues/3384\u003e\n\nThe udev rules in this repository have been added to:\n\n* Debian and Ubuntu\n    * [Debian bug #714399](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=714399)\n    * `joystick` package ([on Debian](https://packages.debian.org/stable/utils/joystick), [on Ubuntu](https://packages.ubuntu.com/noble/joystick)), starting on version 1.4.9-1\n* Arch Linux and derivatives (such as Manjaro)\n    * [AUR package udev-joystick-blacklist-git](https://aur.archlinux.org/packages/udev-joystick-blacklist-git)\n* SDL library\n    * [SDL_ShouldIgnoreJoystick() inside SDL_joystick.c](https://github.com/spurious/SDL-mirror/blob/master/src/joystick/SDL_joystick.c#L2188-L2317)\n    * [Originally added only for Linux on 2017-04-06](https://github.com/spurious/SDL-mirror/commit/3b03af8b7e2c7105ffce8843fe395e6f3b2e678b)\n    * [Later expanded to other systems (such as Windows) on 2018-12-05](https://github.com/spurious/SDL-mirror/commit/87928f6cbd875c771b9647ff471ec6a37bd52491)\n\nBut remember that the version distributed elsewhere might be different than the version on this repository.\n\n## Semi-related projects\n\n* [game-devices-udev](https://codeberg.org/fabiscafe/game-devices-udev) - Collection of udev rules for game controllers, usually giving permission for the user to access those devices.\n\n## History of this repository\n\nAfter suffering with this issue for a long time, I decided to investigate possible fixes and workarounds. Then, in May 2015, after searching a lot for a solution, I've managed to create some udev rules that fixed the issue for my devices and decided to share this solution with other people. Initially, I shared [the simple file at GitHub Gist][gist]. Over time, people submitted contributions through comments, and keeping that file on Gist was becoming too hard to manage.\n\nIn October 2015, I decided to move the file to [this GitHub repository][github]. That way, it will be easier to make changes, to fork, to receive notifications, and essentially to maintain it.\n\nIdeally, the bug in the Linux kernel should be fixed, so that this repository (which is essentially just a workaround) wouldn't be needed anymore. However, it's also possible those devices are incorrectly reporting their own capabilities, and thus the operating system is just following the device descriptors. Given there is [a report of this issue on Windows](https://github.com/spurious/SDL-mirror/commit/87928f6cbd875c771b9647ff471ec6a37bd52491), that could be the case.\n\n## License\n\nPublic domain. Feel free to use this project for whatever purpose you want.\n\nAlso, feel free to contribute to the project. And, if you have the knowledge and the skills, consider fixing this bug in the Linux kernel itself.\n\nThere is no warranty implied by using this project. Use at your own risk.\n\n\n[gist]: https://gist.github.com/denilsonsa/978f1d842cf5430f57f6\n[github]: https://github.com/denilsonsa/udev-joystick-blacklist\n[issues]: https://github.com/denilsonsa/udev-joystick-blacklist/issues\n[forking]: https://guides.github.com/activities/forking/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenilsonsa%2Fudev-joystick-blacklist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdenilsonsa%2Fudev-joystick-blacklist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenilsonsa%2Fudev-joystick-blacklist/lists"}