From 3d62999485e0f1e360a77b283962fe30ddc29922 Mon Sep 17 00:00:00 2001 From: kimci86 Date: Tue, 15 Feb 2022 11:10:51 +0100 Subject: [PATCH] Make right Alt key work on X11 --- src/SFML/Window/Unix/KeySymToKeyMapping.cpp | 1 + src/SFML/Window/Unix/KeyboardImpl.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/SFML/Window/Unix/KeySymToKeyMapping.cpp b/src/SFML/Window/Unix/KeySymToKeyMapping.cpp index 7aea2d979..f9e4264e1 100644 --- a/src/SFML/Window/Unix/KeySymToKeyMapping.cpp +++ b/src/SFML/Window/Unix/KeySymToKeyMapping.cpp @@ -43,6 +43,7 @@ Keyboard::Key keySymToKey(KeySym symbol) case XK_Control_L: return Keyboard::LControl; case XK_Control_R: return Keyboard::RControl; case XK_Alt_L: return Keyboard::LAlt; + case XK_ISO_Level3_Shift: case XK_Alt_R: return Keyboard::RAlt; case XK_Super_L: return Keyboard::LSystem; case XK_Super_R: return Keyboard::RSystem; diff --git a/src/SFML/Window/Unix/KeyboardImpl.cpp b/src/SFML/Window/Unix/KeyboardImpl.cpp index cf53f9484..502381fc9 100644 --- a/src/SFML/Window/Unix/KeyboardImpl.cpp +++ b/src/SFML/Window/Unix/KeyboardImpl.cpp @@ -544,9 +544,15 @@ KeyCode keyToKeyCode(sf::Keyboard::Key key) Display* display = sf::priv::OpenDisplay(); KeyCode keycode = XKeysymToKeycode(display, keysym); sf::priv::CloseDisplay(display); - return keycode; + + if (keycode != NullKeyCode) + return keycode; } + // Fallback for when XKeysymToKeycode cannot tell the KeyCode for XK_Alt_R + if (key == sf::Keyboard::RAlt) + return scancodeToKeycode[sf::Keyboard::ScanRAlt]; + return NullKeyCode; }