diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/bootmagic.c | 71 | ||||
-rw-r--r-- | common/bootmagic.h | 78 | ||||
-rw-r--r-- | common/command.c | 48 | ||||
-rw-r--r-- | common/debug.c | 8 | ||||
-rw-r--r-- | common/debug.h | 24 | ||||
-rw-r--r-- | common/eeconfig.c | 9 | ||||
-rw-r--r-- | common/eeconfig.h | 58 | ||||
-rw-r--r-- | common/keyboard.c | 12 | ||||
-rw-r--r-- | common/keymap.c | 64 | ||||
-rw-r--r-- | common/keymap.h | 19 |
10 files changed, 225 insertions, 166 deletions
diff --git a/common/bootmagic.c b/common/bootmagic.c index 388099e2e6..716f5d956b 100644 --- a/common/bootmagic.c +++ b/common/bootmagic.c @@ -2,53 +2,78 @@ #include <stdbool.h> #include <util/delay.h> #include "matrix.h" +#include "bootloader.h" +#include "debug.h" #include "keymap.h" #include "eeconfig.h" -#include "bootloader.h" #include "bootmagic.h" void bootmagic(void) { - if (!BOOTMAGIC_IS_ENABLED()) { return; } + /* check signature */ + if (!eeconfig_is_enabled()) { + eeconfig_init(); + } /* do scans in case of bounce */ uint8_t scan = 100; - while (scan--) { matrix_scan(); _delay_ms(1); } + while (scan--) { matrix_scan(); _delay_ms(10); } - if (bootmagic_scan_keycode(BOOTMAGIC_BOOTLOADER_KEY)) { - bootloader_jump(); + /* bootmagic skip */ + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SKIP)) { + return; } - if (bootmagic_scan_keycode(BOOTMAGIC_DEBUG_ENABLE_KEY)) { - eeconfig_write_debug(eeconfig_read_debug() ^ EECONFIG_DEBUG_ENABLE); + /* eeconfig clear */ + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EEPROM_CLEAR)) { + eeconfig_init(); } - if (bootmagic_scan_keycode(BOOTMAGIC_EEPROM_CLEAR_KEY)) { - eeconfig_init(); + /* bootloader */ + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_BOOTLOADER)) { + bootloader_jump(); + } + + /* debug enable */ + debug_config.raw = eeconfig_read_debug(); + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_ENABLE)) { + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_MATRIX)) { + debug_config.matrix = !debug_config.matrix; + } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_KEYBOARD)) { + debug_config.keyboard = !debug_config.keyboard; + } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_MOUSE)) { + debug_config.mouse = !debug_config.mouse; + } else { + debug_config.enable = !debug_config.enable; + } } + eeconfig_write_debug(debug_config.raw); - if (bootmagic_scan_keycode(BOOTMAGIC_SWAP_CONTROL_CPASLOCK)) { - eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_SWAP_CONTROL_CAPSLOCK); + /* keymap config */ + keymap_config.raw = eeconfig_read_keymap(); + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_CONTROL_CPASLOCK)) { + keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock; } - if (bootmagic_scan_keycode(BOOTMAGIC_CAPSLOCK_TO_CONTROL)) { - eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_CAPSLOCK_TO_CONTROL); + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_CAPSLOCK_TO_CONTROL)) { + keymap_config.capslock_to_control = !keymap_config.capslock_to_control; } - if (bootmagic_scan_keycode(BOOTMAGIC_SWAP_LALT_LGUI)) { - eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_SWAP_LALT_LGUI); + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_LALT_LGUI)) { + keymap_config.swap_lalt_lgui = !keymap_config.swap_lalt_lgui; } - if (bootmagic_scan_keycode(BOOTMAGIC_SWAP_RALT_RGUI)) { - eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_SWAP_RALT_RGUI); + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_RALT_RGUI)) { + keymap_config.swap_ralt_rgui = !keymap_config.swap_ralt_rgui; } - if (bootmagic_scan_keycode(BOOTMAGIC_NO_GUI)) { - eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_NO_GUI); + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_NO_GUI)) { + keymap_config.no_gui = !keymap_config.no_gui; } - if (bootmagic_scan_keycode(BOOTMAGIC_SWAP_GRAVE_ESC)) { - eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_SWAP_GRAVE_ESC); + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_GRAVE_ESC)) { + keymap_config.swap_grave_esc = !keymap_config.swap_grave_esc; } - if (bootmagic_scan_keycode(BOOTMAGIC_SWAP_BACKSLASH_BACKSPACE)) { - eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_SWAP_BACKSLASH_BACKSPACE); + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_BACKSLASH_BACKSPACE)) { + keymap_config.swap_backslash_backspace = !keymap_config.swap_backslash_backspace; } + eeconfig_write_keymap(keymap_config.raw); } bool bootmagic_scan_keycode(uint8_t keycode) diff --git a/common/bootmagic.h b/common/bootmagic.h index 5791b221f4..2e7496ebc5 100644 --- a/common/bootmagic.h +++ b/common/bootmagic.h @@ -2,71 +2,45 @@ #define BOOTMAGIC_H -#ifndef BOOTMAGIC_IS_ENABLED -#define BOOTMAGIC_IS_ENABLED() true +#ifndef BOOTMAGIC_KEY_SKIP +#define BOOTMAGIC_KEY_SKIP KC_ESC +#endif + +/* eeprom clear */ +#ifndef BOOTMAGIC_KEY_EEPROM_CLEAR +#define BOOTMAGIC_KEY_EEPROM_CLEAR KC_BSPACE #endif /* kick up bootloader */ -#ifndef BOOTMAGIC_BOOTLOADER_KEY -#define BOOTMAGIC_BOOTLOADER_KEY KC_B +#ifndef BOOTMAGIC_KEY_BOOTLOADER +#define BOOTMAGIC_KEY_BOOTLOADER KC_B #endif + /* debug enable */ -#ifndef BOOTMAGIC_DEBUG_ENABLE_KEY -#define BOOTMAGIC_DEBUG_ENABLE_KEY KC_D -#endif -/* eeprom clear */ -#ifndef BOOTMAGIC_EEPROM_CLEAR_KEY -#define BOOTMAGIC_EEPROM_CLEAR_KEY KC_BSPACE -#endif +#define BOOTMAGIC_KEY_DEBUG_ENABLE KC_D +#define BOOTMAGIC_KEY_DEBUG_MATRIX KC_X +#define BOOTMAGIC_KEY_DEBUG_KEYBOARD KC_K +#define BOOTMAGIC_KEY_DEBUG_MOUSE KC_M /* - * key configure + * keymap config */ -/* swap control and capslock */ -#ifndef BOOTMAGIC_SWAP_CONTROL_CPASLOCK -#define BOOTMAGIC_SWAP_CONTROL_CPASLOCK KC_LCTRL -#endif -/* capslock to control */ -#ifndef BOOTMAGIC_CAPSLOCK_TO_CONTROL -#define BOOTMAGIC_CAPSLOCK_TO_CONTROL KC_CAPSLOCK -#endif -/* swap alt and gui */ -#ifndef BOOTMAGIC_SWAP_LALT_LGUI -#define BOOTMAGIC_SWAP_LALT_LGUI KC_LALT -#endif -/* swap alt and gui */ -#ifndef BOOTMAGIC_SWAP_RALT_RGUI -#define BOOTMAGIC_SWAP_RALT_RGUI KC_RALT -#endif -/* no gui */ -#ifndef BOOTMAGIC_NO_GUI -#define BOOTMAGIC_NO_GUI KC_LGUI -#endif -/* swap esc and grave */ -#ifndef BOOTMAGIC_SWAP_GRAVE_ESC -#define BOOTMAGIC_SWAP_GRAVE_ESC KC_GRAVE -#endif -/* swap backslash and backspace */ -#ifndef BOOTMAGIC_SWAP_BACKSLASH_BACKSPACE -#define BOOTMAGIC_SWAP_BACKSLASH_BACKSPACE KC_BSLASH -#endif +#define BOOTMAGIC_KEY_SWAP_CONTROL_CPASLOCK KC_LCTRL +#define BOOTMAGIC_KEY_CAPSLOCK_TO_CONTROL KC_CAPSLOCK +#define BOOTMAGIC_KEY_SWAP_LALT_LGUI KC_LALT +#define BOOTMAGIC_KEY_SWAP_RALT_RGUI KC_RALT +#define BOOTMAGIC_KEY_NO_GUI KC_LGUI +#define BOOTMAGIC_KEY_SWAP_GRAVE_ESC KC_GRAVE +#define BOOTMAGIC_KEY_SWAP_BACKSLASH_BACKSPACE KC_BSLASH /* * change default layer */ -#ifndef BOOTMAGIC_DEFAULT_LAYER_0_KEY -#define BOOTMAGIC_DEFAULT_LAYER_0_KEY KC_0 -#endif -#ifndef BOOTMAGIC_DEFAULT_LAYER_1_KEY -#define BOOTMAGIC_DEFAULT_LAYER_1_KEY KC_1 -#endif -#ifndef BOOTMAGIC_DEFAULT_LAYER_2_KEY -#define BOOTMAGIC_DEFAULT_LAYER_2_KEY KC_2 -#endif -#ifndef BOOTMAGIC_DEFAULT_LAYER_3_KEY -#define BOOTMAGIC_DEFAULT_LAYER_3_KEY KC_3 -#endif +#define BOOTMAGIC_KEY_DEFAULT_LAYER_0 KC_0 +#define BOOTMAGIC_KEY_DEFAULT_LAYER_1 KC_1 +#define BOOTMAGIC_KEY_DEFAULT_LAYER_2 KC_2 +#define BOOTMAGIC_KEY_DEFAULT_LAYER_3 KC_3 void bootmagic(void); diff --git a/common/command.c b/common/command.c index 3a1fcb186e..216ad06128 100644 --- a/common/command.c +++ b/common/command.c @@ -110,7 +110,7 @@ static void command_common_help(void) print("v: print device version & info\n"); print("t: print timer count\n"); print("s: print status\n"); - print("e: print eeprom boot config\n"); + print("e: print eeprom config\n"); #ifdef NKRO_ENABLE print("n: toggle NKRO\n"); #endif @@ -125,28 +125,28 @@ static void command_common_help(void) } #ifdef BOOTMAGIC_ENABLE -static void print_eeprom_config(void) +static void print_eeconfig(void) { - uint8_t eebyte; - - eebyte = eeconfig_read_debug(); - print("debug: "); print_hex8(eebyte); print("\n"); - - eebyte = eeconfig_read_defalt_layer(); - print("defalt_layer: "); print_hex8(eebyte); print("\n"); - - eebyte = eeconfig_read_keyconf(); - print("keyconf: "); print_hex8(eebyte); print("\n"); - - keyconf kc; - kc = (keyconf){ .raw = eebyte }; - print("keyconf.swap_control_capslock: "); print_hex8(kc.swap_control_capslock); print("\n"); - print("keyconf.capslock_to_control: "); print_hex8(kc.capslock_to_control); print("\n"); - print("keyconf.swap_lalt_lgui: "); print_hex8(kc.swap_lalt_lgui); print("\n"); - print("keyconf.swap_ralt_rgui: "); print_hex8(kc.swap_ralt_rgui); print("\n"); - print("keyconf.no_gui: "); print_hex8(kc.no_gui); print("\n"); - print("keyconf.swap_grave_esc: "); print_hex8(kc.swap_grave_esc); print("\n"); - print("keyconf.swap_backslash_backspace: "); print_hex8(kc.swap_backslash_backspace); print("\n"); + print("default_layer: "); print_dec(eeconfig_read_defalt_layer()); print("\n"); + + debug_config_t dc; + dc.raw = eeconfig_read_debug(); + print("debug_config.raw: "); print_hex8(dc.raw); print("\n"); + print(".enable: "); print_dec(dc.enable); print("\n"); + print(".matrix: "); print_dec(dc.matrix); print("\n"); + print(".keyboard: "); print_dec(dc.keyboard); print("\n"); + print(".mouse: "); print_dec(dc.mouse); print("\n"); + + keymap_config_t kc; + kc.raw = eeconfig_read_keymap(); + print("keymap_config.raw: "); print_hex8(kc.raw); print("\n"); + print(".swap_control_capslock: "); print_dec(kc.swap_control_capslock); print("\n"); + print(".capslock_to_control: "); print_dec(kc.capslock_to_control); print("\n"); + print(".swap_lalt_lgui: "); print_dec(kc.swap_lalt_lgui); print("\n"); + print(".swap_ralt_rgui: "); print_dec(kc.swap_ralt_rgui); print("\n"); + print(".no_gui: "); print_dec(kc.no_gui); print("\n"); + print(".swap_grave_esc: "); print_dec(kc.swap_grave_esc); print("\n"); + print(".swap_backslash_backspace: "); print_dec(kc.swap_backslash_backspace); print("\n"); } #endif @@ -162,8 +162,8 @@ static bool command_common(uint8_t code) break; #ifdef BOOTMAGIC_ENABLE case KC_E: - print("eeprom config\n"); - print_eeprom_config(); + print("eeconfig:\n"); + print_eeconfig(); break; #endif case KC_CAPSLOCK: diff --git a/common/debug.c b/common/debug.c deleted file mode 100644 index e406d39b0e..0000000000 --- a/common/debug.c +++ /dev/null @@ -1,8 +0,0 @@ -#include <stdbool.h> -#include "debug.h" - - -bool debug_enable = false; -bool debug_matrix = false; -bool debug_keyboard = false; -bool debug_mouse = false; diff --git a/common/debug.h b/common/debug.h index e16ea14af4..cac682703d 100644 --- a/common/debug.h +++ b/common/debug.h @@ -79,10 +79,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. extern "C" { #endif -extern bool debug_enable; -extern bool debug_matrix; -extern bool debug_keyboard; -extern bool debug_mouse; + +/* NOTE: Not portable. Bit field order depends on implementation */ +typedef union { + uint8_t raw; + struct { + bool enable:1; + bool matrix:1; + bool keyboard:1; + bool mouse:1; + uint8_t reserved:4; + }; +} debug_config_t; +debug_config_t debug_config; + +/* for backward compatibility */ +#define debug_enable (debug_config.enable) +#define debug_matrix (debug_config.matrix) +#define debug_keyboard (debug_config.keyboard) +#define debug_mouse (debug_config.mouse) + #ifdef __cplusplus } diff --git a/common/eeconfig.c b/common/eeconfig.c index cea3810ee3..0481d4b9c3 100644 --- a/common/eeconfig.c +++ b/common/eeconfig.c @@ -3,13 +3,12 @@ #include <avr/eeprom.h> #include "eeconfig.h" - void eeconfig_init(void) { eeprom_write_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER); eeprom_write_byte(EECONFIG_DEBUG, 0); eeprom_write_byte(EECONFIG_DEFAULT_LAYER, 0); - eeprom_write_byte(EECONFIG_KEYCONF, 0); + eeprom_write_byte(EECONFIG_KEYMAP, 0); eeprom_write_byte(EECONFIG_MOUSEKEY_ACCEL, 0); } @@ -25,7 +24,7 @@ void eeconfig_disable(void) bool eeconfig_is_enabled(void) { - return EECONFIG_IS_ENABLED() && (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER); + return (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER); } uint8_t eeconfig_read_debug(void) { return eeprom_read_byte(EECONFIG_DEBUG); } @@ -34,5 +33,5 @@ void eeconfig_write_debug(uint8_t val) { eeprom_write_byte(EECONFIG_DEBUG, val); uint8_t eeconfig_read_defalt_layer(void) { return eeprom_read_byte(EECONFIG_DEFAULT_LAYER); } void eeconfig_write_defalt_layer(uint8_t val) { eeprom_write_byte(EECONFIG_DEFAULT_LAYER, val); } -uint8_t eeconfig_read_keyconf(void) { return eeprom_read_byte(EECONFIG_KEYCONF); } -void eeconfig_write_keyconf(uint8_t val) { eeprom_write_byte(EECONFIG_KEYCONF, val); } +uint8_t eeconfig_read_keymap(void) { return eeprom_read_byte(EECONFIG_KEYMAP); } +void eeconfig_write_keymap(uint8_t val) { eeprom_write_byte(EECONFIG_KEYMAP, val); } diff --git a/common/eeconfig.h b/common/eeconfig.h index 3e195478b5..526cee7836 100644 --- a/common/eeconfig.h +++ b/common/eeconfig.h @@ -20,50 +20,32 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <stdint.h> -#ifndef EECONFIG_IS_ENABLED -#define EECONFIG_IS_ENABLED() true -#endif -#define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEED +#define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEED /* eeprom parameteter address */ -#define EECONFIG_MAGIC (uint16_t *)0 -#define EECONFIG_DEBUG (uint8_t *)2 -#define EECONFIG_DEFAULT_LAYER (uint8_t *)3 -#define EECONFIG_KEYCONF (uint8_t *)4 -#define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5 +#define EECONFIG_MAGIC (uint16_t *)0 +#define EECONFIG_DEBUG (uint8_t *)2 +#define EECONFIG_DEFAULT_LAYER (uint8_t *)3 +#define EECONFIG_KEYMAP (uint8_t *)4 +#define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5 /* debug bit */ -#define EECONFIG_DEBUG_ENABLE (1<<0) -#define EECONFIG_DEBUG_MATRIX (1<<1) -#define EECONFIG_DEBUG_KEYBOARD (1<<2) -#define EECONFIG_DEBUG_MOUSE (1<<3) +#define EECONFIG_DEBUG_ENABLE (1<<0) +#define EECONFIG_DEBUG_MATRIX (1<<1) +#define EECONFIG_DEBUG_KEYBOARD (1<<2) +#define EECONFIG_DEBUG_MOUSE (1<<3) /* keyconf bit */ -#define EECONFIG_KEYCONF_SWAP_CONTROL_CAPSLOCK (1<<0) -#define EECONFIG_KEYCONF_CAPSLOCK_TO_CONTROL (1<<1) -#define EECONFIG_KEYCONF_SWAP_LALT_LGUI (1<<2) -#define EECONFIG_KEYCONF_SWAP_RALT_RGUI (1<<3) -#define EECONFIG_KEYCONF_NO_GUI (1<<4) -#define EECONFIG_KEYCONF_SWAP_GRAVE_ESC (1<<5) -#define EECONFIG_KEYCONF_SWAP_BACKSLASH_BACKSPACE (1<<6) - - -/* XXX: Not portable. Bit field order depends on implementation */ -typedef union { - uint8_t raw; - struct { - bool swap_control_capslock:1; - bool capslock_to_control:1; - bool swap_lalt_lgui:1; - bool swap_ralt_rgui:1; - bool no_gui:1; - bool swap_grave_esc:1; - bool swap_backslash_backspace:1; - bool reserved:1; - }; -} keyconf; +#define EECONFIG_KEYMAP_SWAP_CONTROL_CAPSLOCK (1<<0) +#define EECONFIG_KEYMAP_CAPSLOCK_TO_CONTROL (1<<1) +#define EECONFIG_KEYMAP_SWAP_LALT_LGUI (1<<2) +#define EECONFIG_KEYMAP_SWAP_RALT_RGUI (1<<3) +#define EECONFIG_KEYMAP_NO_GUI (1<<4) +#define EECONFIG_KEYMAP_SWAP_GRAVE_ESC (1<<5) +#define EECONFIG_KEYMAP_SWAP_BACKSLASH_BACKSPACE (1<<6) + bool eeconfig_is_enabled(void); @@ -79,7 +61,7 @@ void eeconfig_write_debug(uint8_t val); uint8_t eeconfig_read_defalt_layer(void); void eeconfig_write_defalt_layer(uint8_t val); -uint8_t eeconfig_read_keyconf(void); -void eeconfig_write_keyconf(uint8_t val); +uint8_t eeconfig_read_keymap(void); +void eeconfig_write_keymap(uint8_t val); #endif diff --git a/common/keyboard.c b/common/keyboard.c index cb0dc06e60..6bc6fae6e2 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -64,18 +64,6 @@ void keyboard_init(void) #ifdef BOOTMAGIC_ENABLE bootmagic(); - - if (eeconfig_is_enabled()) { - uint8_t config; - config = eeconfig_read_debug(); - // ignored if debug is enabled by program before. - if (!debug_enable) debug_enable = (config & EECONFIG_DEBUG_ENABLE); - if (!debug_matrix) debug_matrix = (config & EECONFIG_DEBUG_MATRIX); - if (!debug_keyboard) debug_keyboard = (config & EECONFIG_DEBUG_KEYBOARD); - if (!debug_mouse) debug_mouse = (config & EECONFIG_DEBUG_MOUSE); - } else { - eeconfig_init(); - } #endif } diff --git a/common/keymap.c b/common/keymap.c index 572d922c62..8e2b8607c8 100644 --- a/common/keymap.c +++ b/common/keymap.c @@ -34,6 +34,70 @@ action_t action_for_key(uint8_t layer, key_t key) switch (keycode) { case KC_FN0 ... KC_FN31: return keymap_fn_to_action(keycode); +#ifdef BOOTMAGIC_ENABLE + case KC_CAPSLOCK: + if (keymap_config.swap_control_capslock || keymap_config.capslock_to_control) { + return keycode_to_action(KC_LCTL); + } + return keycode_to_action(KC_CAPS); + case KC_LCTL: + if (keymap_config.swap_control_capslock) { + return keycode_to_action(KC_CAPSLOCK); + } + return keycode_to_action(KC_LCTL); + case KC_LALT: + if (keymap_config.swap_lalt_lgui) { + if (keymap_config.no_gui) { + return keycode_to_action(ACTION_NO); + } + return keycode_to_action(KC_LGUI); + } + return keycode_to_action(KC_LALT); + case KC_LGUI: + if (keymap_config.swap_lalt_lgui) { + return keycode_to_action(KC_LALT); + } + if (keymap_config.no_gui) { + return keycode_to_action(ACTION_NO); + } + return keycode_to_action(KC_LGUI); + case KC_RALT: + if (keymap_config.swap_ralt_rgui) { + if (keymap_config.no_gui) { + return keycode_to_action(ACTION_NO); + } + return keycode_to_action(KC_RGUI); + } + return keycode_to_action(KC_RALT); + case KC_RGUI: + if (keymap_config.swap_ralt_rgui) { + return keycode_to_action(KC_RALT); + } + if (keymap_config.no_gui) { + return keycode_to_action(ACTION_NO); + } + return keycode_to_action(KC_RGUI); + case KC_GRAVE: + if (keymap_config.swap_grave_esc) { + return keycode_to_action(KC_ESC); + } + return keycode_to_action(KC_GRAVE); + case KC_ESC: + if (keymap_config.swap_grave_esc) { + return keycode_to_action(KC_GRAVE); + } + return keycode_to_action(KC_ESC); + case KC_BSLASH: + if (keymap_config.swap_backslash_backspace) { + return keycode_to_action(KC_BSPACE); + } + return keycode_to_action(KC_BSLASH); + case KC_BSPACE: + if (keymap_config.swap_backslash_backspace) { + return keycode_to_action(KC_BSLASH); + } + return keycode_to_action(KC_BSPACE); +#endif default: return keycode_to_action(keycode); } diff --git a/common/keymap.h b/common/keymap.h index 7efd91f704..bf32acedad 100644 --- a/common/keymap.h +++ b/common/keymap.h @@ -23,6 +23,25 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "action.h" +#ifdef BOOTMAGIC_ENABLE +/* NOTE: Not portable. Bit field order depends on implementation */ +typedef union { + uint8_t raw; + struct { + bool swap_control_capslock:1; + bool capslock_to_control:1; + bool swap_lalt_lgui:1; + bool swap_ralt_rgui:1; + bool no_gui:1; + bool swap_grave_esc:1; + bool swap_backslash_backspace:1; + bool reserved:1; + }; +} keymap_config_t; +keymap_config_t keymap_config; +#endif + + /* translates key to keycode */ uint8_t keymap_key_to_keycode(uint8_t layer, key_t key); |