Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ namespace config {
bool ds5_inputtino_randomize_mac;

bool keyboard;
bool key_rightalt_to_key_win;
bool mouse;
bool controller;

Expand Down
22 changes: 19 additions & 3 deletions src/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
}
Expand Down