Approvals: 0/1
This is an old revision of the document!
Diagnose Joysticks Issues
Physical joystick ←→ linux driver ←→ linux events stack ←A→ SDL2 library ←B→ EmulationStation
From your joystick to the batocera interface (EmulationStation), there are several technical steps. In case of issues, there are 2 mains tools, evtest and sdl2-jstest
evtest acts on point A to analyse linux events while sdl2-jstest acts on point B to analyse events going to EmulationStation.
evtests
events in the linux kernel are the way to handle mouses, keyboards, joysticks, etc… sdl2 is a library to help to code program compatible with linux, windows, mac os x, … it converts linux events to a common way to define events. On linux, events are define in /usr/include/linux/input-event-codes.h. For example, the button “yellow” if your joystick has one is :
#define KEY_YELLOW 0x190 (1*16*16 + 9*16 + 0 = 400)
On Windows, possibly that this button is not defined, or at least, for sure, with an other value, while on Linux, the value is arbitrary. Thus, SDL doesn't use the code. Instead, SDL uses button numbers, thus, this button may be “BUTTON 1”.
Let's see an example :
- Connect via ssh to batocera
- run evtest to check that linux sees your joysticks :
In my case, i've only 1 joystick plugged, it displays :
# evtest No device specified, trying to scan all of /dev/input/event* Available devices: /dev/input/event0: Bigben Interactive Bigben Game Pad Select the device event number [0-0]:
Press 0 to see linux events on this joystick. In my case, when i press one button (button BTN_C), it displays :
Event: time 1492442283.255053, type 1 (EV_KEY), code 306 (BTN_C), value 1 Event: time 1492442283.255053, type 1 (EV_KEY), code 306 (BTN_C), value 0
value 1 is when the button is pressed. value 0 is when the buton is released.
Some general information, like the list of buttons available are provided by :
evtest --info /dev/input/event0 udevadm info -q all -n /dev/input/event0
sdl2-jstest
- run sdl2-jstest –list to check what emulationstation sees when you press buttons
In my case, it displays :
# export DISPLAY=:0.0 # sdl2-jstest --list Found 1 joystick(s) Joystick Name: 'Bigben Interactive Bigben Game Pad' Joystick Path: '/dev/input/event0' Joystick GUID: 030000006b1400000209000011010000 Joystick Number: 0 Number of Axes: 4 Number of Buttons: 13 Number of Hats: 1 ... Button code 0: 304 Button code 1: 305 Button code 2: 306 ...
To see the events, run sdl2-jstest -e 0 (0 is the joystick number) When I press C, it displays :
... SDL_JOYBUTTONDOWN: joystick: 0 button: 2 state: 1 code:306 SDL_JOYBUTTONUP: joystick: 0 button: 2 state: 0 code:306 ...
- diagnose_joysticks_issues.1580241063.txt.gz
- Last modified: 4 years ago
- by genetik57