A Steam Controller might be generating keyboard input

We can't use keyboard input as a signal about whether a keyboard is attached. There might be keyboard input from any number of generated inputs or non-keyboard devices.
This commit is contained in:
Sam Lantinga 2025-03-20 16:00:04 -07:00
parent cbb83be895
commit 8caeaaacdd
4 changed files with 1 additions and 29 deletions

View file

@ -70,7 +70,6 @@ typedef struct SDL_Keyboard
static SDL_Keyboard SDL_keyboard; static SDL_Keyboard SDL_keyboard;
static int SDL_keyboard_count; static int SDL_keyboard_count;
static SDL_KeyboardInstance *SDL_keyboards; static SDL_KeyboardInstance *SDL_keyboards;
static bool SDL_keyboard_active;
static void SDLCALL SDL_KeycodeOptionsChanged(void *userdata, const char *name, const char *oldValue, const char *hint) static void SDLCALL SDL_KeycodeOptionsChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
{ {
@ -215,20 +214,6 @@ const char *SDL_GetKeyboardNameForID(SDL_KeyboardID instance_id)
return SDL_GetPersistentString(SDL_keyboards[keyboard_index].name); return SDL_GetPersistentString(SDL_keyboards[keyboard_index].name);
} }
void SDL_SetKeyboardActive(bool active)
{
SDL_keyboard_active = active;
}
bool SDL_HasActiveKeyboard(void)
{
if (!SDL_HasKeyboard()) {
// No keyboards to be active
return false;
}
return SDL_keyboard_active;
}
void SDL_ResetKeyboard(void) void SDL_ResetKeyboard(void)
{ {
SDL_Keyboard *keyboard = &SDL_keyboard; SDL_Keyboard *keyboard = &SDL_keyboard;
@ -571,8 +556,6 @@ static bool SDL_SendKeyboardKeyInternal(Uint64 timestamp, Uint32 flags, SDL_Keyb
} }
if (source == KEYBOARD_HARDWARE) { if (source == KEYBOARD_HARDWARE) {
// Primary input appears to be a keyboard
SDL_SetKeyboardActive(true);
keyboard->hardware_timestamp = SDL_GetTicks(); keyboard->hardware_timestamp = SDL_GetTicks();
} else if (source == KEYBOARD_AUTORELEASE) { } else if (source == KEYBOARD_AUTORELEASE) {
keyboard->autorelease_pending = true; keyboard->autorelease_pending = true;

View file

@ -43,12 +43,6 @@ extern void SDL_AddKeyboard(SDL_KeyboardID keyboardID, const char *name, bool se
// A keyboard has been removed from the system // A keyboard has been removed from the system
extern void SDL_RemoveKeyboard(SDL_KeyboardID keyboardID, bool send_event); extern void SDL_RemoveKeyboard(SDL_KeyboardID keyboardID, bool send_event);
// Set whether keyboard input is active
extern void SDL_SetKeyboardActive(bool active);
// Get whether keyboard input is active
extern bool SDL_HasActiveKeyboard(void);
// Set the mapping of scancode to key codes // Set the mapping of scancode to key codes
extern void SDL_SetKeymap(SDL_Keymap *keymap, bool send_event); extern void SDL_SetKeymap(SDL_Keymap *keymap, bool send_event);

View file

@ -2368,11 +2368,6 @@ void SDL_SendJoystickButton(Uint64 timestamp, SDL_Joystick *joystick, Uint8 butt
return; return;
} }
if (!joystick->is_virtual) {
// Primary input appears to be a joystick
SDL_SetKeyboardActive(false);
}
/* We ignore events if we don't have keyboard focus, except for button /* We ignore events if we don't have keyboard focus, except for button
* release. */ * release. */
if (SDL_PrivateJoystickShouldIgnoreEvent()) { if (SDL_PrivateJoystickShouldIgnoreEvent()) {

View file

@ -5416,7 +5416,7 @@ bool SDL_GetTextInputMultiline(SDL_PropertiesID props)
static bool AutoShowingScreenKeyboard(void) static bool AutoShowingScreenKeyboard(void)
{ {
const char *hint = SDL_GetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD); const char *hint = SDL_GetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD);
if (((!hint || SDL_strcasecmp(hint, "auto") == 0) && !SDL_HasActiveKeyboard()) || if (((!hint || SDL_strcasecmp(hint, "auto") == 0) && !SDL_HasKeyboard()) ||
SDL_GetStringBoolean(hint, false)) { SDL_GetStringBoolean(hint, false)) {
return true; return true;
} else { } else {