From 71995aeee9025666ba46964b4f49cfb040a1da66 Mon Sep 17 00:00:00 2001 From: MediocreDev Date: Fri, 29 Dec 2023 02:16:46 -0500 Subject: [PATCH] Linux: Fix joystick EV_KEY handling indexing below 0 on keyboard input --- CONTRIBUTORS.md | 1 + README.md | 2 ++ src/linux_joystick.c | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 75533ec3..ae597a4d 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -278,6 +278,7 @@ video tutorials. - Jonas Ådahl - Lasse Öörni - Leonard König + - Liam Malone - All the unmentioned and anonymous contributors in the GLFW community, for bug reports, patches, feedback, testing and encouragement diff --git a/README.md b/README.md index cebe62bc..fdd67ce6 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,8 @@ information on what to include when reporting a bug. ## Changelog + - Bugfix: Linux joystick handling would crash with some keyboards, indexing the + associated KeyMap with a value less than 0 - Added `GLFW_PLATFORM` init hint for runtime platform selection (#1958) - Added `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`, `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` and `GLFW_PLATFORM_NULL` symbols to diff --git a/src/linux_joystick.c b/src/linux_joystick.c index 78d867eb..b12f6bcd 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -51,7 +51,7 @@ // static void handleKeyEvent(_GLFWjoystick* js, int code, int value) { - _glfwInputJoystickButton(js, + if (code - BTN_MISC >= 0) _glfwInputJoystickButton(js, js->linjs.keyMap[code - BTN_MISC], value ? GLFW_PRESS : GLFW_RELEASE); }