fix(input): don't send ALT when right-alt is remapped to meta (#5318)

Signed-off-by: Anish Pallati <i@anish.land>
This commit is contained in:
Anish Pallati
2026-06-24 18:01:58 -04:00
committed by GitHub
parent e4740f0696
commit 0731729347
3 changed files with 23 additions and 6 deletions
+3 -3
View File
@@ -1274,10 +1274,10 @@ namespace config {
// This config option will only be used by the UI
// When editing in the config file itself, use "keybindings"
bool map_rightalt_to_win = false;
bool_f(vars, "key_rightalt_to_key_win", map_rightalt_to_win);
input.key_rightalt_to_key_win = false;
bool_f(vars, "key_rightalt_to_key_win", input.key_rightalt_to_key_win);
if (map_rightalt_to_win) {
if (input.key_rightalt_to_key_win) {
input.keybindings.emplace(0xA5, 0x5B);
}
+1
View File
@@ -217,6 +217,7 @@ namespace config {
bool ds5_inputtino_randomize_mac;
bool keyboard;
bool key_rightalt_to_key_win;
bool mouse;
bool controller;
+19 -3
View File
@@ -178,6 +178,9 @@ namespace input {
// Keep track of alt+ctrl+shift key combo
int shortcutFlags;
bool left_alt_pressed = false;
bool right_alt_pressed = false;
std::vector<gamepad_t> gamepads;
std::unique_ptr<platf::client_input_t> client_context;
@@ -760,17 +763,30 @@ namespace input {
auto release = util::endian::little(packet->header.magic) == KEY_UP_EVENT_MAGIC;
auto keyCode = packet->keyCode & 0x00FF;
if (keyCode == VKEY_LMENU) {
input->left_alt_pressed = !release;
} else if (keyCode == VKEY_RMENU) {
input->right_alt_pressed = !release;
}
// Right-alt maps to meta, so it must not also register as ALT
int modifiers = packet->modifiers;
if (config::input.key_rightalt_to_key_win &&
input->right_alt_pressed && !input->left_alt_pressed) {
modifiers &= ~MODIFIER_ALT;
}
// Set synthetic modifier flags if the keyboard packet is requesting modifier
// keys that are not current pressed.
uint8_t synthetic_modifiers = 0;
if (!release && !is_modifier(keyCode)) {
if (!(input->shortcutFlags & input_t::SHIFT) && (packet->modifiers & MODIFIER_SHIFT)) {
if (!(input->shortcutFlags & input_t::SHIFT) && (modifiers & MODIFIER_SHIFT)) {
synthetic_modifiers |= MODIFIER_SHIFT;
}
if (!(input->shortcutFlags & input_t::CTRL) && (packet->modifiers & MODIFIER_CTRL)) {
if (!(input->shortcutFlags & input_t::CTRL) && (modifiers & MODIFIER_CTRL)) {
synthetic_modifiers |= MODIFIER_CTRL;
}
if (!(input->shortcutFlags & input_t::ALT) && (packet->modifiers & MODIFIER_ALT)) {
if (!(input->shortcutFlags & input_t::ALT) && (modifiers & MODIFIER_ALT)) {
synthetic_modifiers |= MODIFIER_ALT;
}
}