diff options
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/keycode_config.h | 5 | ||||
| -rw-r--r-- | quantum/keymap.h | 1 | ||||
| -rw-r--r-- | quantum/quantum.c | 124 |
3 files changed, 74 insertions, 56 deletions
diff --git a/quantum/keycode_config.h b/quantum/keycode_config.h index 6216eefc9..c15b0d32f 100644 --- a/quantum/keycode_config.h +++ b/quantum/keycode_config.h | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | #include "eeconfig.h" | 1 | #include "eeconfig.h" |
| 2 | #include "keycode.h" | 2 | #include "keycode.h" |
| 3 | 3 | ||
| 4 | #ifndef KEYCODE_CONFIG_H | ||
| 5 | #define KEYCODE_CONFIG_H | ||
| 6 | |||
| 4 | uint16_t keycode_config(uint16_t keycode); | 7 | uint16_t keycode_config(uint16_t keycode); |
| 5 | 8 | ||
| 6 | /* NOTE: Not portable. Bit field order depends on implementation */ | 9 | /* NOTE: Not portable. Bit field order depends on implementation */ |
| @@ -19,3 +22,5 @@ typedef union { | |||
| 19 | } keymap_config_t; | 22 | } keymap_config_t; |
| 20 | 23 | ||
| 21 | extern keymap_config_t keymap_config; | 24 | extern keymap_config_t keymap_config; |
| 25 | |||
| 26 | #endif /* KEYCODE_CONFIG_H */ | ||
diff --git a/quantum/keymap.h b/quantum/keymap.h index f2d94d75c..98ddfd0c5 100644 --- a/quantum/keymap.h +++ b/quantum/keymap.h | |||
| @@ -111,6 +111,7 @@ enum quantum_keycodes { | |||
| 111 | MAGIC_UNSWAP_BACKSLASH_BACKSPACE, | 111 | MAGIC_UNSWAP_BACKSLASH_BACKSPACE, |
| 112 | MAGIC_UNHOST_NKRO, | 112 | MAGIC_UNHOST_NKRO, |
| 113 | MAGIC_UNSWAP_ALT_GUI, | 113 | MAGIC_UNSWAP_ALT_GUI, |
| 114 | MAGIC_TOGGLE_NKRO, | ||
| 114 | 115 | ||
| 115 | // Leader key | 116 | // Leader key |
| 116 | #ifndef DISABLE_LEADER | 117 | #ifndef DISABLE_LEADER |
diff --git a/quantum/quantum.c b/quantum/quantum.c index fa86b6220..a16bd5443 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -27,10 +27,6 @@ static void do_code16 (uint16_t code, void (*f) (uint8_t)) { | |||
| 27 | f(KC_RGUI); | 27 | f(KC_RGUI); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | #ifdef NKRO_ENABLE | ||
| 31 | extern bool keyboard_nkro; | ||
| 32 | #endif | ||
| 33 | |||
| 34 | void register_code16 (uint16_t code) { | 30 | void register_code16 (uint16_t code) { |
| 35 | do_code16 (code, register_code); | 31 | do_code16 (code, register_code); |
| 36 | register_code (code); | 32 | register_code (code); |
| @@ -203,7 +199,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 203 | return false; | 199 | return false; |
| 204 | break; | 200 | break; |
| 205 | #endif | 201 | #endif |
| 206 | case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_UNSWAP_ALT_GUI: | 202 | case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO: |
| 207 | if (record->event.pressed) { | 203 | if (record->event.pressed) { |
| 208 | // MAGIC actions (BOOTMAGIC without the boot) | 204 | // MAGIC actions (BOOTMAGIC without the boot) |
| 209 | if (!eeconfig_is_enabled()) { | 205 | if (!eeconfig_is_enabled()) { |
| @@ -211,57 +207,73 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 211 | } | 207 | } |
| 212 | /* keymap config */ | 208 | /* keymap config */ |
| 213 | keymap_config.raw = eeconfig_read_keymap(); | 209 | keymap_config.raw = eeconfig_read_keymap(); |
| 214 | if (keycode == MAGIC_SWAP_CONTROL_CAPSLOCK) { | 210 | switch (keycode) |
| 215 | keymap_config.swap_control_capslock = 1; | 211 | { |
| 216 | } else if (keycode == MAGIC_CAPSLOCK_TO_CONTROL) { | 212 | case MAGIC_SWAP_CONTROL_CAPSLOCK: |
| 217 | keymap_config.capslock_to_control = 1; | 213 | keymap_config.swap_control_capslock = true; |
| 218 | } else if (keycode == MAGIC_SWAP_LALT_LGUI) { | 214 | break; |
| 219 | keymap_config.swap_lalt_lgui = 1; | 215 | case MAGIC_CAPSLOCK_TO_CONTROL: |
| 220 | } else if (keycode == MAGIC_SWAP_RALT_RGUI) { | 216 | keymap_config.capslock_to_control = true; |
| 221 | keymap_config.swap_ralt_rgui = 1; | 217 | break; |
| 222 | } else if (keycode == MAGIC_NO_GUI) { | 218 | case MAGIC_SWAP_LALT_LGUI: |
| 223 | keymap_config.no_gui = 1; | 219 | keymap_config.swap_lalt_lgui = true; |
| 224 | } else if (keycode == MAGIC_SWAP_GRAVE_ESC) { | 220 | break; |
| 225 | keymap_config.swap_grave_esc = 1; | 221 | case MAGIC_SWAP_RALT_RGUI: |
| 226 | } else if (keycode == MAGIC_SWAP_BACKSLASH_BACKSPACE) { | 222 | keymap_config.swap_ralt_rgui = true; |
| 227 | keymap_config.swap_backslash_backspace = 1; | 223 | break; |
| 228 | } else if (keycode == MAGIC_HOST_NKRO) { | 224 | case MAGIC_NO_GUI: |
| 229 | keymap_config.nkro = 1; | 225 | keymap_config.no_gui = true; |
| 230 | 226 | break; | |
| 231 | #ifdef NKRO_ENABLE | 227 | case MAGIC_SWAP_GRAVE_ESC: |
| 232 | clear_keyboard(); // clear to prevent stuck keys | 228 | keymap_config.swap_grave_esc = true; |
| 233 | keyboard_nkro = keymap_config.nkro; | 229 | break; |
| 234 | #endif | 230 | case MAGIC_SWAP_BACKSLASH_BACKSPACE: |
| 235 | } else if (keycode == MAGIC_SWAP_ALT_GUI) { | 231 | keymap_config.swap_backslash_backspace = true; |
| 236 | keymap_config.swap_lalt_lgui = 1; | 232 | break; |
| 237 | keymap_config.swap_ralt_rgui = 1; | 233 | case MAGIC_HOST_NKRO: |
| 238 | } | 234 | keymap_config.nkro = true; |
| 239 | /* UNs */ | 235 | break; |
| 240 | else if (keycode == MAGIC_UNSWAP_CONTROL_CAPSLOCK) { | 236 | case MAGIC_SWAP_ALT_GUI: |
| 241 | keymap_config.swap_control_capslock = 0; | 237 | keymap_config.swap_lalt_lgui = true; |
| 242 | } else if (keycode == MAGIC_UNCAPSLOCK_TO_CONTROL) { | 238 | keymap_config.swap_ralt_rgui = true; |
| 243 | keymap_config.capslock_to_control = 0; | 239 | break; |
| 244 | } else if (keycode == MAGIC_UNSWAP_LALT_LGUI) { | 240 | case MAGIC_UNSWAP_CONTROL_CAPSLOCK: |
| 245 | keymap_config.swap_lalt_lgui = 0; | 241 | keymap_config.swap_control_capslock = false; |
| 246 | } else if (keycode == MAGIC_UNSWAP_RALT_RGUI) { | 242 | break; |
| 247 | keymap_config.swap_ralt_rgui = 0; | 243 | case MAGIC_UNCAPSLOCK_TO_CONTROL: |
| 248 | } else if (keycode == MAGIC_UNNO_GUI) { | 244 | keymap_config.capslock_to_control = false; |
| 249 | keymap_config.no_gui = 0; | 245 | break; |
| 250 | } else if (keycode == MAGIC_UNSWAP_GRAVE_ESC) { | 246 | case MAGIC_UNSWAP_LALT_LGUI: |
| 251 | keymap_config.swap_grave_esc = 0; | 247 | keymap_config.swap_lalt_lgui = false; |
| 252 | } else if (keycode == MAGIC_UNSWAP_BACKSLASH_BACKSPACE) { | 248 | break; |
| 253 | keymap_config.swap_backslash_backspace = 0; | 249 | case MAGIC_UNSWAP_RALT_RGUI: |
| 254 | } else if (keycode == MAGIC_UNHOST_NKRO) { | 250 | keymap_config.swap_ralt_rgui = false; |
| 255 | keymap_config.nkro = 0; | 251 | break; |
| 256 | #ifdef NKRO_ENABLE | 252 | case MAGIC_UNNO_GUI: |
| 257 | clear_keyboard(); // clear to prevent stuck keys | 253 | keymap_config.no_gui = false; |
| 258 | keyboard_nkro = keymap_config.nkro; | 254 | break; |
| 259 | #endif | 255 | case MAGIC_UNSWAP_GRAVE_ESC: |
| 260 | } else if (keycode == MAGIC_UNSWAP_ALT_GUI) { | 256 | keymap_config.swap_grave_esc = false; |
| 261 | keymap_config.swap_lalt_lgui = 0; | 257 | break; |
| 262 | keymap_config.swap_ralt_rgui = 0; | 258 | case MAGIC_UNSWAP_BACKSLASH_BACKSPACE: |
| 259 | keymap_config.swap_backslash_backspace = false; | ||
| 260 | break; | ||
| 261 | case MAGIC_UNHOST_NKRO: | ||
| 262 | keymap_config.nkro = false; | ||
| 263 | break; | ||
| 264 | case MAGIC_UNSWAP_ALT_GUI: | ||
| 265 | keymap_config.swap_lalt_lgui = false; | ||
| 266 | keymap_config.swap_ralt_rgui = false; | ||
| 267 | break; | ||
| 268 | case MAGIC_TOGGLE_NKRO: | ||
| 269 | keymap_config.nkro = !keymap_config.nkro; | ||
| 270 | break; | ||
| 271 | default: | ||
| 272 | break; | ||
| 263 | } | 273 | } |
| 264 | eeconfig_update_keymap(keymap_config.raw); | 274 | eeconfig_update_keymap(keymap_config.raw); |
| 275 | clear_keyboard(); // clear to prevent stuck keys | ||
| 276 | |||
| 265 | return false; | 277 | return false; |
| 266 | } | 278 | } |
| 267 | break; | 279 | break; |
| @@ -284,7 +296,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 284 | unregister_mods(MOD_BIT(KC_LSFT)); | 296 | unregister_mods(MOD_BIT(KC_LSFT)); |
| 285 | } | 297 | } |
| 286 | return false; | 298 | return false; |
| 287 | break; | 299 | // break; |
| 288 | } | 300 | } |
| 289 | 301 | ||
| 290 | case KC_RSPC: { | 302 | case KC_RSPC: { |
| @@ -306,7 +318,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 306 | unregister_mods(MOD_BIT(KC_RSFT)); | 318 | unregister_mods(MOD_BIT(KC_RSFT)); |
| 307 | } | 319 | } |
| 308 | return false; | 320 | return false; |
| 309 | break; | 321 | // break; |
| 310 | } | 322 | } |
| 311 | default: { | 323 | default: { |
| 312 | shift_interrupted[0] = true; | 324 | shift_interrupted[0] = true; |
