From c9b6581210597b46b3e5c7a4623af24bcbac1111 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 17 Jun 2026 16:34:16 -0700
Subject: [PATCH] Added SDL_HINT_ENABLE_STEAM_SCREEN_KEYBOARD
---
include/SDL3/SDL_hints.h | 17 +++++++++++++++++
src/video/SDL_video.c | 6 ++++--
src/video/x11/SDL_x11keyboard.c | 6 +++---
src/video/x11/SDL_x11video.c | 2 +-
src/video/x11/SDL_x11video.h | 2 +-
5 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/include/SDL3/SDL_hints.h b/include/SDL3/SDL_hints.h
index d23577fa8c7d2..263e2ac738bb7 100644
--- a/include/SDL3/SDL_hints.h
+++ b/include/SDL3/SDL_hints.h
@@ -865,6 +865,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 4f8f3c0f8f2e6..2d9a59adf8b11 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -5775,8 +5775,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 e94053f3e8d53..5f86c5667dc74 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 9c2e801c8d6b1..4c1a7c6ddc34f 100644
--- a/src/video/x11/SDL_x11video.c
+++ b/src/video/x11/SDL_x11video.c
@@ -153,7 +153,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 7bc858d98bded..a80712d362a8e 100644
--- a/src/video/x11/SDL_x11video.h
+++ b/src/video/x11/SDL_x11video.h
@@ -193,7 +193,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;
};