I want to calibrate a joystick (custom hardware) with no buttons and only one axis (Z). I used evtest to read the movement range i.e. min/max values and the centre (the point where the joystick rests), which is approximately in the middle of that range: [min, centre, max] = [2028, 3228, 4225].
I used then evdev-joystick --e to apply these min/max values and fuzz = 100 just for testing purposes (no idea how to apply the deadzone value, is that the point where the value should return 0? in my case 3228? evdev-joystick shows some percentage but I don't get what it means, ignore everything under that deadzone value? That is not what I would expect though... a deadzone should consist of two values around the centre, right? or at least some percentage around the centre).
When I run evtest again, the summary shows the new values I set with evdev-joystick, but only the fuzz value seems to have any effect. If I set min/max values within the movement range, I can get events outside of that new range. I tried different values for the deadzone (0, 3228, almost the max value...) with no effect at all. I expected some range or centre correction but it looks like evtest is ignoring the calibration (apart from fuzz, I do not get consecutive values within the fuzz range) even though it displays it at the beginning.
Is evtest supposed to ignore the min/max/deadzone calibration and deliver raw values? Should I test the calibration with a different tool? I can only use command line tools by the way.
I have also tried the old Joystick API with jstest and jscal, which actually looks much better than the new one in the sense that jscal offers interactive calibration where the min/max/centre/fuzz values are automatically saved and the calibration can be tested with jstest and the original range gets corrected to [-32767, 0, 32767]. Unfortunately I am only allowed to use the evdev API because of some concerns about the old Joystick API getting removed altogether at some point in the near future.
**Edit:** I dove into the tools' code and they make use of the input_absinfo struct located in the input.h uapi, where there is the following note:
* Note that input core does not clamp reported values to the
* [minimum, maximum] limits, such task is left to userspace.
So the evtest tool is not doing that clamping and therefore no range correction. But the flat definition in that file is still ambiguous:
* @flat: values that are within this value will be discarded by
* joydev interface and reported as 0 instead.
Values within this value?? Joydev interface? is that not part of the old API?
**Edit 2:** it seems that the old jstest tool displays the corrected values because it relies on the joydev device driver, which calculates the correction coefficients and does the clamping. Evtest does not use joydev and hence the "raw" values. What is the way to go after the calibration then? I have seen there is an SDL2 library that some games use. Will I get the functionality joydev delivers (dead zones, clamping) with that library after the calibration with evdev-joystick? I have also seen that SDL has some testing tools, but none of them seem to be command line tools to use on my embedded system so I could not get any further so far.
Asked by ldd3
(71 rep)
Feb 16, 2023, 07:38 AM
Last activity: Feb 27, 2023, 08:07 AM
Last activity: Feb 27, 2023, 08:07 AM