From 04c4f7b25a4fbb2e4c0d763e8c8aa9008e0719e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 17 Jul 2024 22:04:32 +0200 Subject: [PATCH] Add ifdefs to try to be compatible with old SDL versions --- SDL/SDLJoystick.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/SDL/SDLJoystick.cpp b/SDL/SDLJoystick.cpp index f7f0cba2e1..a0d206ee21 100644 --- a/SDL/SDLJoystick.cpp +++ b/SDL/SDLJoystick.cpp @@ -149,8 +149,13 @@ InputKeyCode SDLJoystick::getKeycodeForButton(SDL_GameControllerButton button) { return NKCODE_BUTTON_THUMBL; case SDL_CONTROLLER_BUTTON_RIGHTSTICK: return NKCODE_BUTTON_THUMBR; + + // Found these limits by checking out the SDL2 branch of the SDL repo, doing git blame, then `git tag --contains (commit)` etc. +#if SDL_VERSION_ATLEAST(2, 0, 16) case SDL_CONTROLLER_BUTTON_MISC1: return NKCODE_BUTTON_11; +#endif +#if SDL_VERSION_ATLEAST(2, 0, 28) case SDL_CONTROLLER_BUTTON_PADDLE1: return NKCODE_BUTTON_12; case SDL_CONTROLLER_BUTTON_PADDLE2: @@ -159,8 +164,11 @@ InputKeyCode SDLJoystick::getKeycodeForButton(SDL_GameControllerButton button) { return NKCODE_BUTTON_14; case SDL_CONTROLLER_BUTTON_PADDLE4: return NKCODE_BUTTON_15; +#endif +#if SDL_VERSION_ATLEAST(2, 0, 14) case SDL_CONTROLLER_BUTTON_TOUCHPAD: return NKCODE_BUTTON_16; +#endif case SDL_CONTROLLER_BUTTON_INVALID: default: return NKCODE_UNKNOWN;