SDL_HINT_AND...P_BACK_BUTTON(3)

πŸ’– NAME πŸ’–

SDL_HINT_ANDROID_TRAP_BACK_BUTTON β€” bestie, it's literally just a variable that controls whether we trap the Android back button so we can handle it ourselves manually. that's it. that's the whole girl. πŸŽ€


✨ SYNOPSIS ✨

#include <SDL3/SDL_hints.h>

#define SDL_HINT_ANDROID_TRAP_BACK_BUTTON "SDL_ANDROID_TRAP_BACK_BUTTON"

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so listen. this hint is lowkey essential for two whole reasons. one: it makes the right mouse button actually work on some Android devices. two: it lets you trap the back button for use in your code reliably, no cap. if this hint is true, the back button shows up as an SDL_EVENT_KEY_DOWN / SDL_EVENT_KEY_UP pair with a keycode of SDL_SCANCODE_AC_BACK. slay. πŸ’…

the variable can be set to the following values, and yes we're going through all of them:

  • "0" β€” the back button will be handled as usual for the system. this is the default, bestie. (default)
  • "1" β€” the back button will be trapped, allowing you to handle the key press manually. (this will also let right mouse click work on systems where the right mouse button functions as back.)

this hint can be set anytime. no waiting around, no setup era, just vibes. 🌈


🌸 AVAILABILITY 🌸

this hint has been available since SDL 3.2.0. she's new-ish but she's iconic. periodt. πŸ‘‘


ok but fr fr, if you're not trapping that back button and your right mouse click is giving nothing on some Android devices… this is your sign. 🫢

that's the whole page, bestie! this came to you courtesy of Simple Directmedia Layer β€” SDL 3.4.18 πŸŽ€ β€” go build something cute, mwah πŸ’–βœ¨

πŸ“¦ where this page comes from