From 620e6bdb490433f9d753eb7cc85b8f9292bf0c94 Mon Sep 17 00:00:00 2001 From: mintey Date: Wed, 3 Mar 2021 17:58:45 +0200 Subject: [PATCH] gui modifier instead of insert --- smol_gkos.ino | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/smol_gkos.ino b/smol_gkos.ino index f3c8dd8..ddab07e 100644 --- a/smol_gkos.ino +++ b/smol_gkos.ino @@ -98,7 +98,7 @@ const byte specials[22] = { 17, 51, 30, 10, 20, 12, 33, 34, 9, 36, 27, 54, 18, 45, 63, 31, 47, 55, 62, 43, 61, 59 }; -enum Modifier { Shift, SymbolShift, Keyset, Control, Alt }; +enum Modifier { Shift, SymbolShift, Keyset, Control, Alt, Gui }; const int special_action_targets[22] = { // - \ / ' KEY_MINUS, KEY_MINUS + MASK_ALTGR, KEY_SLASH, KEY_QUOTE, @@ -106,7 +106,7 @@ const int special_action_targets[22] = { KEY_COMMA, KEY_1 + MASK_SHIFT, KEY_SLASH + MASK_SHIFT, KEY_PERIOD, KEY_UP, KEY_DOWN, KEY_PAGE_UP, KEY_PAGE_DOWN, Modifier::Shift, Modifier::SymbolShift, Modifier::Keyset, - KEY_ESC, Modifier::Control, Modifier::Alt, KEY_DELETE, KEY_INSERT, + KEY_ESC, Modifier::Control, Modifier::Alt, KEY_DELETE, Modifier::Gui, KEY_TAB, KEY_ENTER }; const int special_action_targets_symbol[22] = { @@ -120,7 +120,7 @@ const int special_action_targets_symbol[22] = { 0, 0 }; const byte special_action_target_types[22] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0 }; byte key_pressed = 0; @@ -135,6 +135,7 @@ bool mod_symbol_lock = false; bool mod_control = false; bool mod_alt = false; bool mod_altgr = false; +bool mod_gui = false; IntervalTimer trackball_timer; volatile bool trackball_update = false; @@ -354,6 +355,9 @@ void key_released(byte key) { case Modifier::Alt: mod_alt = !mod_alt; return; + case Modifier::Gui: + mod_gui = !mod_gui; + return; } } return; @@ -433,6 +437,8 @@ void press_key(int key) { Keyboard.press(KEY_LEFT_ALT); if (mod_altgr) Keyboard.press(KEY_RIGHT_ALT); + if (mod_gui) + Keyboard.press(KEY_LEFT_GUI); // keypress Keyboard.press(key); @@ -447,15 +453,17 @@ void press_key(int key) { Keyboard.release(KEY_LEFT_ALT); if (mod_altgr) Keyboard.release(KEY_RIGHT_ALT); + if (mod_gui) + Keyboard.release(KEY_LEFT_GUI); // clear temporary modifiers - mod_shift = mod_symbol = mod_control = mod_alt = mod_altgr = false; + mod_shift = mod_symbol = mod_control = mod_alt = mod_altgr = mod_gui = false; } void update_leds() { digitalWrite(PIN_LED1, mod_shift || mod_shift_lock); digitalWrite(PIN_LED2, mod_symbol || mod_symbol_lock); - digitalWrite(PIN_LED3, mod_control || mod_alt); + digitalWrite(PIN_LED3, mod_control || mod_alt || mod_gui); } int sign(int num) {