summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
authorIBNobody <IBNobody@users.noreply.github.com>2016-09-06 23:19:01 -0500
committerGitHub <noreply@github.com>2016-09-06 23:19:01 -0500
commit558f3ec1eb325caf706efc15e2fab26121aba442 (patch)
treea14b00c189492426beadc69c2094055f833b811f /quantum
parentf0388a5b1334ce0b8c8a359a0a8a1460e456b8c5 (diff)
Use keyboard config for nkro (#7)
* removing nkro references - wip * changed NKRO to be defined by keymap_config
Diffstat (limited to 'quantum')
-rw-r--r--quantum/keycode_config.h5
-rw-r--r--quantum/keymap.h1
-rw-r--r--quantum/quantum.c124
3 files changed, 74 insertions, 56 deletions
diff --git a/quantum/keycode_config.h b/quantum/keycode_config.h
index 6216eefc90..c15b0d32f8 100644
--- a/quantum/keycode_config.h
+++ b/quantum/keycode_config.h
@@ -1,6 +1,9 @@
#include "eeconfig.h"
#include "keycode.h"
+#ifndef KEYCODE_CONFIG_H
+#define KEYCODE_CONFIG_H
+
uint16_t keycode_config(uint16_t keycode);
/* NOTE: Not portable. Bit field order depends on implementation */
@@ -19,3 +22,5 @@ typedef union {
} keymap_config_t;
extern keymap_config_t keymap_config;
+
+#endif /* KEYCODE_CONFIG_H */
diff --git a/quantum/keymap.h b/quantum/keymap.h
index f2d94d75c3..98ddfd0c53 100644
--- a/quantum/keymap.h
+++ b/quantum/keymap.h
@@ -111,6 +111,7 @@ enum quantum_keycodes {
MAGIC_UNSWAP_BACKSLASH_BACKSPACE,
MAGIC_UNHOST_NKRO,
MAGIC_UNSWAP_ALT_GUI,
+ MAGIC_TOGGLE_NKRO,
// Leader key
#ifndef DISABLE_LEADER
diff --git a/quantum/quantum.c b/quantum/quantum.c
index fa86b6220f..a16bd5443c 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -27,10 +27,6 @@ static void do_code16 (uint16_t code, void (*f) (uint8_t)) {
f(KC_RGUI);
}
-#ifdef NKRO_ENABLE
- extern bool keyboard_nkro;
-#endif
-
void register_code16 (uint16_t code) {
do_code16 (code, register_code);
register_code (code);
@@ -203,7 +199,7 @@ bool process_record_quantum(keyrecord_t *record) {
return false;
break;
#endif
- case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_UNSWAP_ALT_GUI:
+ case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO:
if (record->event.pressed) {
// MAGIC actions (BOOTMAGIC without the boot)
if (!eeconfig_is_enabled()) {
@@ -211,57 +207,73 @@ bool process_record_quantum(keyrecord_t *record) {
}
/* keymap config */
keymap_config.raw = eeconfig_read_keymap();
- if (keycode == MAGIC_SWAP_CONTROL_CAPSLOCK) {
- keymap_config.swap_control_capslock = 1;
- } else if (keycode == MAGIC_CAPSLOCK_TO_CONTROL) {
- keymap_config.capslock_to_control = 1;
- } else if (keycode == MAGIC_SWAP_LALT_LGUI) {
- keymap_config.swap_lalt_lgui = 1;
- } else if (keycode == MAGIC_SWAP_RALT_RGUI) {
- keymap_config.swap_ralt_rgui = 1;
- } else if (keycode == MAGIC_NO_GUI) {
- keymap_config.no_gui = 1;
- } else if (keycode == MAGIC_SWAP_GRAVE_ESC) {
- keymap_config.swap_grave_esc = 1;
- } else if (keycode == MAGIC_SWAP_BACKSLASH_BACKSPACE) {
- keymap_config.swap_backslash_backspace = 1;
- } else if (keycode == MAGIC_HOST_NKRO) {
- keymap_config.nkro = 1;
-
-#ifdef NKRO_ENABLE
- clear_keyboard(); // clear to prevent stuck keys
- keyboard_nkro = keymap_config.nkro;
-#endif
- } else if (keycode == MAGIC_SWAP_ALT_GUI) {
- keymap_config.swap_lalt_lgui = 1;
- keymap_config.swap_ralt_rgui = 1;
- }
- /* UNs */
- else if (keycode == MAGIC_UNSWAP_CONTROL_CAPSLOCK) {
- keymap_config.swap_control_capslock = 0;
- } else if (keycode == MAGIC_UNCAPSLOCK_TO_CONTROL) {
- keymap_config.capslock_to_control = 0;
- } else if (keycode == MAGIC_UNSWAP_LALT_LGUI) {
- keymap_config.swap_lalt_lgui = 0;
- } else if (keycode == MAGIC_UNSWAP_RALT_RGUI) {
- keymap_config.swap_ralt_rgui = 0;
- } else if (keycode == MAGIC_UNNO_GUI) {
- keymap_config.no_gui = 0;
- } else if (keycode == MAGIC_UNSWAP_GRAVE_ESC) {
- keymap_config.swap_grave_esc = 0;
- } else if (keycode == MAGIC_UNSWAP_BACKSLASH_BACKSPACE) {
- keymap_config.swap_backslash_backspace = 0;
- } else if (keycode == MAGIC_UNHOST_NKRO) {
- keymap_config.nkro = 0;
-#ifdef NKRO_ENABLE
- clear_keyboard(); // clear to prevent stuck keys
- keyboard_nkro = keymap_config.nkro;
-#endif
- } else if (keycode == MAGIC_UNSWAP_ALT_GUI) {
- keymap_config.swap_lalt_lgui = 0;
- keymap_config.swap_ralt_rgui = 0;
+ switch (keycode)
+ {
+ case MAGIC_SWAP_CONTROL_CAPSLOCK:
+ keymap_config.swap_control_capslock = true;
+ break;
+ case MAGIC_CAPSLOCK_TO_CONTROL:
+ keymap_config.capslock_to_control = true;
+ break;
+ case MAGIC_SWAP_LALT_LGUI:
+ keymap_config.swap_lalt_lgui = true;
+ break;
+ case MAGIC_SWAP_RALT_RGUI:
+ keymap_config.swap_ralt_rgui = true;
+ break;
+ case MAGIC_NO_GUI:
+ keymap_config.no_gui = true;
+ break;
+ case MAGIC_SWAP_GRAVE_ESC:
+ keymap_config.swap_grave_esc = true;
+ break;
+ case MAGIC_SWAP_BACKSLASH_BACKSPACE:
+ keymap_config.swap_backslash_backspace = true;
+ break;
+ case MAGIC_HOST_NKRO:
+ keymap_config.nkro = true;
+ break;
+ case MAGIC_SWAP_ALT_GUI:
+ keymap_config.swap_lalt_lgui = true;
+ keymap_config.swap_ralt_rgui = true;
+ break;
+ case MAGIC_UNSWAP_CONTROL_CAPSLOCK:
+ keymap_config.swap_control_capslock = false;
+ break;
+ case MAGIC_UNCAPSLOCK_TO_CONTROL:
+ keymap_config.capslock_to_control = false;
+ break;
+ case MAGIC_UNSWAP_LALT_LGUI:
+ keymap_config.swap_lalt_lgui = false;
+ break;
+ case MAGIC_UNSWAP_RALT_RGUI:
+ keymap_config.swap_ralt_rgui = false;
+ break;
+ case MAGIC_UNNO_GUI:
+ keymap_config.no_gui = false;
+ break;
+ case MAGIC_UNSWAP_GRAVE_ESC:
+ keymap_config.swap_grave_esc = false;
+ break;
+ case MAGIC_UNSWAP_BACKSLASH_BACKSPACE:
+ keymap_config.swap_backslash_backspace = false;
+ break;
+ case MAGIC_UNHOST_NKRO:
+ keymap_config.nkro = false;
+ break;
+ case MAGIC_UNSWAP_ALT_GUI:
+ keymap_config.swap_lalt_lgui = false;
+ keymap_config.swap_ralt_rgui = false;
+ break;
+ case MAGIC_TOGGLE_NKRO:
+ keymap_config.nkro = !keymap_config.nkro;
+ break;
+ default:
+ break;
}
eeconfig_update_keymap(keymap_config.raw);
+ clear_keyboard(); // clear to prevent stuck keys
+
return false;
}
break;
@@ -284,7 +296,7 @@ bool process_record_quantum(keyrecord_t *record) {
unregister_mods(MOD_BIT(KC_LSFT));
}
return false;
- break;
+ // break;
}
case KC_RSPC: {
@@ -306,7 +318,7 @@ bool process_record_quantum(keyrecord_t *record) {
unregister_mods(MOD_BIT(KC_RSFT));
}
return false;
- break;
+ // break;
}
default: {
shift_interrupted[0] = true;