A device file is a filesystem entry that gives software a file-like interface to hardware or a kernel device driver. On Unix systems, connected joysticks appear automatically as device files such as /dev/input/js0, /dev/input/js1, and /dev/input/js2. section 7.5.1
Device files make hardware discovery and event inspection straightforward:
- List joystick device files with ls /dev/input/js*. section 7.5.1
- Use the device-file path with jstest to inspect live button and axis events. section 7.5.1
- Map numeric button and axis identifiers to controls in an application. section 7.5.1
Inspecting a controller
After locating /dev/input/js0, run jstest /dev/input/js0. The terminal reports detected axes and buttons, then updates their values as controls are pressed or moved. section 7.5.1
$ ls /dev/input/js* /dev/input/js0
Use this listing to discover the joystick device path before reading its events. section 7.5.1
