peripheral.joystick
peripheral.joystick copied to clipboard
fix axis when not aligned on 0
Thanks for the collection of PRs! I'll review as soon as time allows.
for information, patches are from here : https://github.com/batocera-linux/batocera.linux/tree/master/board/batocera/patches/kodi-peripheral-joystick i did them initially cause people having trouble on batocera
I see you also include https://github.com/xbmc/peripheral.joystick/pull/251. I'll make sure to get this reviewed too (sorry for the long delay!)
don't worry for the delay. i've the patches system on my side :-) i took a long time before doing the pr too. don't hesitate if you've questions
oh and i forgot the most important ! thanks a lot for peripheral.joystick. it is an important project for batocera.linux, because we deal with automatic joystick configuration and all go throw udev.
@nadenislamarre Can you rebase on the Omega
branch after https://github.com/xbmc/peripheral.joystick/pull/280? I think it's time to get your udev patches in.
There seems to be a degenerate commit in your math.
You have:
SetAxisValue(axisIndex, event.value - middle, length);
and:
SetAxisValue(axisIndex, -(middle - event.value), length);
But you can transform the second to equal the first because event.value - middle
== -(middle - event.value)
Or am I wrong?
for information, patches are from here : https://github.com/batocera-linux/batocera.linux/tree/master/board/batocera/patches/kodi-peripheral-joystick i did them initially cause people having trouble on batocera
Hi. Sorry to bother here, but saw you are pretty active on wiimote dev, at least on linux, but this one is for Windows 🗡️ We are scratching our heads here to add calibration support to wiimote through touchmote. Also we have some problems with screen top and below reach. https://github.com/simphax/Touchmote/issues/65
If you could bring us any ideas, it will be welcome. Trying to achieve some wiimote lightgun improvements on windows. Thanks.
@Trihy don't hesitate to join the batocera discord to discuss with me or the man who did the windows lightgun support for the wiimote on this projet : https://github.com/fabricecaruso/WiimoteGun
Merged with a fix for the degenerative math in 6a8810705043b4656aaa03d32a8bc574e1d3049b.
Simplified Patch
The transformation mentioned in the PR conversation shows that event.value - middle
and -(middle - event.value)
are equivalent. Thus, we can simplify the code by using absolute values.
Explanation of the resulting patch
- We calculate the middle and length of the axis range as before.
- We use
std::abs(event.value - middle)
to get the absolute difference between the event value and the middle of the axis range. - If this difference is greater than half the length of the axis range, we adjust the axis value relative to the middle.
- Otherwise, we set the axis value to 0, indicating it's within the dead zone.
Let me know if that looks correct!