Added SDL_HINT_ENABLE_STEAM_SCREEN_KEYBOARD

(cherry picked from commit c9b6581210)
This commit is contained in:
Sam Lantinga 2026-06-17 16:34:16 -07:00
parent 31e08f0bad
commit c548acee53
5 changed files with 26 additions and 7 deletions

View file

@ -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.

View file

@ -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)) {

View file

@ -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();
}

View file

@ -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;

View file

@ -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;
};