diff --git a/include/SDL3/SDL_hints.h b/include/SDL3/SDL_hints.h index ba2ff351e0..8d96137d16 100644 --- a/include/SDL3/SDL_hints.h +++ b/include/SDL3/SDL_hints.h @@ -809,6 +809,23 @@ extern "C" { */ #define SDL_HINT_ENABLE_SCREEN_KEYBOARD "SDL_ENABLE_SCREEN_KEYBOARD" +/** + * A variable that controls whether the Steam on-screen keyboard should be shown + * when text input is active. + * + * Steam will set this hint via environment variable for games launched in Big Picture mode. To override this you should call SDL_SetHintWithPriority() with priority `SDL_HINT_OVERRIDE`. + * + * The variable can be set to the following values: + * + * - "0": Do not show the Steam on-screen keyboard. + * - "1": Show the Steam on-screen keyboard. + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.4.12. + */ +#define SDL_HINT_ENABLE_STEAM_SCREEN_KEYBOARD "SDL_ENABLE_STEAM_SCREEN_KEYBOARD" + /** * A variable containing a list of evdev devices to use if udev is not * available. diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 48ed85a20a..b7804b17ed 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -5785,8 +5785,10 @@ static bool AutoShowingScreenKeyboard(void) { const char *hint = SDL_GetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD); if (!hint) { - // Steam will eventually have smarts about whether a keyboard is active, so always request the on-screen keyboard on Steam Deck - hint = SDL_GetHint("SteamDeck"); + // This hint is currently only used by the X11 video driver + if (SDL_strcmp(_this->name, "x11") == 0) { + hint = SDL_GetHint(SDL_HINT_ENABLE_STEAM_SCREEN_KEYBOARD); + } } if (((!hint || SDL_strcasecmp(hint, "auto") == 0) && !SDL_HasKeyboard()) || SDL_GetStringBoolean(hint, false)) { diff --git a/src/video/x11/SDL_x11keyboard.c b/src/video/x11/SDL_x11keyboard.c index e94053f3e8..5f86c5667d 100644 --- a/src/video/x11/SDL_x11keyboard.c +++ b/src/video/x11/SDL_x11keyboard.c @@ -831,14 +831,14 @@ bool X11_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window) bool X11_HasScreenKeyboardSupport(SDL_VideoDevice *_this) { SDL_VideoData *videodata = _this->internal; - return videodata->is_steam_deck; + return videodata->use_steam_screen_keyboard; } void X11_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) { SDL_VideoData *videodata = _this->internal; - if (videodata->is_steam_deck) { + if (videodata->use_steam_screen_keyboard) { /* For more documentation of the URL parameters, see: * https://partner.steamgames.com/doc/api/ISteamUtils#ShowFloatingGamepadTextInput */ @@ -880,7 +880,7 @@ void X11_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) { SDL_VideoData *videodata = _this->internal; - if (videodata->is_steam_deck) { + if (videodata->use_steam_screen_keyboard) { SDL_OpenURL("steam://close/keyboard"); SDL_SendScreenKeyboardHidden(); } diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 0981c0f049..955fcfad3a 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -143,7 +143,7 @@ static SDL_VideoDevice *X11_CreateDevice(void) /* Steam Deck will have an on-screen keyboard, so check their environment * variable so we can make use of SDL_StartTextInput. */ - data->is_steam_deck = SDL_GetHintBoolean("SteamDeck", false); + data->use_steam_screen_keyboard = SDL_GetHintBoolean(SDL_HINT_ENABLE_STEAM_SCREEN_KEYBOARD, false); // Set the function pointers device->VideoInit = X11_VideoInit; diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h index c6069b2624..026593aca5 100644 --- a/src/video/x11/SDL_x11video.h +++ b/src/video/x11/SDL_x11video.h @@ -190,7 +190,7 @@ struct SDL_VideoData #endif // Used to interact with the on-screen keyboard - bool is_steam_deck; + bool use_steam_screen_keyboard; bool is_xwayland; };