Skip to content

Commit

Permalink
Add ifdefs to try to be compatible with old SDL versions
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jul 17, 2024
1 parent 320a1cf commit 04c4f7b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions SDL/SDLJoystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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;
Expand Down

0 comments on commit 04c4f7b

Please sign in to comment.