aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md23
-rw-r--r--common.mk1
-rw-r--r--common/bootmagic.c71
-rw-r--r--common/bootmagic.h78
-rw-r--r--common/command.c48
-rw-r--r--common/debug.c8
-rw-r--r--common/debug.h24
-rw-r--r--common/eeconfig.c9
-rw-r--r--common/eeconfig.h58
-rw-r--r--common/keyboard.c12
-rw-r--r--common/keymap.c64
-rw-r--r--common/keymap.h19
12 files changed, 246 insertions, 169 deletions
diff --git a/README.md b/README.md
index 998d99a00..eccb1bd77 100644
--- a/README.md
+++ b/README.md
@@ -106,6 +106,8 @@ Following commands can be also executed with `Magic` + key. In console mode `Mag
v: print device version & info
t: print timer count
s: print status
+ e: print eeprom config
+ n: toggle NKRO
0/F10: switch to Layer0
1/F1: switch to Layer1
2/F2: switch to Layer2
@@ -117,13 +119,24 @@ Following commands can be also executed with `Magic` + key. In console mode `Mag
**TBD**
-### Conguration with Boot Magic
+### Boot Magic Configuration - Virtual DIP Switch
Boot Magic are executed during boot up time. Press Magic key below then pulgin keyboard cable.
-These settings are stored in EEPROM.
+Note that you must use keys of **Layer 0** as Magic keys. These settings are stored in EEPROM so that retain your configure over power cycles.
+#### EEPROM
+- Skip reading EEPROM(`ESC`)
- Clear configuration stored in EEPROM(`Backspace`)
+
+#### Bootloader
- Kick up Bootloader(`B`)
+
+#### Debug
- Debug enable(`D`)
+- Debug matrix enable(`D`+`X`)
+- Debug keyboard enable(`D`+`K`)
+- Debug mouse enable(`D`+`M`)
+
+#### Keymap
- Swap Control and CapsLock(`Left Control`)
- Change CapsLock to Control(`Casp Lock`)
- Swap LeftAlt and Gui(`Left Alt`)
@@ -132,6 +145,12 @@ These settings are stored in EEPROM.
- Swap Grave and Escape(`Grave`)
- Swap BackSlash and BackSpace(`Back Slash`)
+#### Default Layer
+- Set Default Layer to 0(`0`)
+- Set Default Layer to 0(`1`)
+- Set Default Layer to 0(`2`)
+- Set Default Layer to 0(`3`)
+
**TBD**
diff --git a/common.mk b/common.mk
index 6759e6ef9..810f802c6 100644
--- a/common.mk
+++ b/common.mk
@@ -9,7 +9,6 @@ SRC += $(COMMON_DIR)/host.c \
$(COMMON_DIR)/keymap.c \
$(COMMON_DIR)/timer.c \
$(COMMON_DIR)/print.c \
- $(COMMON_DIR)/debug.c \
$(COMMON_DIR)/bootloader.c \
$(COMMON_DIR)/suspend.c \
$(COMMON_DIR)/util.c
diff --git a/common/bootmagic.c b/common/bootmagic.c
index 388099e2e..716f5d956 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 5791b221f..2e7496ebc 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 3a1fcb186..216ad0612 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 e406d39b0..000000000
--- 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 e16ea14af..cac682703 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 cea3810ee..0481d4b9c 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 3e195478b..526cee783 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 cb0dc06e6..6bc6fae6e 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 572d922c6..8e2b8607c 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 7efd91f70..bf32aceda 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);