]> git.donarmstrong.com Git - tmk_firmware.git/blobdiff - common/bootmagic.c
Merge branch 'rhaberkorn-serial-mouse'
[tmk_firmware.git] / common / bootmagic.c
index 11eef3c3c604d205fbbd737ce75fc6dd4cb61eb7..642d5face42e18bcc79fc17ae172d4224a49f98d 100644 (file)
@@ -5,6 +5,8 @@
 #include "bootloader.h"
 #include "debug.h"
 #include "keymap.h"
+#include "host.h"
+#include "action_layer.h"
 #include "eeconfig.h"
 #include "bootmagic.h"
 
@@ -17,8 +19,10 @@ void bootmagic(void)
     }
 
     /* do scans in case of bounce */
+    print("boogmagic scan: ... ");
     uint8_t scan = 100;
     while (scan--) { matrix_scan(); _delay_ms(10); }
+    print("done.\n");
 
     /* bootmagic skip */
     if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SKIP)) {
@@ -52,7 +56,7 @@ void bootmagic(void)
 
     /* keymap config */
     keymap_config.raw = eeconfig_read_keymap();
-    if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_CONTROL_CPASLOCK)) {
+    if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK)) {
         keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock;
     }
     if (bootmagic_scan_keycode(BOOTMAGIC_KEY_CAPSLOCK_TO_CONTROL)) {
@@ -73,8 +77,15 @@ void bootmagic(void)
     if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_BACKSLASH_BACKSPACE)) {
         keymap_config.swap_backslash_backspace = !keymap_config.swap_backslash_backspace;
     }
+    if (bootmagic_scan_keycode(BOOTMAGIC_HOST_NKRO)) {
+        keymap_config.nkro = !keymap_config.nkro;
+    }
     eeconfig_write_keymap(keymap_config.raw);
 
+#ifdef NKRO_ENABLE
+    keyboard_nkro = keymap_config.nkro;
+#endif
+
     /* default layer */
     uint8_t default_layer = 0;
     if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_0)) { default_layer |= (1<<0); }
@@ -94,7 +105,7 @@ void bootmagic(void)
     }
 }
 
-bool bootmagic_scan_keycode(uint8_t keycode)
+static bool scan_keycode(uint8_t keycode)
 {
     for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
         matrix_row_t matrix_row = matrix_get_row(r);
@@ -108,3 +119,10 @@ bool bootmagic_scan_keycode(uint8_t keycode)
     }
     return false;
 }
+
+bool bootmagic_scan_keycode(uint8_t keycode)
+{
+    if (!scan_keycode(BOOTMAGIC_KEY_SALT)) return false;
+
+    return scan_keycode(keycode);
+}