Fix keyboard detection

Apparently, `keyboard_is_active` defaulted to `true`, relying on the
existence of a gamepad connection to set it to `false`. This logic is
faulty on devices where you have neither a keyboard OR a gamepad, such
as touch input. This is the exact scenario I ran into while working on
touch input -- the editor was enabled despite not having a keyboard.

This patch sets the default depending on the device -- if we're on a
mobile device, set it to false; otherwise check if we're on Steam Deck.
This commit is contained in:
NyakoFox authored and Ethan Lee committed 2026-10-19 07:37:29 -04:00
1 parent 8a76433eec
commit 40e1ec3bbf
1 file changed
+7 -1
+7 -1
View File
@@ -155,7 +155,7 @@ static const char* glyph_layout[LAYOUT_TOTAL][SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER
} }
}; };
static bool keyboard_is_active = true; static bool keyboard_is_active;
static ButtonGlyphLayout layout = LAYOUT_GENERIC; static ButtonGlyphLayout layout = LAYOUT_GENERIC;
void BUTTONGLYPHS_init(void) void BUTTONGLYPHS_init(void)
@@ -165,6 +165,12 @@ void BUTTONGLYPHS_init(void)
{ {
SDL_strlcpy(glyph[i], UTF8_encode(0xEB00+i).bytes, sizeof(glyph[i])); SDL_strlcpy(glyph[i], UTF8_encode(0xEB00+i).bytes, sizeof(glyph[i]));
} }
#if defined(SDL_PLATFORM_ANDROID) || TARGET_OS_IPHONE
keyboard_is_active = false;
#else
keyboard_is_active = !SDL_GetHintBoolean("SteamDeck", false);
#endif
} }
bool BUTTONGLYPHS_keyboard_is_available(void) bool BUTTONGLYPHS_keyboard_is_available(void)