From ba9e924e578e7820b36f2dee70447750e80d2ab3 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 29 Jun 2023 16:09:55 -0700
Subject: [PATCH] Added additional debug logging for Linux joysticks
---
src/joystick/linux/SDL_sysjoystick.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c
index 8e744d96a4ef..819583a3f33a 100644
--- a/src/joystick/linux/SDL_sysjoystick.c
+++ b/src/joystick/linux/SDL_sysjoystick.c
@@ -1810,6 +1810,9 @@ static void HandleInputEvents(SDL_Joystick *joystick)
switch (event->type) {
case EV_KEY:
+#ifdef DEBUG_INPUT_EVENTS
+ SDL_Log("Key 0x%.2x %s\n", code, event->value ? "PRESSED" : "RELEASED");
+#endif
SDL_SendJoystickButton(SDL_EVDEV_GetEventTimestamp(event), joystick,
joystick->hwdata->key_map[code],
event->value);
@@ -1826,11 +1829,17 @@ static void HandleInputEvents(SDL_Joystick *joystick)
case ABS_HAT3Y:
hat_index = (code - ABS_HAT0X) / 2;
if (joystick->hwdata->has_hat[hat_index]) {
+#ifdef DEBUG_INPUT_EVENTS
+ SDL_Log("Axis 0x%.2x = %d\n", code, event->value);
+#endif
HandleHat(SDL_EVDEV_GetEventTimestamp(event), joystick, hat_index, code % 2, event->value);
break;
}
SDL_FALLTHROUGH;
default:
+#ifdef DEBUG_INPUT_EVENTS
+ SDL_Log("Axis 0x%.2x = %d\n", code, event->value);
+#endif
event->value = AxisCorrect(joystick, code, event->value);
SDL_SendJoystickAxis(SDL_EVDEV_GetEventTimestamp(event), joystick,
joystick->hwdata->abs_map[code],