Joystick API vs evdev API

From Free Knowledge Base- The DUCK Project: information for everyone
Jump to: navigation, search

Linux has two different input systems for Joysticks – the original Joystick interface and the newer evdev-based interface.

evdev (short for 'event device') is a generic input event interface in the Linux kernel and FreeBSD. Input events are available through character devices in the /dev/input/ directory, because In UNIX Everything is a File which also holds true mostly for Linux. Libevdev abstracts the evdev ioctls through type-safe interfaces and provides functions to change the appearance of the device. Although you can use libevdev library instead of using traditional ioctl calls as this library provided simpler higher-level access to the evdev API. SteamOS uses evdev Joystick input.

  • /dev/input/eventXX

The path with the event node maps to the evdev input system as well as 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.

There are a lot of applications that can test the legacy Joystick API (rather than evdev) such as jstest from the joyutils package. Use of jstest is 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 jstest-gtk, it will just show you a list of joysticks available.

You can use a program called 'evtest' to test evdev joysticks or you can use SDL2 and run sdl2-jstest --test 0. Use sdl2-jstest --list to get IDs of other controllers.