Lakka-LibreELEC/projects/L4T/devices/Switch/patches/peripheral.joystick/02-fix-axis-when-not-aligned-on-0.patch
GavinDarkglider 6fb5ad6fee
Cleanups, More LibreELEC Stuff, more permission fixes, Misc switch stuff. (#1930)
* libCEC: Update to 6.0.2

* L4T: Switch-bsp: Fix typos

* Switch: Fix all permission issues with running kodi as a non-root user.

* L4T: Switch: Minor code cleanups

* Add upower and libgudev so kodi can get battery stats

Upower was removed from libreELEC in 2013 with this commit: 3a130cd5009c8d3595b8afcde2421324572ce58b
This was a stupid choice as it is the only option in kodi for supplying any battery statitistics. Currently broken.
This patchset: https://github.com/xbmc/xbmc/pull/17327/commits for kodi seemingliy wants to fix the issue(Doesnt, is more of a new way to deal with dbus in general), but will still require that upower be available for battery.

* Switch: LibreELEC: Peripheral.Joystick: Fix Add Patches from PR's upstream to fix issues with udev devices

* Switch: LibreElec: Peripheral.Joystick: Add Nintendo Switch udev joystick mappings

* Switch: LibreELEC: Peripheral.Joystick: Force Udev controller driver as default.
2024-02-17 18:33:15 +02:00

37 lines
1.5 KiB
Diff

From 3f76122bbe2ec31b75c78558ca8dca84d042ca12 Mon Sep 17 00:00:00 2001
From: Nicolas Adenis-Lamarre <nicolas.adenis.lamarre@gmail.com>
Date: Wed, 28 Jun 2023 05:18:19 +0000
Subject: [PATCH] fix axis when not aligned on 0
Signed-off-by: Nicolas Adenis-Lamarre <nicolas.adenis.lamarre@gmail.com>
---
src/api/udev/JoystickUdev.cpp | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/api/udev/JoystickUdev.cpp b/src/api/udev/JoystickUdev.cpp
index 3c0c6113..ce088156 100644
--- a/src/api/udev/JoystickUdev.cpp
+++ b/src/api/udev/JoystickUdev.cpp
@@ -217,10 +217,17 @@ bool CJoystickUdev::ScanEvents(void)
const unsigned int axisIndex = it->second.axisIndex;
const input_absinfo& info = it->second.axisInfo;
- if (event.value >= 0)
- SetAxisValue(axisIndex, event.value, info.maximum);
- else
- SetAxisValue(axisIndex, event.value, -info.minimum);
+ int middle = (info.minimum+info.maximum)/2;
+ int length = (info.maximum-info.minimum)/2;
+
+ if (event.value >= middle && event.value-middle > length/2) {
+ SetAxisValue(axisIndex, event.value-middle, length);
+ }
+ else if (event.value <= middle && middle-event.value > length/2) {
+ SetAxisValue(axisIndex, -(middle-event.value), length);
+ } else {
+ SetAxisValue(axisIndex, 0, length);
+ }
}
}
break;