1
0
Эх сурвалжийг харах

Added SDL_HINT_ENABLE_STEAM_SCREEN_KEYBOARD

(cherry picked from commit c9b6581210597b46b3e5c7a4623af24bcbac1111)
Sam Lantinga 1 өдөр өмнө
parent
commit
c548acee53

+ 17 - 0
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.

+ 4 - 2
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)) {

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

+ 1 - 1
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;

+ 1 - 1
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;
 };