Re: [RFC PATCH 0/2] Input: adc-joystick: add detachable devices support

From: Paul Cercueil
Date: Sat Nov 05 2022 - 19:47:01 EST


Hi Siarhei,

Le lun. 31 oct. 2022 à 22:01:57 +0300, Siarhei Volkau <lis8215@xxxxxxxxx> a écrit :
For detachable or lock-able joysticks the ADC lanes might
be biased to GND or AVDD when the joystick is detached/locked.

One such kind of joystick is found in the Ritmix RZX-50 handheld.
The joystick is non-detachable, although ADC lane biased to power
supply when the "Hold" switch is activated.

But the RZX-50 has no joystick...
Or is the d-pad actually wired to the ADC instead of GPIOs?

To avoid reporting old/broken measurements valid-range is introduced.
When measured value is outside valid-range the driver reports
safe center position for corresponding axis.

First of all, you already have a "valid range", it is called "abs-range"; no need for a new one.

Then, the driver has no business doing events filtering. Notice that when you activate the "hold" button and your joystick values go way off-range, you still get input events in userspace: that's because the kernel is not responsible for enforcing the deadzone, the userspace is.

In your case, you need to update your userspace applications/libraries so that when the joystick values are way off-range, the assumed position is the center.

Cheers,
-Paul