Hi guys. Maybe I can shed some light on this. @voljega notified me of this thread... I speak no word of french (exept maybe merci ;), but Google helped so much to understand, but I choose to answer in english if you don't mind...
First thing to note is there there are (at least) two different ways to access joysticks in Linux:
- the joydev joystick driver and API, with devices
/dev/input/js*
, which is what you used here. This is configured using jscal and friends. - and the raw event devices,
/dev/input/event*
. It's not clear to me if this is configurable. Some sources say it's just raw events, not configurable, the Archwiki @voljega linked seems to suggest you can configure/calibrate them...). Otherwise the apps or SDL would have to take care of that. No idea if SDL has any support for this.
So what do we have?
-
the coefficients you modified for jscal at pretty much wrong. When I take the initial line from @ironic:
jscal -s 6,1,16,-128,128,16513,16513,1,16,-128,128,16513,16513,1,16,-128,128,16513,16513,1,16,-128,128,16513,16513,1,0,0,0,536870912,536870912,1,0,0,0,536870912,536870912 /dev/input/js0
then the coefficents of the first axis are:
-128,128,16513,16513
. As you figured out the first two are the borders of the deadzone. But they have to stay in the input range, i.e. between 0..255. So changing them to 8000 or whatever is likely just plain wrong. The other two are actually scaling factors, mapping the remaining input range to the entire output range (-32767..0, 0..32767). You can not simply change them, but you have to actually calculate them, taking into account the actual input range minus deadzone. -
if you want to test these changes you should use
jstest
. If you want to verify how things behave in SDL apps you can usesdl-jstest/sdl2-jstest
, for SDL 1 and 2 respectively. -
as for making the values persistent, you should use some udev magic. Relying on the generic device is likely to fail sooner or later, as they are just numbered by the OS as they are detected or plugged in. If at all, you should use the named devices
/dev/input/by-id/usb-Foo_Bar-joystick
. And the init script won't work if you plug in the device later on. The debian joystick package (used in Raspbian or Retropie) also shipsjscal-store/-restore
, which take of the udev magic. But they are not available on Recalbox. -
somehow something else seems wrong on Recalbox as jscal button mapping is broken:
# jscal -q /dev/input/js0 "jscal: error getting axis map: Success"
The other thing is, as I just found out, that the joydev driver devices (js0) are ignored by SDL1 and SDL2 (and thus programs like dosbox) on Recalbox. See https://forum.recalbox.com/post/75291
For SDL1 you can override the default device and work around this with export SDL_JOYSTICK_DEVICE=/dev/input/js0
. If you do that then sdl-jstest
should give you the results you expect, same as jstest
. Otherwise you only get the erratic, uncalibrated default behaviour.
For SDL2 however this does not work. It just ignores this variable. As dosbox on Recalbox uses SDL2 your jscal based calibration will never end up there. It will always use the erratic, uncalibrated default.
The open questions are:
- can SDL2 be compile configured to obey SDL_JOYSTICK_DEVICE?
- can SDL2 be compile configured to default to joydev driver devices (js*)?
- can the raw event devices be calibrated (as the archwiki page suggests)? At least the tools are not available in Recalbox.
So yea, I guess we are stuck the way things currently are. No calibration for Dosbox (or any other SDL2 based apps, ScummVM? uae4arm/amiberry?).
Btw: what is this blue program? I couldn't find a "Recalbox Joystick/Gamepad Utility" anywhere...