From be0d9e8a569b8bbb07acac0bccf2c04df6f984cc Mon Sep 17 00:00:00 2001 From: Jochen Heizmann Date: Sat, 21 Jun 2025 11:28:12 +0200 Subject: [PATCH 1/3] Joystick Detection tweaks for Raspberry PI OS / Linux --- src/linux_joystick.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/linux_joystick.c b/src/linux_joystick.c index d8a916b0..fc121dc2 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -157,10 +157,19 @@ static GLFWbool openJoystickDevice(const char* path) } // Ensure this device supports the events expected of a joystick - if (!isBitSet(EV_ABS, evBits)) + // NOTE: SDL2 based Joystick Check + if (isBitSet(BTN_STYLUS, keyBits) || + isBitSet(BTN_TOOL_PEN, keyBits) || + isBitSet(BTN_TOOL_FINGER, keyBits) || + isBitSet(BTN_MOUSE, keyBits) || + isBitSet(BTN_TOUCH, keyBits) || + (keyBits[0] & 0xFFFFFFFE) != 0) { close(linjs.fd); return GLFW_FALSE; + } else if (!isBitSet(EV_ABS, evBits)) { + close(linjs.fd); + return GLFW_FALSE; } char name[256] = ""; @@ -168,6 +177,17 @@ static GLFWbool openJoystickDevice(const char* path) if (ioctl(linjs.fd, EVIOCGNAME(sizeof(name)), name) < 0) strncpy(name, "Unknown", sizeof(name)); + // NOTE: Some devices are still indentified as Gamepad devices (Rapsbery PI 500, Hypertouch Square Display). + // They are filtered out for enumeration. I wish there is a more robust way to detect if a device is really + // a gamecontroller/gamepad, but I wasn't able to find a way. + if (strstr(name, "Keyboard System Control") || + strstr(name, "Keyboard Consumer Control" || + strstr(name, "11-0048 EP0110M09") || + strstr(name, "HID 046a:0023")) { + close(linjs.fd); + return GLFW_FALSE; + } + char guid[33] = ""; // Generate a joystick GUID that matches the SDL 2.0.5+ one @@ -433,4 +453,3 @@ void _glfwUpdateGamepadGUIDLinux(char* guid) } #endif // GLFW_BUILD_LINUX_JOYSTICK - From dca02a988bc5ba82f9e71ae135ff1d656eb7c28e Mon Sep 17 00:00:00 2001 From: Jochen Heizmann Date: Sat, 21 Jun 2025 11:45:45 +0200 Subject: [PATCH 2/3] typo / missing bracket --- src/linux_joystick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/linux_joystick.c b/src/linux_joystick.c index fc121dc2..288bc7fb 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -181,7 +181,7 @@ static GLFWbool openJoystickDevice(const char* path) // They are filtered out for enumeration. I wish there is a more robust way to detect if a device is really // a gamecontroller/gamepad, but I wasn't able to find a way. if (strstr(name, "Keyboard System Control") || - strstr(name, "Keyboard Consumer Control" || + strstr(name, "Keyboard Consumer Control") || strstr(name, "11-0048 EP0110M09") || strstr(name, "HID 046a:0023")) { close(linjs.fd); From 5115508d2cc189d91846f31e43691eaf5bbdd6eb Mon Sep 17 00:00:00 2001 From: Jochen Heizmann Date: Sat, 21 Jun 2025 11:45:57 +0200 Subject: [PATCH 3/3] CONTRIBUTURS.md and README.md updated --- CONTRIBUTORS.md | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4fc27126..0f1042df 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -98,6 +98,7 @@ video tutorials. - Björn Hempel - Matthew Henry - heromyth + - Jochen Heizmann - Lucas Hinderberger - Paul Holden - Hajime Hoshi diff --git a/README.md b/README.md index 52306188..e9452fd0 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,7 @@ information on what to include when reporting a bug. - [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless` - [EGL] Allowed native access on Wayland with `GLFW_CONTEXT_CREATION_API` set to `GLFW_NATIVE_CONTEXT_API` (#2518) + - [Linux] Bugfix: Non-joystick input devices were incorrectly detected as joysticks on Raspberry PI OS ## Contact