If you want to read the raw joystick you have two basic options:
- Read the old
/dev/js0
(or/dev/input/js0
) device with joystick events. - Find the relevant new
/dev/input/event*
device and read generic input events.
You can find examples of both easily on the Internet. Or you can use the source (joydev.c, input.c)!
For quick testing, many distributions have the input-utils
package. Its source code will be most enlightening.
QUICK LINK:
See for example the tutorial here. The basics are:
- Open the device
/dev/input/event*
, withopen()
. - Use the
ioctl()
system call with theEVIO*
codes to identify the device. - Read the events with
read()
intoinput_event
structs. - Identify the interesting events and use them!
As I said before, it will be most useful to run the input-events
util from the console, to see the input events as your program will receive them.