From 85ad091c22e6b173c4f50bfccdf3436db9c870bd Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 24 Feb 2021 11:19:57 -0500 Subject: [PATCH] Filter out Keypad as a mod in sdl_key_names (#1678) --- src/duckstation-nogui/sdl_key_names.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/duckstation-nogui/sdl_key_names.h b/src/duckstation-nogui/sdl_key_names.h index 86e117c22..acf32e478 100644 --- a/src/duckstation-nogui/sdl_key_names.h +++ b/src/duckstation-nogui/sdl_key_names.h @@ -333,14 +333,22 @@ std::optional ParseKeyString(const std::string_view key_str) break; const std::string_view mod_part = key_str.substr(pos, plus_pos - pos); + + // Keypad in SDL is not a mod and should always be the last + in the string + bool known_mod = false; for (const SDLKeyModifierEntry& mod : s_sdl_key_modifiers) { if (mod_part == mod.name) { modifiers |= static_cast(mod.mod); + known_mod = true; break; } } + + if (!known_mod) + break; + pos = plus_pos + 1; } @@ -350,4 +358,4 @@ std::optional ParseKeyString(const std::string_view key_str) return static_cast(key_code.value()) | (modifiers << 16); } -} // namespace SDLKeyNames \ No newline at end of file +} // namespace SDLKeyNames