Difference between revisions of "Gamepad"

From ArchWiki
Jump to navigation Jump to search
m (Clarify mention of issues with default xpad driver to include both wired & wireless controllers, as the problems effect both)
(general cleanup, differentiate between joystick and evdev API, information on how to change deadzones in evdev joystick devices)
Line 7: Line 7:
 
Linux actually has 2 different input systems for Joysticks. The original 'Joystick' interface and the newer 'evdev' based one.
 
Linux actually has 2 different input systems for Joysticks. The original 'Joystick' interface and the newer 'evdev' based one.
  
'/dev/input/jsX' maps to the 'Joystick' API interface and /dev/input/eventX maps to the 'evdev' ones (this also includes other input devices such as mice and keyboards).
+
{{ic|1=/dev/input/jsX}} maps to the 'Joystick' API interface and {{ic|/dev/input/event*}} maps to the 'evdev' ones (this also includes other input devices such as mice and keyboards). Symbolic links to those devices are also available in {{ic|/dev/input/by-id/}} and {{ic|/dev/input/by-path/}} where the legacy 'Joystick' API has names ending with {{ic|-joystick}} while the 'evdev' have names ending with {{ic|-event-joystick}}.
  
Most new games will default to the 'evdev' ones. However many of the ones mentioned here (such as jscal, jstest and jstest-gtk) only work with the older 'Joystick' interface making calibration/mapping with those tools mostly useless. 'evdev' doesn't support any remapping or calibration leaving it up to the applications to support it.
+
Most new games will default to the 'evdev' interface as it gives more detailed information about the buttons and axes available and also adds support for force feedback.
  
You can override SDL and force it to use the 'Joystick' API by setting the environment variable {{ic|1=SDL_JOYSTICK_DEVICE=/dev/input/js0}}. This can help many games such as X3.
+
While SDL1.x defaults to 'evdev' interface you can force it to use the old 'Joystick' API by setting the environment variable {{ic|1=SDL_JOYSTICK_DEVICE=/dev/input/js0}}. This can help many games such as X3. SDL2.x supports only the new 'evdev' interface.
  
You can normally see and test both in wine with 'wine control joy.cpl'.
+
It's also worth mentioning that there is also a xorg driver {{ic|xf86-input-joystick}}. It just allows you to control the mouse/keyboard in xorg using a joystick, for most people this will be undesirable. Disabling this behaviour is described below in [[#Disable Joystick From Controlling Mouse|Disable Joystick From Controlling Mouse]], in most cases you can just remove this package though.
  
It's also worth mentioning that there is also a xorg driver 'xf86-input-joystick'. It just to allow you to control the mouse/keyboard in xorg using a joystick, for most people this will be undesirable. This mean that editing xorg.conf.d files for calibration/button mapping in games is pointless.
+
== Determining which modules you need ==
  
== Determining which modules you need ==
+
Unless you're using very old joystick that uses gameport or proprietary USB protocol, you will need just the generic USB human interface device (HID) modules.
  
 
For an extensive overview of all joystick related modules in Linux, you will need access to the Linux kernel sources -- specifically the Documentation section. Unfortunately, pacman kernel packages do not include what we need. If you have the kernel sources downloaded, have a look at {{ic|Documentation/input/joystick.txt}}. You can browse the kernel source tree at [https://kernel.org/ kernel.org] by clicking the "cgit" (git frontend) link for the kernel that you're using, then clicking the "tree" link near the top. Here's a link to the [https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/Documentation/input/joystick.txt?id=refs/tags/v3.12.6 Documentation from kernel 3.12.6].
 
For an extensive overview of all joystick related modules in Linux, you will need access to the Linux kernel sources -- specifically the Documentation section. Unfortunately, pacman kernel packages do not include what we need. If you have the kernel sources downloaded, have a look at {{ic|Documentation/input/joystick.txt}}. You can browse the kernel source tree at [https://kernel.org/ kernel.org] by clicking the "cgit" (git frontend) link for the kernel that you're using, then clicking the "tree" link near the top. Here's a link to the [https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/Documentation/input/joystick.txt?id=refs/tags/v3.12.6 Documentation from kernel 3.12.6].
Line 25: Line 25:
 
As you can see, there are many different modules related to getting your joystick working in Linux, so I couldn't possibly cover everything here. Please have a look at the documentation mentioned above for details.
 
As you can see, there are many different modules related to getting your joystick working in Linux, so I couldn't possibly cover everything here. Please have a look at the documentation mentioned above for details.
  
== Loading the modules ==
+
=== Loading the modules for analogue devices ===
  
 
You need to load a module for your gameport ({{ic|ns558}}, {{ic|emu10k1-gp}}, {{ic|cs461x}}, etc...), a module for your joystick ({{ic|analog}}, {{ic|sidewinder}}, {{ic|adi}}, etc...), and finally the kernel joystick device driver ({{ic|joydev}}). Add these to your {{ic|/etc/rc.conf}}, or simply modprobe them. The {{ic|gameport}} module should load automatically, as this is a dependency of the other modules.
 
You need to load a module for your gameport ({{ic|ns558}}, {{ic|emu10k1-gp}}, {{ic|cs461x}}, etc...), a module for your joystick ({{ic|analog}}, {{ic|sidewinder}}, {{ic|adi}}, etc...), and finally the kernel joystick device driver ({{ic|joydev}}). Add these to your {{ic|/etc/rc.conf}}, or simply modprobe them. The {{ic|gameport}} module should load automatically, as this is a dependency of the other modules.
 +
 +
=== USB joysticks ===
 +
 +
You need to get USB working, and then modprobe your joystick driver, which is {{ic|usbhid}}, as well as {{ic|joydev}}.
 +
If you use a usb mouse or keyboard, {{ic|usbhid}} will be loaded already and you just have to load the {{ic|joydev}} module.
  
 
== Testing Your Configuration ==
 
== Testing Your Configuration ==
  
Once the modules are loaded, you should find a new device: {{ic|/dev/input/js0}}. You can simply {{ic|cat}} the device to see if it works - move the stick around, press all the buttons. I found my Logitech Thunderpad Digital had two buttons that weren't working with the {{ic|analog}} module. After reading some docs, I saw there was a specific {{ic|adi}} module for this controller. The moral of the story is, if it doesn't work the first time, do not give up, and read those docs thoroughly! I couldn't get anything working at all until I found that documentation.
+
Once the modules are loaded, you should be able to find a new device: {{ic|/dev/input/js0}} and a file ending with {{ic|-event-joystick}} in {{ic|/dev/input/by-id}} directory. You can simply {{ic|cat}} those devices to see if the joystick works - move the stick around, press all the buttons - you should see mojibake printed when you move the sticks or press buttons.
 +
 
 +
Both interfaces are also supported in wine and reported as separate devices. You can test them with {{ic|1=wine control joy.cpl}}.
 +
 
 +
=== Joystick API ===
 +
There are a lot of applications that can test this old API, {{ic|jstest}} from the AUR {{AUR|joyutils}} package is the simplest one. If the output is unreadable because the line printed is too long you can also use graphical tools. KDE4 has a built in one in Input Devices panel in System Settings or the alternative AUR {{AUR|jstest-gtk-git}} application.
 +
 
 +
Use of {{ic|jstest}} fairly simple, you just run {{ic|jstest /dev/input/js0}} and it will print a line with state of all the axes (normalised to {-32767,32767}) and buttons.
 +
 
 +
After you start {{is|jstest-gtk}}, it will just show you a list of joysticks available, you just need to select one and press Properties.
 +
 
 +
=== evdev API ===
 +
 
 +
The new 'evdev' API can be tested using the SDL2 joystick test application. Install {{AUR|sdl2-jstest-git}} and then run {{ic|sdl2-jstest --test 0}}. Use {{ic|sdl2-jstest --list}} to get IDs of other controllers if you have multiple ones connected.
 +
 
 +
==Setting up deadzones and calibration==
 +
If you want to set up the deadzones (or remove them completely) of your analog input you have to do it separately for the xorg (for mouse and keyboard emulation), Joystick API and evdev API.
 +
 
 +
===Xorg deadzones===
 +
Add a similar line into your {{ic|/etc/X11/xorg.conf.d/50-joystick.conf}} before the {{ic|EndSection}}:
 +
Option "MapAxis1" "deadzone=1000"
 +
1000 is the default value, but you can set anything between 0 and 30 000. To get the axis number see the "Testing Your Configuration" section of this article.
 +
If you already have an option with a specific axis just type in the {{ic|1=deadzone=value}} at the end of the parameter separated by a space.
 +
 
 +
===Joystick API deadzones===
 +
The easiest way is using {{ic|jstest-gtk}} from {{AUR|jstest-gtk-git}}. Select the controller you want to edit, then click the Calibration button at the bottom of the dialog ('''don't''' click Start Calibration there). You can then set the CenterMin and CenterMax values (which control the center deadzone), RangeMin and RangeMax which control the end of throw deadzones. Note that the calibration settings are applied when the application opens the device, so you need to restart your game or test application to see updated calibration settings.
 +
 
 +
After you set the deadzones use {{ic|jscal}} to dump the new values into a shell script:
 +
jscal -p /dev/input/jsX > jscal.sh # replace X with your joystick's number
 +
chmod +x jscal.sh
 +
 
 +
Now you need to make a [[udev]] rule (for example {{ic|/etc/udev/rules.d and name it 85-jscal.rules}}) so the script will automatically run when you connect the controller:
 +
SUBSYSTEM=="input", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="c268", ACTION=="add", RUN+="/usr/bin/jscal.sh"
 +
To get the idVendor and idProduct use {{ic|udevadm info --attribute-walk --name /dev/input/jsX}}
 +
 
 +
Use the `/dev/input/by-id/*-joystick` device names in case you use multiple controllers.
 +
 
 +
===evdev API deadzones===
 +
Currently there is no standalone application that allows changing calibration for {{ic|evdev}} API, but there is {{ic|G25manage}} distributed together with VDrift game that can change the center deadzone.
 +
 
 +
The easiest way to get it is to go to VDrift [https://github.com/VDrift/vdrift/tree/master/tools/G25manage github], download all files in the folder and build them using {{ic|make}}.
 +
 
 +
After that, you should be able to see your device configuration by using:
 +
./G25manage --showcalibration /dev/input/by-id/usb-*-event-joystick
 +
 
 +
To change deadzones of any of the axes, you use the following command:
 +
./G25manage --evdev /dev/input/by-id/usb-*-event-joystick --axis 0 --deadzone 0
 +
 
 +
Use udev rules file to set them automatically when the controller is connected.
 +
 
 +
Note that inside the kernel, the value is called {{ic|flatness}} and is set using the {{ic|EVIOCSABS}} {{ic|ioctl}}.
 +
 
 +
Default configuration will look like similar to this:
 +
./G25manage --showcalibration /dev/input/by-id/usb-Madcatz_Saitek_Pro_Flight_X-55_Rhino_Stick_G0000090-event-joystick
 +
Supported Absolute axes:
 +
  Absolute axis 0x00 (0) (X Axis) (min: 0, max: 65535, flatness: 4095 (=6.25%), fuzz: 255)
 +
  Absolute axis 0x01 (1) (Y Axis) (min: 0, max: 65535, flatness: 4095 (=6.25%), fuzz: 255)
 +
  Absolute axis 0x05 (5) (Z Rate Axis) (min: 0, max: 4095, flatness: 255 (=6.23%), fuzz: 15)
 +
  Absolute axis 0x10 (16) (Hat zero, x axis) (min: -1, max: 1, flatness: 0 (=0.00%), fuzz: 0)
 +
  Absolute axis 0x11 (17) (Hat zero, y axis) (min: -1, max: 1, flatness: 0 (=0.00%), fuzz: 0)
 +
 
 +
While a more reasonable setting would be achieved with something like this (repeat for other axes):
 +
./G25manage --evdev /dev/input/by-id/usb-Madcatz_Saitek_Pro_Flight_X-55_Rhino_Stick_G0000090-event-joystick --axis 0 --deadzone 512
 +
Event device file: /dev/input/by-id/usb-Madcatz_Saitek_Pro_Flight_X-55_Rhino_Stick_G0000090-event-joystick
 +
Axis index to deal with: 0
 +
New dead zone value: 512
 +
Trying to set axis 0 deadzone to: 512
 +
  Absolute axis 0x00 (0) (X Axis) Setting deadzone value to : 512
 +
(min: 0, max: 65535, flatness: 512 (=0.78%), fuzz: 255)
 +
 
 +
== Disable Joystick From Controlling Mouse ==
 +
If you want to play games with your controller, you might want to disable joystick control over mouse cursor.  To do this, edit /etc/X11/xorg.conf.d/50-joystick.conf so that it looks like this:
 +
{{hc|/etc/X11/xorg.conf.d/50-joystick.conf |
 +
Section "InputClass"
 +
        Identifier "joystick catchall"
 +
        MatchIsJoystick "on"
 +
        MatchDevicePath "/dev/input/event*"
 +
        Driver "joystick"
 +
        Option "StartKeysEnabled" "False"      #Disable mouse
 +
        Option "StartMouseEnabled" "False"      #support
 +
EndSection}}
 +
 
 +
== Using Joystick to send keystrokes ==
 +
 
 +
A couple joystick to keystroke programs exist like {{AUR|rejoystick}}, {{AUR|qjoypad}} or {{AUR|antimicro-qt4}}, all work well without the need for X.org configuration.
 +
 
 +
=== via X.org ===
 +
 
 +
This is a good solution for systems where restarting Xorg is a rare event because it's a static configuration loaded only on X startup. I use it on my media PC running XBMC controlled with Logitech Cordless RumblePad 2. Due to a problem with the d-pad (a.k.a. "hat") being recognized as another axis, I used to run [[Joy2key]] as a workaround. Since I upgraded to XBMC 11.0 and joy2key 1.6.3-1, this setup no longer worked for me. I ended up taking a more direct approach and let Xorg handle joystick events.
 +
 
 +
First, make sure you have {{Pkg|xf86-input-joystick}} installed. Then, create {{ic|/etc/X11/xorg.conf.d/51-joystick.conf}} like so:
 +
{{bc|<nowiki>
 +
Section "InputClass"
 +
  Identifier "Joystick hat mapping"
 +
  Option "StartKeysEnabled" "True"
 +
  #MatchIsJoystick "on"
 +
  Option "MapAxis5" "keylow=113 keyhigh=114"
 +
  Option "MapAxis6" "keylow=111 keyhigh=116"
 +
EndSection
 +
</nowiki>}}
 +
{{Note|The ''MatchIsJoystick "on"'' line doesn't seem to be required for this to work but you may want to uncomment it.}}
 +
 
  
Another way of testing is using {{ic|jstest}} from the AUR {{AUR|joyutils}} package. That package also has {{ic|jscal}} for calibrating your device. If you have too many buttons and axes to fit on a single line or your pad has an accelerometer (it continuously sends new events even when nothing really happens) you should use a graphical tool. AUR has {{AUR|jstest-gtk-git}} for that purpose. It's essential for testing and troubleshooting a sixaxis.
+
== Specific devices ==
  
== USB joysticks ==
+
While most joysticks, especially USB based ones should just work, some may require (or give better results) if you use alternative drivers. If it doesn't work the first time, do not give up, and read those docs thoroughly!
  
You need to get USB working, and then modprobe your joystick driver, which is {{ic|usbhid}}, as well as {{ic|joydev}}.
+
=== Logitech Thunderpad Digital ===
If you use a usb mouse or keyboard, {{ic|usbhid}} will be loaded already and you just have to load the {{ic|joydev}} module.
+
Logitech Thunderpad Digital won't show all the buttons if you use the {{ic|analog}} module. Use the device specific {{ic|adi}} module for this controller.
  
== PS3 controller ==
+
=== PS3 controller ===
  
 
The Sixaxis gamepad works out of the box when plugged in via USB (the PS button will need to be pushed to begin), force feedback is backed since kernel 3.14.
 
The Sixaxis gamepad works out of the box when plugged in via USB (the PS button will need to be pushed to begin), force feedback is backed since kernel 3.14.
Line 46: Line 152:
 
Steam properly recognizes it as a PS3 pad and Big Picture can be launched with the PS button. Big Picture and some games may act as if it was a 360 controller.  Gamepad control over mouse is on by default.  You may want to turn it off before playing games, see below.
 
Steam properly recognizes it as a PS3 pad and Big Picture can be launched with the PS button. Big Picture and some games may act as if it was a 360 controller.  Gamepad control over mouse is on by default.  You may want to turn it off before playing games, see below.
  
== Xbox 360 controllers ==
+
=== Xbox 360 controllers ===
  
 
The controllers should work without additional packages, but the wireless controller needs a wireless receiver (the charge-and-play cable can not be used for communicating with the controller). Both the wired controllers and the wireless receiver is supported by the {{ic|xpad}} kernel module.
 
The controllers should work without additional packages, but the wireless controller needs a wireless receiver (the charge-and-play cable can not be used for communicating with the controller). Both the wired controllers and the wireless receiver is supported by the {{ic|xpad}} kernel module.
Line 67: Line 173:
 
{{Tip|If you use the [[TLP]] power management daemon, you may experience connection issues with your Microsoft wireless adapter (e.g. the indicator LED will go out after the adapter has been connected for a few seconds, and controller connection attempts fail). This is due to TLP's USB autosuspend functionality, and the solution is to either disable the functionality entirely, or to add the Microsoft wireless adapter's device ID to this feature's blacklist (check [http://linrunner.de/en/tlp/docs/tlp-configuration.html#usb TLP configuration] for more details).}}
 
{{Tip|If you use the [[TLP]] power management daemon, you may experience connection issues with your Microsoft wireless adapter (e.g. the indicator LED will go out after the adapter has been connected for a few seconds, and controller connection attempts fail). This is due to TLP's USB autosuspend functionality, and the solution is to either disable the functionality entirely, or to add the Microsoft wireless adapter's device ID to this feature's blacklist (check [http://linrunner.de/en/tlp/docs/tlp-configuration.html#usb TLP configuration] for more details).}}
  
=== SteamOS xpad ===
+
==== SteamOS xpad ====
  
 
If you have issues with the default {{ic|xpad}} kernel module, you can install the SteamOS version, available in [[AUR]] {{AUR|steamos-xpad-dkms}}.
 
If you have issues with the default {{ic|xpad}} kernel module, you can install the SteamOS version, available in [[AUR]] {{AUR|steamos-xpad-dkms}}.
Line 89: Line 195:
 
Now, only a reboot is needed to make this work.
 
Now, only a reboot is needed to make this work.
  
=== xboxdrv with two controllers ===
+
==== xboxdrv with two controllers ====
  
 
xboxdrv supports a multitude of controllers, but it works only in [http://pingus.seul.org/~grumbel/xboxdrv/xboxdrv.html#idp147464 daemon mode].
 
xboxdrv supports a multitude of controllers, but it works only in [http://pingus.seul.org/~grumbel/xboxdrv/xboxdrv.html#idp147464 daemon mode].
Line 104: Line 210:
 
</nowiki>}}
 
</nowiki>}}
  
=== Mimic Xbox 360 controller ===
+
==== Mimic Xbox 360 controller with other controllers ====
  
 
xboxdrv can be used to make any controller register as an Xbox 360 controller with the {{ic|--mimic-xpad}} switch. This may be desirable for games that support Xbox 360 controllers out of the box, but have trouble detecting or working with other gamepads.
 
xboxdrv can be used to make any controller register as an Xbox 360 controller with the {{ic|--mimic-xpad}} switch. This may be desirable for games that support Xbox 360 controllers out of the box, but have trouble detecting or working with other gamepads.
Line 150: Line 256:
 
By default, xboxdrv outputs all events to the terminal. You can use this to test that the mappings are correct. Append the {{ic|--silent}} option to keep it quiet.
 
By default, xboxdrv outputs all events to the terminal. You can use this to test that the mappings are correct. Append the {{ic|--silent}} option to keep it quiet.
  
====Playstation 3 Controllers via USB====
+
=====Playstation 3 Controllers via USB=====
  
 
If you own a PS3 controller and can connect with USB, xboxdrv has the mappings built in. Just run the program (and detach the running driver) and it works!  
 
If you own a PS3 controller and can connect with USB, xboxdrv has the mappings built in. Just run the program (and detach the running driver) and it works!  
Line 156: Line 262:
 
  # xboxdrv --silent --detach-kernel-driver
 
  # xboxdrv --silent --detach-kernel-driver
  
====Playstation 3 Controllers via Bluetooth====
+
=====Playstation 3 Controllers via Bluetooth=====
  
 
{{Note|{{Pkg|bluez-plugins}} includes a sixaxis plugin that should replace the need for {{AUR|sixpair}}.  Simply [[start]] {{ic|bluetooth.service}}, plug the controller in via USB, and the plugin should program your PC's bluetooth address into the controller automatically.}}
 
{{Note|{{Pkg|bluez-plugins}} includes a sixaxis plugin that should replace the need for {{AUR|sixpair}}.  Simply [[start]] {{ic|bluetooth.service}}, plug the controller in via USB, and the plugin should program your PC's bluetooth address into the controller automatically.}}
Line 245: Line 351:
 
Have tons of fun.
 
Have tons of fun.
  
====Playstation 2 Adapter====
+
=====Playstation 2 Adapter=====
  
 
To fix the button mapping of PS2 dual adapters and mimic the Xbox controller you can run the following command:
 
To fix the button mapping of PS2 dual adapters and mimic the Xbox controller you can run the following command:
Line 255: Line 361:
 
       --mimic-xpad --silent
 
       --mimic-xpad --silent
  
====Logitech Dual Action====
+
=====Logitech Dual Action=====
  
 
The Logitech Dual Action gamepad has a very similar mapping to the PS2 pad, but some buttons and triggers need to be swapped to mimic the Xbox controller.
 
The Logitech Dual Action gamepad has a very similar mapping to the PS2 pad, but some buttons and triggers need to be swapped to mimic the Xbox controller.
Line 265: Line 371:
 
       --mimic-xpad --silent
 
       --mimic-xpad --silent
  
====Playstation 4 controller====
+
=====Playstation 4 controller=====
  
 
To fix the button mapping of PS4 controller you can use the following script with xboxdrv or try with the [https://github.com/chrippa/ds4drv ds4drv] program:
 
To fix the button mapping of PS4 controller you can use the following script with xboxdrv or try with the [https://github.com/chrippa/ds4drv ds4drv] program:
Line 286: Line 392:
 
     --silent                                        \                               
 
     --silent                                        \                               
 
     "$@"
 
     "$@"
 
==Setting up deadzones==
 
If you want to set up the deadzones of your analog input you have to do it separately for the xorg (for mouse and keyboard emulation) and the kernel driver (for gaming).
 
 
===Deadzones in Xorg===
 
Add a similar line into your {{ic|/etc/X11/xorg.conf.d/50-joystick.conf}} before the {{ic|EndSection}}:
 
Option "MapAxis1" "deadzone=1000"
 
1000 is the default value, but you can set anything between 0 and 30 000. To get the axis number see the "Testing Your Configuration" section of this article.
 
If you already have an option with a specific axis just type in the {{ic|1=deadzone=value}} at the end of the parameter separated by a space.
 
 
===Deadzones in the Kernel Driver===
 
The easiest way is using {{AUR|jstest-gtk-git}}. Select the controller you want to edit, then click the calibration button at the bottom of the dialog. You must set the CenterMin and CenterMax values for joysticks and analog sticks, RangeMin for triggers. Then use {{ic|jscal}} for to dump the new values into a shell script:
 
jscal -p /dev/input/jsX > jscal.sh # replace X with your joystick's number
 
chmod +x jscal.sh
 
 
Now you need to make a [[udev]] rule (for example {{ic|/etc/udev/rules.d and name it 85-jscal.rules}}) so the script will automatically run when you connect the controller:
 
SUBSYSTEM=="input", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="c268", ACTION=="add", RUN+="/usr/bin/jscal.sh"
 
To get the idVendor and idProduct use {{ic|udevadm info --attribute-walk --name /dev/input/jsX}}
 
 
Finally we must announce SDL our joystick device, or else it will just ignore these to use its own settings.
 
Add this to your {{ic|~/.bashrc}} :
 
export SDL_JOYSTICK_DEVICE=/dev/input/jsX
 
(Again, replace X to your device number.)
 
 
== Disable Joystick From Controlling Mouse ==
 
If you want to play games with your controller, you might want to disable gamepad control over mouse cursor.  To do this, edit /etc/X11/xorg.conf.d/50-joystick.conf so that it looks like this:
 
{{hc|/etc/X11/xorg.conf.d/50-joystick.conf |
 
Section "InputClass"
 
        Identifier "joystick catchall"
 
        MatchIsJoystick "on"
 
        MatchDevicePath "/dev/input/event*"
 
        Driver "joystick"
 
        Option "StartKeysEnabled" "False"      #Disable mouse
 
        Option "StartMouseEnabled" "False"      #support
 
EndSection}}
 
  
 
== Troubleshooting ==
 
== Troubleshooting ==
Line 329: Line 400:
  
 
More gentle solution is to [[#Disable Joystick From Controlling Mouse|Disable Joystick From Controlling Mouse]].
 
More gentle solution is to [[#Disable Joystick From Controlling Mouse|Disable Joystick From Controlling Mouse]].
 
=== Joystick sending keystrokes ===
 
 
A couple joystick to keystroke programs exist like {{AUR|rejoystick}} and {{AUR|qjoypad}}, both work well without the need for X.org configuration.
 
 
==== via X.org ====
 
 
This is a good solution for systems where restarting Xorg is a rare event because it's a static configuration loaded only on X startup. I use it on my media PC running XBMC controlled with Logitech Cordless RumblePad 2. Due to a problem with the d-pad (a.k.a. "hat") being recognized as another axis, I used to run [[Joy2key]] as a workaround. Since I upgraded to XBMC 11.0 and joy2key 1.6.3-1, this setup no longer worked for me. I ended up taking a more direct approach and let Xorg handle joystick events.
 
 
First, make sure you have {{Pkg|xf86-input-joystick}} installed. Then, create {{ic|/etc/X11/xorg.conf.d/51-joystick.conf}} like so:
 
{{bc|<nowiki>
 
Section "InputClass"
 
  Identifier "Joystick hat mapping"
 
  Option "StartKeysEnabled" "True"
 
  #MatchIsJoystick "on"
 
  Option "MapAxis5" "keylow=113 keyhigh=114"
 
  Option "MapAxis6" "keylow=111 keyhigh=116"
 
EndSection
 
</nowiki>}}
 
{{Note|The ''MatchIsJoystick "on"'' line doesn't seem to be required for this to work but you may want to uncomment it.}}
 
  
 
=== Joystick not recognized by all programs ===
 
=== Joystick not recognized by all programs ===

Revision as of 12:54, 8 May 2015

Joysticks can be a bit of a hassle to get working in Linux. Not because they are poorly supported, but simply because you need to determine which modules to load to get your joystick working, and it's not always very obvious!

Joystick Input Systems

Linux actually has 2 different input systems for Joysticks. The original 'Joystick' interface and the newer 'evdev' based one.

/dev/input/jsX maps to the 'Joystick' API interface and /dev/input/event* maps to the 'evdev' ones (this also includes other input devices such as mice and keyboards). Symbolic links to those devices are also available in /dev/input/by-id/ and /dev/input/by-path/ where the legacy 'Joystick' API has names ending with -joystick while the 'evdev' have names ending with -event-joystick.

Most new games will default to the 'evdev' interface as it gives more detailed information about the buttons and axes available and also adds support for force feedback.

While SDL1.x defaults to 'evdev' interface you can force it to use the old 'Joystick' API by setting the environment variable SDL_JOYSTICK_DEVICE=/dev/input/js0. This can help many games such as X3. SDL2.x supports only the new 'evdev' interface.

It's also worth mentioning that there is also a xorg driver xf86-input-joystick. It just allows you to control the mouse/keyboard in xorg using a joystick, for most people this will be undesirable. Disabling this behaviour is described below in Disable Joystick From Controlling Mouse, in most cases you can just remove this package though.

Determining which modules you need

Unless you're using very old joystick that uses gameport or proprietary USB protocol, you will need just the generic USB human interface device (HID) modules.

For an extensive overview of all joystick related modules in Linux, you will need access to the Linux kernel sources -- specifically the Documentation section. Unfortunately, pacman kernel packages do not include what we need. If you have the kernel sources downloaded, have a look at Documentation/input/joystick.txt. You can browse the kernel source tree at kernel.org by clicking the "cgit" (git frontend) link for the kernel that you're using, then clicking the "tree" link near the top. Here's a link to the Documentation from kernel 3.12.6.

Some joysticks need specific modules, such as the Microsoft Sidewinder controllers (sidewinder), or the Logitech digital controllers (adi). Many older joysticks will work with the simple analog module. If your joystick is plugging in to a gameport provided by your soundcard, you will need your soundcard drivers loaded - however, some cards, like the Soundblaster Live, have a specific gameport driver (emu10k1-gp). Older ISA soundcards may need the ns558 module, which is a standard gameport module.

As you can see, there are many different modules related to getting your joystick working in Linux, so I couldn't possibly cover everything here. Please have a look at the documentation mentioned above for details.

Loading the modules for analogue devices

You need to load a module for your gameport (ns558, emu10k1-gp, cs461x, etc...), a module for your joystick (analog, sidewinder, adi, etc...), and finally the kernel joystick device driver (joydev). Add these to your /etc/rc.conf, or simply modprobe them. The gameport module should load automatically, as this is a dependency of the other modules.

USB joysticks

You need to get USB working, and then modprobe your joystick driver, which is usbhid, as well as joydev. If you use a usb mouse or keyboard, usbhid will be loaded already and you just have to load the joydev module.

Testing Your Configuration

Once the modules are loaded, you should be able to find a new device: /dev/input/js0 and a file ending with -event-joystick in /dev/input/by-id directory. You can simply cat those devices to see if the joystick works - move the stick around, press all the buttons - you should see mojibake printed when you move the sticks or press buttons.

Both interfaces are also supported in wine and reported as separate devices. You can test them with wine control joy.cpl.

Joystick API

There are a lot of applications that can test this old API, jstest from the AUR joyutilsAUR package is the simplest one. If the output is unreadable because the line printed is too long you can also use graphical tools. KDE4 has a built in one in Input Devices panel in System Settings or the alternative AUR jstest-gtk-gitAUR application.

Use of jstest fairly simple, you just run jstest /dev/input/js0 and it will print a line with state of all the axes (normalised to {-32767,32767}) and buttons.

After you start Template:Is, it will just show you a list of joysticks available, you just need to select one and press Properties.

evdev API

The new 'evdev' API can be tested using the SDL2 joystick test application. Install sdl2-jstest-gitAUR and then run sdl2-jstest --test 0. Use sdl2-jstest --list to get IDs of other controllers if you have multiple ones connected.

Setting up deadzones and calibration

If you want to set up the deadzones (or remove them completely) of your analog input you have to do it separately for the xorg (for mouse and keyboard emulation), Joystick API and evdev API.

Xorg deadzones

Add a similar line into your /etc/X11/xorg.conf.d/50-joystick.conf before the EndSection:

Option "MapAxis1" "deadzone=1000"

1000 is the default value, but you can set anything between 0 and 30 000. To get the axis number see the "Testing Your Configuration" section of this article. If you already have an option with a specific axis just type in the deadzone=value at the end of the parameter separated by a space.

Joystick API deadzones

The easiest way is using jstest-gtk from jstest-gtk-gitAUR. Select the controller you want to edit, then click the Calibration button at the bottom of the dialog (don't click Start Calibration there). You can then set the CenterMin and CenterMax values (which control the center deadzone), RangeMin and RangeMax which control the end of throw deadzones. Note that the calibration settings are applied when the application opens the device, so you need to restart your game or test application to see updated calibration settings.

After you set the deadzones use jscal to dump the new values into a shell script:

jscal -p /dev/input/jsX > jscal.sh # replace X with your joystick's number 
chmod +x jscal.sh

Now you need to make a udev rule (for example /etc/udev/rules.d and name it 85-jscal.rules) so the script will automatically run when you connect the controller:

SUBSYSTEM=="input", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="c268", ACTION=="add", RUN+="/usr/bin/jscal.sh"

To get the idVendor and idProduct use udevadm info --attribute-walk --name /dev/input/jsX

Use the `/dev/input/by-id/*-joystick` device names in case you use multiple controllers.

evdev API deadzones

Currently there is no standalone application that allows changing calibration for evdev API, but there is G25manage distributed together with VDrift game that can change the center deadzone.

The easiest way to get it is to go to VDrift github, download all files in the folder and build them using make.

After that, you should be able to see your device configuration by using:

./G25manage --showcalibration /dev/input/by-id/usb-*-event-joystick

To change deadzones of any of the axes, you use the following command:

./G25manage --evdev /dev/input/by-id/usb-*-event-joystick --axis 0 --deadzone 0

Use udev rules file to set them automatically when the controller is connected.

Note that inside the kernel, the value is called flatness and is set using the EVIOCSABS ioctl.

Default configuration will look like similar to this:

./G25manage --showcalibration /dev/input/by-id/usb-Madcatz_Saitek_Pro_Flight_X-55_Rhino_Stick_G0000090-event-joystick 
Supported Absolute axes:
  Absolute axis 0x00 (0) (X Axis) (min: 0, max: 65535, flatness: 4095 (=6.25%), fuzz: 255)
  Absolute axis 0x01 (1) (Y Axis) (min: 0, max: 65535, flatness: 4095 (=6.25%), fuzz: 255)
  Absolute axis 0x05 (5) (Z Rate Axis) (min: 0, max: 4095, flatness: 255 (=6.23%), fuzz: 15)
  Absolute axis 0x10 (16) (Hat zero, x axis) (min: -1, max: 1, flatness: 0 (=0.00%), fuzz: 0)
  Absolute axis 0x11 (17) (Hat zero, y axis) (min: -1, max: 1, flatness: 0 (=0.00%), fuzz: 0)

While a more reasonable setting would be achieved with something like this (repeat for other axes):

./G25manage --evdev /dev/input/by-id/usb-Madcatz_Saitek_Pro_Flight_X-55_Rhino_Stick_G0000090-event-joystick --axis 0 --deadzone 512
Event device file: /dev/input/by-id/usb-Madcatz_Saitek_Pro_Flight_X-55_Rhino_Stick_G0000090-event-joystick
Axis index to deal with: 0
New dead zone value: 512
Trying to set axis 0 deadzone to: 512
  Absolute axis 0x00 (0) (X Axis) Setting deadzone value to : 512
(min: 0, max: 65535, flatness: 512 (=0.78%), fuzz: 255)

Disable Joystick From Controlling Mouse

If you want to play games with your controller, you might want to disable joystick control over mouse cursor. To do this, edit /etc/X11/xorg.conf.d/50-joystick.conf so that it looks like this:

/etc/X11/xorg.conf.d/50-joystick.conf 
Section "InputClass"
        Identifier "joystick catchall"
        MatchIsJoystick "on"
        MatchDevicePath "/dev/input/event*"
        Driver "joystick"
        Option "StartKeysEnabled" "False"       #Disable mouse
        Option "StartMouseEnabled" "False"      #support
EndSection

Using Joystick to send keystrokes

A couple joystick to keystroke programs exist like rejoystickAUR, qjoypadAUR or antimicro-qt4AUR, all work well without the need for X.org configuration.

via X.org

This is a good solution for systems where restarting Xorg is a rare event because it's a static configuration loaded only on X startup. I use it on my media PC running XBMC controlled with Logitech Cordless RumblePad 2. Due to a problem with the d-pad (a.k.a. "hat") being recognized as another axis, I used to run Joy2key as a workaround. Since I upgraded to XBMC 11.0 and joy2key 1.6.3-1, this setup no longer worked for me. I ended up taking a more direct approach and let Xorg handle joystick events.

First, make sure you have xf86-input-joystick installed. Then, create /etc/X11/xorg.conf.d/51-joystick.conf like so:

 Section "InputClass"
  Identifier "Joystick hat mapping"
  Option "StartKeysEnabled" "True"
  #MatchIsJoystick "on"
  Option "MapAxis5" "keylow=113 keyhigh=114"
  Option "MapAxis6" "keylow=111 keyhigh=116"
 EndSection
Note: The MatchIsJoystick "on" line doesn't seem to be required for this to work but you may want to uncomment it.


Specific devices

While most joysticks, especially USB based ones should just work, some may require (or give better results) if you use alternative drivers. If it doesn't work the first time, do not give up, and read those docs thoroughly!

Logitech Thunderpad Digital

Logitech Thunderpad Digital won't show all the buttons if you use the analog module. Use the device specific adi module for this controller.

PS3 controller

The Sixaxis gamepad works out of the box when plugged in via USB (the PS button will need to be pushed to begin), force feedback is backed since kernel 3.14.

Steam properly recognizes it as a PS3 pad and Big Picture can be launched with the PS button. Big Picture and some games may act as if it was a 360 controller. Gamepad control over mouse is on by default. You may want to turn it off before playing games, see below.

Xbox 360 controllers

The controllers should work without additional packages, but the wireless controller needs a wireless receiver (the charge-and-play cable can not be used for communicating with the controller). Both the wired controllers and the wireless receiver is supported by the xpad kernel module.

By default, the device associated with a controller (e.g., /dev/input/event14) will be owned root, part of the root group and will only allow its owner to read or write to it (i.e., 600). As a result, applications will not be able to use the controller unless they are run with superuser privileges. To amend this, create the following udev rule.

/etc/udev/rules.d/50-event.rules
KERNEL=="event*", GROUP="games", MODE="660"

This udev rule allows users that are a member the games group to use controllers.

Unfortunately, the default xpad driver has several issues with newer wired and wireless controllers:

The working solutions are using xboxdrvAUR, that is an alternative driver which works in userspace and could be launched as system service or using the Wikipedia:SteamOS patched version of xpad (steamos-xpad-dkmsAUR), that fixes those issues.

If you wish to use the controller for controlling the mouse, or mapping buttons to keys, etc. you should use the xf86-input-joystick package (configuration help can be found using man joystick). If the mouse locks itself in a corner, it might help changing the MatchDevicePath in /etc/X11/xorg.conf.d/50-joystick.conf from /dev/input/event* to /dev/input/js*.

Tip: If you use the TLP power management daemon, you may experience connection issues with your Microsoft wireless adapter (e.g. the indicator LED will go out after the adapter has been connected for a few seconds, and controller connection attempts fail). This is due to TLP's USB autosuspend functionality, and the solution is to either disable the functionality entirely, or to add the Microsoft wireless adapter's device ID to this feature's blacklist (check TLP configuration for more details).

SteamOS xpad

If you have issues with the default xpad kernel module, you can install the SteamOS version, available in AUR steamos-xpad-dkmsAUR.

Before installing it, make sure you have DKMS installed and running.

Then, install the modified kernel module steamos-xpad-dkmsAUR from the AUR, during the installation you'll see that new xpad kernel module is strapped to your current kernel:

Creating symlink /var/lib/dkms/steamos-xpad-dkms/0.1/source ->
                 /usr/src/steamos-xpad-dkms-0.1
 
DKMS: add completed.
 
Kernel preparation unnecessary for this kernel.  Skipping...
 
Building module:
cleaning build area....
make KERNELRELEASE=3.12.8-1-ARCH KVERSION=3.12.8-1-ARCH....
cleaning build area....

Now, only a reboot is needed to make this work.

xboxdrv with two controllers

xboxdrv supports a multitude of controllers, but it works only in daemon mode. The simplest way is launch xboxdrv as service in daemon mode:

ExecStart = /usr/bin/xboxdrv -D -c /etc/conf.d/xboxdrv

And add support of the second controller in config file:

 [xboxdrv]
 silent = true
 next-controller = true
 [xboxdrv-daemon]
 dbus = disabled

Mimic Xbox 360 controller with other controllers

xboxdrv can be used to make any controller register as an Xbox 360 controller with the --mimic-xpad switch. This may be desirable for games that support Xbox 360 controllers out of the box, but have trouble detecting or working with other gamepads.

First, you need to find out what each button and axis on the controller is called. You can use evtest for this. Run evtest and select the device event ID number (/dev/input/event*) that corresponds to your controller. Press the buttons on the controller and move the axes to read the names of each button and axis.

Here is an example of the output:


Event: time 1380985017.964843, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003
Event: time 1380985017.964843, type 1 (EV_KEY), code 290 (BTN_THUMB2), value 1
Event: time 1380985017.964843, -------------- SYN_REPORT ------------
Event: time 1380985018.076843, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003
Event: time 1380985018.076843, type 1 (EV_KEY), code 290 (BTN_THUMB2), value 0
Event: time 1380985018.076843, -------------- SYN_REPORT ------------
Event: time 1380985018.460841, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
Event: time 1380985018.460841, type 1 (EV_KEY), code 289 (BTN_THUMB), value 1
Event: time 1380985018.460841, -------------- SYN_REPORT ------------
Event: time 1380985018.572835, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
Event: time 1380985018.572835, type 1 (EV_KEY), code 289 (BTN_THUMB), value 0
Event: time 1380985018.572835, -------------- SYN_REPORT ------------
Event: time 1380985019.980824, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90006
Event: time 1380985019.980824, type 1 (EV_KEY), code 293 (BTN_PINKIE), value 1
Event: time 1380985019.980824, -------------- SYN_REPORT ------------
Event: time 1380985020.092835, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90006
Event: time 1380985020.092835, type 1 (EV_KEY), code 293 (BTN_PINKIE), value 0
Event: time 1380985020.092835, -------------- SYN_REPORT ------------
Event: time 1380985023.596806, type 3 (EV_ABS), code 3 (ABS_RX), value 18
Event: time 1380985023.596806, -------------- SYN_REPORT ------------
Event: time 1380985023.612811, type 3 (EV_ABS), code 3 (ABS_RX), value 0
Event: time 1380985023.612811, -------------- SYN_REPORT ------------
Event: time 1380985023.708768, type 3 (EV_ABS), code 3 (ABS_RX), value 14
Event: time 1380985023.708768, -------------- SYN_REPORT ------------
Event: time 1380985023.724772, type 3 (EV_ABS), code 3 (ABS_RX), value 128
Event: time 1380985023.724772, -------------- SYN_REPORT ------------

In this case, BTN_THUMB, BTN_THUMB2 and BTN_PINKIE are buttons and ABS_RX is the X axis of the right analogue stick. You can now mimic an Xbox 360 controller with the following command:

$ xboxdrv --evdev /dev/input/event* --evdev-absmap ABS_RX=X2 --evdev-keymap BTN_THUMB2=a,BTN_THUMB=b,BTN_PINKIE=rt --mimic-xpad

The above example is incomplete. It only maps one axis and 3 buttons for demonstration purposes. Use xboxdrv --help-button to see the names of the Xbox controller buttons and axes and bind them accordingly by expanding the command above. Axes mappings should go after --evdev--absmap and button mappings follow --evdev-keymap (comma separated list; no spaces).

By default, xboxdrv outputs all events to the terminal. You can use this to test that the mappings are correct. Append the --silent option to keep it quiet.

Playstation 3 Controllers via USB

If you own a PS3 controller and can connect with USB, xboxdrv has the mappings built in. Just run the program (and detach the running driver) and it works!

# xboxdrv --silent --detach-kernel-driver
Playstation 3 Controllers via Bluetooth
Note: bluez-plugins includes a sixaxis plugin that should replace the need for sixpairAUR. Simply start bluetooth.service, plug the controller in via USB, and the plugin should program your PC's bluetooth address into the controller automatically.

To make the Playstation 3 controller work over bluetooth you will need to install the sixpairAUR utility.

After installing sixpair connect your controller with an USB cable and run sixpair

# sixpair

Disconnect your controller from USB and wait about 5 minutes (not sure if really needed)

Now you will need to pair it with bluez. You will need bluez-utils and bluez-plugins packages.

Disable all bluetooth utilities (like bluedevil or bluemon)

Run the bluetoothctl utility

# bluetoothctl

A bluetooth prompt will appear.

Press the playstation button and watch for connection and disconnection messages and copy the device address (something like 38:C0:96:56:4D:AA)

Wait for the lights stop blinking.

Now, type the following:

agent on
default-agent
discoverable on
pairable on

Hit the playstation button again and while it blinks type the following

connect <device_addr>

Keep trying this command if you see device not available (it will loop between connected and disconnected) until you see something like the following

I usually keep pressing up + enter (repeating the last command)

[CHG] Device <device_addr> Modalias: usb:v054Cp0268d0100
[CHG] Device <device_addr> UUIDs:
       00001124-0000-1000-8000-00805f9b34fb
       00001200-0000-1000-8000-00805f9b34fb

Now trust the device

trust <device_addr>

You're done

Next time you hit the Playstation button it will connect without asking anything else.

You can also re-enable your bluetooth applets/monitors.

Just remind to disconnect the device once you are done, once it will stay connected, on and consuming battery.

If you intend to use the xboxdrv to emulate the xbox360 controller its best to create a udev rule for it

Creating the udev rule

Create a new udev rule with the following content:

/etc/udev/rules.d/99-dualshock.rules
KERNEL=="event*", SUBSYSTEM=="input", ATTRS{uniq}=="<device_addr_you_got_on_pairing>", SYMLINK+="input/dualshock3"

The address must be in lowercase, like 06:9a:b4:c8:ef:8b.

Now run xboxdrv over the new device:

xboxdrv --evdev /dev/input/dualshock3 --mimic-xpad

If the mimic-xpad does not work, use the configuration file provided by xboxdrv, adding the following in the xboxdrv section:

mimic-xpad = true

…and replacing the evdev line by:

evdev = /dev/input/dualshock3 (or whatever other name you gave in the udev_rule)

Now, just run xboxdrv:

# xboxdrv -c config_file

Have tons of fun.

Playstation 2 Adapter

To fix the button mapping of PS2 dual adapters and mimic the Xbox controller you can run the following command:

 sudo xboxdrv --evdev /dev/input/event* \
     --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_RZ=x2,ABS_Z=y2,ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y \
     --axismap -Y1=Y1,-Y2=Y2 \
     --evdev-keymap   BTN_TOP=x,BTN_TRIGGER=y,BTN_THUMB2=a,BTN_THUMB=b,BTN_BASE3=back,BTN_BASE4=start,BTN_BASE=lb,BTN_BASE2=rb,BTN_TOP2=lt,BTN_PINKIE=rt,BTN_BASE5=tl,BTN_BASE6=tr \
     --mimic-xpad --silent
Logitech Dual Action

The Logitech Dual Action gamepad has a very similar mapping to the PS2 pad, but some buttons and triggers need to be swapped to mimic the Xbox controller.

 sudo xboxdrv --evdev /dev/input/event* \
     --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_RZ=x2,ABS_Z=y2,ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y \
     --axismap -Y1=Y1,-Y2=Y2 \
     --evdev-keymap BTN_TRIGGER=x,BTN_TOP=y,BTN_THUMB=a,BTN_THUMB2=b,BTN_BASE3=back,BTN_BASE4=start,BTN_BASE=lt,BTN_BASE2=rt,BTN_TOP2=lb,BTN_PINKIE=rb,BTN_BASE5=tl,BTN_BASE6=tr \
     --mimic-xpad --silent
Playstation 4 controller

To fix the button mapping of PS4 controller you can use the following script with xboxdrv or try with the ds4drv program:

 #!/bin/bash                                                                          
 sudo xboxdrv  \                                                                      
   --evdev /dev/input/by-id/usb-Sony_Computer_Entertainment_Wireless_Controller-event-joys>
   --evdev-absmap ABS_X=x1,ABS_Y=y1                 \                               
   --evdev-absmap ABS_Z=x2,ABS_RZ=y2                \                               
   --evdev-absmap ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y \                               
   --evdev-keymap BTN_A=x,BTN_B=a                   \                               
   --evdev-keymap BTN_C=b,BTN_X=y                   \                               
   --evdev-keymap BTN_Y=lb,BTN_Z=rb                 \                               
   --evdev-keymap BTN_TL=lt,BTN_TR=rt               \
   --evdev-keymap BTN_SELECT=tl,BTN_START=tr        \                               
   --evdev-keymap BTN_TL2=back,BTN_TR2=start        \                               
   --evdev-keymap BTN_MODE=guide                    \                               
   --axismap -y1=y1,-y2=y2                          \                               
   --mimic-xpad                                     \                               
   --silent                                         \                               
   "$@"

Troubleshooting

Joystick moving mouse

Sometimes USB joystick can be recognized as HID mouse (only in X, it is still being installed as /dev/input/js0 as well). Known issue is cursor being moved by the joystick, or escaping to en edge of a screen right after plugin. If your application can detect joystick by it self, you can remove xf86-input-joystick package.

More gentle solution is to Disable Joystick From Controlling Mouse.

Joystick not recognized by all programs

Some software, Steam for example, will only recognize the first joystick it encounters. Due to a bug in the driver for Microsoft wireless periphery devices this can in fact be the bluetooth dongle. If you find you have a /dev/input/js* and /dev/input/event* belonging to you keyboard's bluetooth transceiver you can get automatically get rid of it by creating according udev rules. Create a /:

/etc/udev/rules.d/99-btcleanup.rules
ACTION=="add", KERNEL=="js[0-9]*", SUBSYSTEM=="input", KERNELS=="...", ATTRS{bInterfaceSubClass}=="00", ATTRS{bInterfaceProtocol}=="00", ATTRS{bInterfaceNumber}=="02", RUN+="/usr/bin/rm /dev/input/js%n"
ACTION=="add", KERNEL=="event*", SUBSYSTEM=="input", KERNELS=="...", ATTRS{bInterfaceSubClass}=="00", ATTRS{bInterfaceProtocol}=="00", ATTRS{bInterfaceNumber}=="02", RUN+="/usr/bin/rm /dev/input/event%n"

Correct the KERNELS=="..." to match your device. The correct value can be found by running

# udevadm info -an /dev/input/js0

Assuming the device in question is /dev/input/js0. After you placed the rule reload the rules with

# udevadm control --reload

Then replug the device making you trouble. The joystick and event devices should be gone, although their number will still be reserved. But the files are out of the way.