diff options
Diffstat (limited to 'quantum/quantum.c')
| -rw-r--r-- | quantum/quantum.c | 73 |
1 files changed, 71 insertions, 2 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c index 63ffe2074..d3905decf 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -1,4 +1,7 @@ | |||
| 1 | #include "quantum.h" | 1 | #include "quantum.h" |
| 2 | #ifdef PROTOCOL_LUFA | ||
| 3 | #include "outputselect.h" | ||
| 4 | #endif | ||
| 2 | 5 | ||
| 3 | #ifndef TAPPING_TERM | 6 | #ifndef TAPPING_TERM |
| 4 | #define TAPPING_TERM 200 | 7 | #define TAPPING_TERM 200 |
| @@ -33,14 +36,42 @@ static void do_code16 (uint16_t code, void (*f) (uint8_t)) { | |||
| 33 | f(KC_RGUI); | 36 | f(KC_RGUI); |
| 34 | } | 37 | } |
| 35 | 38 | ||
| 39 | static inline void qk_register_weak_mods(uint8_t kc) { | ||
| 40 | add_weak_mods(MOD_BIT(kc)); | ||
| 41 | send_keyboard_report(); | ||
| 42 | } | ||
| 43 | |||
| 44 | static inline void qk_unregister_weak_mods(uint8_t kc) { | ||
| 45 | del_weak_mods(MOD_BIT(kc)); | ||
| 46 | send_keyboard_report(); | ||
| 47 | } | ||
| 48 | |||
| 49 | static inline void qk_register_mods(uint8_t kc) { | ||
| 50 | add_weak_mods(MOD_BIT(kc)); | ||
| 51 | send_keyboard_report(); | ||
| 52 | } | ||
| 53 | |||
| 54 | static inline void qk_unregister_mods(uint8_t kc) { | ||
| 55 | del_weak_mods(MOD_BIT(kc)); | ||
| 56 | send_keyboard_report(); | ||
| 57 | } | ||
| 58 | |||
| 36 | void register_code16 (uint16_t code) { | 59 | void register_code16 (uint16_t code) { |
| 37 | do_code16 (code, register_code); | 60 | if (IS_MOD(code) || code == KC_NO) { |
| 61 | do_code16 (code, qk_register_mods); | ||
| 62 | } else { | ||
| 63 | do_code16 (code, qk_register_weak_mods); | ||
| 64 | } | ||
| 38 | register_code (code); | 65 | register_code (code); |
| 39 | } | 66 | } |
| 40 | 67 | ||
| 41 | void unregister_code16 (uint16_t code) { | 68 | void unregister_code16 (uint16_t code) { |
| 42 | unregister_code (code); | 69 | unregister_code (code); |
| 43 | do_code16 (code, unregister_code); | 70 | if (IS_MOD(code) || code == KC_NO) { |
| 71 | do_code16 (code, qk_unregister_mods); | ||
| 72 | } else { | ||
| 73 | do_code16 (code, qk_unregister_weak_mods); | ||
| 74 | } | ||
| 44 | } | 75 | } |
| 45 | 76 | ||
| 46 | __attribute__ ((weak)) | 77 | __attribute__ ((weak)) |
| @@ -130,6 +161,9 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 130 | #ifndef DISABLE_CHORDING | 161 | #ifndef DISABLE_CHORDING |
| 131 | process_chording(keycode, record) && | 162 | process_chording(keycode, record) && |
| 132 | #endif | 163 | #endif |
| 164 | #ifdef COMBO_ENABLE | ||
| 165 | process_combo(keycode, record) && | ||
| 166 | #endif | ||
| 133 | #ifdef UNICODE_ENABLE | 167 | #ifdef UNICODE_ENABLE |
| 134 | process_unicode(keycode, record) && | 168 | process_unicode(keycode, record) && |
| 135 | #endif | 169 | #endif |
| @@ -212,6 +246,36 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 212 | return false; | 246 | return false; |
| 213 | break; | 247 | break; |
| 214 | #endif | 248 | #endif |
| 249 | #ifdef PROTOCOL_LUFA | ||
| 250 | case OUT_AUTO: | ||
| 251 | if (record->event.pressed) { | ||
| 252 | set_output(OUTPUT_AUTO); | ||
| 253 | } | ||
| 254 | return false; | ||
| 255 | break; | ||
| 256 | case OUT_USB: | ||
| 257 | if (record->event.pressed) { | ||
| 258 | set_output(OUTPUT_USB); | ||
| 259 | } | ||
| 260 | return false; | ||
| 261 | break; | ||
| 262 | #ifdef BLUETOOTH_ENABLE | ||
| 263 | case OUT_BT: | ||
| 264 | if (record->event.pressed) { | ||
| 265 | set_output(OUTPUT_BLUETOOTH); | ||
| 266 | } | ||
| 267 | return false; | ||
| 268 | break; | ||
| 269 | #endif | ||
| 270 | #ifdef ADAFRUIT_BLE_ENABLE | ||
| 271 | case OUT_BLE: | ||
| 272 | if (record->event.pressed) { | ||
| 273 | set_output(OUTPUT_ADAFRUIT_BLE); | ||
| 274 | } | ||
| 275 | return false; | ||
| 276 | break; | ||
| 277 | #endif | ||
| 278 | #endif | ||
| 215 | case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO: | 279 | case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO: |
| 216 | if (record->event.pressed) { | 280 | if (record->event.pressed) { |
| 217 | // MAGIC actions (BOOTMAGIC without the boot) | 281 | // MAGIC actions (BOOTMAGIC without the boot) |
| @@ -508,6 +572,11 @@ void matrix_scan_quantum() { | |||
| 508 | #ifdef TAP_DANCE_ENABLE | 572 | #ifdef TAP_DANCE_ENABLE |
| 509 | matrix_scan_tap_dance(); | 573 | matrix_scan_tap_dance(); |
| 510 | #endif | 574 | #endif |
| 575 | |||
| 576 | #ifdef COMBO_ENABLE | ||
| 577 | matrix_scan_combo(); | ||
| 578 | #endif | ||
| 579 | |||
| 511 | matrix_scan_kb(); | 580 | matrix_scan_kb(); |
| 512 | } | 581 | } |
| 513 | 582 | ||
