git: 17391201101f - main - games/flightgear: Improve joystick hat management
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 12 Apr 2023 10:57:29 UTC
The branch main has been updated by martymac: URL: https://cgit.FreeBSD.org/ports/commit/?id=17391201101f313c2c9049fea8e336acfee43d92 commit 17391201101f313c2c9049fea8e336acfee43d92 Author: Stephen Hurd <shurd@FreeBSD.org> AuthorDate: 2023-04-12 10:47:02 +0000 Commit: Ganael LAPLANCHE <martymac@FreeBSD.org> CommitDate: 2023-04-12 10:52:33 +0000 games/flightgear: Improve joystick hat management Do not hardcode the hatmap but derive values from HID data (based on HID1.1 spec), and if the HID data is unexpected, fall back to the old values. That patch fixes support for Logitech Extreme 3D Pro joystick's hat. PR: 270676 Reported by: shurd Tested by: shurd --- games/flightgear/Makefile | 1 + .../files/patch-3rdparty-joystick-jsBSD.cxx | 77 +++++++++++++++++++++- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/games/flightgear/Makefile b/games/flightgear/Makefile index 5a0068fb1d08..f955cf419c59 100644 --- a/games/flightgear/Makefile +++ b/games/flightgear/Makefile @@ -1,5 +1,6 @@ PORTNAME= flightgear PORTVERSION= 2020.3.18 +PORTREVISION= 1 CATEGORIES= games MASTER_SITES= SF/flightgear/release-${PORTVERSION:R} diff --git a/games/flightgear/files/patch-3rdparty-joystick-jsBSD.cxx b/games/flightgear/files/patch-3rdparty-joystick-jsBSD.cxx index 115d2bd2db8b..299a4933f9c7 100644 --- a/games/flightgear/files/patch-3rdparty-joystick-jsBSD.cxx +++ b/games/flightgear/files/patch-3rdparty-joystick-jsBSD.cxx @@ -1,4 +1,4 @@ ---- 3rdparty/joystick/jsBSD.cxx.orig 2020-05-28 21:56:43 UTC +--- 3rdparty/joystick/jsBSD.cxx.orig 2023-04-07 17:57:15 UTC +++ 3rdparty/joystick/jsBSD.cxx @@ -52,6 +52,7 @@ #include <sys/param.h> @@ -8,3 +8,78 @@ #include <string.h> #include <errno.h> #include <sys/ioctl.h> +@@ -198,6 +199,8 @@ static int joy_initialize_hid(struct os_specific_s *os + interesting_hid = TRUE; + if (page == HUP_GENERIC_DESKTOP) + { ++ int range; ++ int matched; + switch(usage) { + case HUG_X: + case HUG_RX: +@@ -221,6 +224,65 @@ static int joy_initialize_hid(struct os_specific_s *os + (*num_axes)++; + os->axes_usage[*num_axes] = usage; + (*num_axes)++; ++ } ++ range = h.logical_maximum - h.logical_minimum + 1; ++ matched = 0; ++ if (((h.logical_minimum == 0) || (h.logical_minimum == 1)) && (h.unit == HUM_DEGREE) && (h.unit_exponent == 0) && ((range == 4) || (range == 8))) { ++ int resolution = (h.physical_maximum - h.physical_minimum) / (h.logical_maximum - h.logical_minimum); ++ for (int i = h.logical_minimum; i <= h.logical_maximum; i++) { ++ const int degrees = (i - h.logical_minimum) * resolution + h.physical_minimum; ++ switch (degrees) { ++ case 0: ++ hatmap_x[i] = 0; ++ hatmap_y[i] = -1; ++ matched++; ++ break; ++ case 45: ++ hatmap_x[i] = 1; ++ hatmap_y[i] = -1; ++ matched++; ++ break; ++ case 90: ++ hatmap_x[i] = 1; ++ hatmap_y[i] = 0; ++ matched++; ++ break; ++ case 135: ++ hatmap_x[i] = 1; ++ hatmap_y[i] = 1; ++ matched++; ++ break; ++ case 180: ++ hatmap_x[i] = 0; ++ hatmap_y[i] = 1; ++ matched++; ++ break; ++ case 225: ++ hatmap_x[i] = -1; ++ hatmap_y[i] = 1; ++ matched++; ++ break; ++ case 270: ++ hatmap_x[i] = -1; ++ hatmap_y[i] = 0; ++ matched++; ++ break; ++ case 315: ++ hatmap_x[i] = -1; ++ hatmap_y[i] = -1; ++ matched++; ++ break; ++ } ++ } ++ if (matched == range) { ++ if (h.logical_minimum == 0) { ++ hatmap_x[h.logical_maximum + 1] = 0; ++ hatmap_y[h.logical_maximum + 1] = 0; ++ } else { ++ hatmap_x[0] = 0; ++ hatmap_y[0] = 0; ++ } ++ } + } + break; + default: