diff options
Diffstat (limited to 'quantum/quantum.c')
| -rw-r--r-- | quantum/quantum.c | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c index 098312e6e..f653564a6 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | #include "quantum.h" | 1 | #include "quantum.h" |
| 2 | 2 | ||
| 3 | #ifndef TAPPING_TERM | ||
| 4 | #define TAPPING_TERM 200 | ||
| 5 | #endif | ||
| 6 | |||
| 3 | static void do_code16 (uint16_t code, void (*f) (uint8_t)) { | 7 | static void do_code16 (uint16_t code, void (*f) (uint8_t)) { |
| 4 | switch (code) { | 8 | switch (code) { |
| 5 | case QK_MODS ... QK_MODS_MAX: | 9 | case QK_MODS ... QK_MODS_MAX: |
| @@ -75,6 +79,7 @@ void reset_keyboard(void) { | |||
| 75 | #endif | 79 | #endif |
| 76 | 80 | ||
| 77 | static bool shift_interrupted[2] = {0, 0}; | 81 | static bool shift_interrupted[2] = {0, 0}; |
| 82 | static uint16_t scs_timer = 0; | ||
| 78 | 83 | ||
| 79 | bool process_record_quantum(keyrecord_t *record) { | 84 | bool process_record_quantum(keyrecord_t *record) { |
| 80 | 85 | ||
| @@ -129,6 +134,9 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 129 | #ifdef UCIS_ENABLE | 134 | #ifdef UCIS_ENABLE |
| 130 | process_ucis(keycode, record) && | 135 | process_ucis(keycode, record) && |
| 131 | #endif | 136 | #endif |
| 137 | #ifdef PRINTING_ENABLE | ||
| 138 | process_printer(keycode, record) && | ||
| 139 | #endif | ||
| 132 | #ifdef UNICODEMAP_ENABLE | 140 | #ifdef UNICODEMAP_ENABLE |
| 133 | process_unicode_map(keycode, record) && | 141 | process_unicode_map(keycode, record) && |
| 134 | #endif | 142 | #endif |
| @@ -283,6 +291,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 283 | case KC_LSPO: { | 291 | case KC_LSPO: { |
| 284 | if (record->event.pressed) { | 292 | if (record->event.pressed) { |
| 285 | shift_interrupted[0] = false; | 293 | shift_interrupted[0] = false; |
| 294 | scs_timer = timer_read (); | ||
| 286 | register_mods(MOD_BIT(KC_LSFT)); | 295 | register_mods(MOD_BIT(KC_LSFT)); |
| 287 | } | 296 | } |
| 288 | else { | 297 | else { |
| @@ -292,7 +301,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 292 | shift_interrupted[1] = true; | 301 | shift_interrupted[1] = true; |
| 293 | } | 302 | } |
| 294 | #endif | 303 | #endif |
| 295 | if (!shift_interrupted[0]) { | 304 | if (!shift_interrupted[0] && timer_elapsed(scs_timer) < TAPPING_TERM) { |
| 296 | register_code(LSPO_KEY); | 305 | register_code(LSPO_KEY); |
| 297 | unregister_code(LSPO_KEY); | 306 | unregister_code(LSPO_KEY); |
| 298 | } | 307 | } |
| @@ -305,6 +314,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 305 | case KC_RSPC: { | 314 | case KC_RSPC: { |
| 306 | if (record->event.pressed) { | 315 | if (record->event.pressed) { |
| 307 | shift_interrupted[1] = false; | 316 | shift_interrupted[1] = false; |
| 317 | scs_timer = timer_read (); | ||
| 308 | register_mods(MOD_BIT(KC_RSFT)); | 318 | register_mods(MOD_BIT(KC_RSFT)); |
| 309 | } | 319 | } |
| 310 | else { | 320 | else { |
| @@ -314,7 +324,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 314 | shift_interrupted[1] = true; | 324 | shift_interrupted[1] = true; |
| 315 | } | 325 | } |
| 316 | #endif | 326 | #endif |
| 317 | if (!shift_interrupted[1]) { | 327 | if (!shift_interrupted[1] && timer_elapsed(scs_timer) < TAPPING_TERM) { |
| 318 | register_code(RSPC_KEY); | 328 | register_code(RSPC_KEY); |
| 319 | unregister_code(RSPC_KEY); | 329 | unregister_code(RSPC_KEY); |
| 320 | } | 330 | } |
| @@ -799,6 +809,51 @@ void backlight_set(uint8_t level) | |||
| 799 | #endif // backlight | 809 | #endif // backlight |
| 800 | 810 | ||
| 801 | 811 | ||
| 812 | // Functions for spitting out values | ||
| 813 | // | ||
| 814 | |||
| 815 | void send_dword(uint32_t number) { // this might not actually work | ||
| 816 | uint16_t word = (number >> 16); | ||
| 817 | send_word(word); | ||
| 818 | send_word(number & 0xFFFFUL); | ||
| 819 | } | ||
| 820 | |||
| 821 | void send_word(uint16_t number) { | ||
| 822 | uint8_t byte = number >> 8; | ||
| 823 | send_byte(byte); | ||
| 824 | send_byte(number & 0xFF); | ||
| 825 | } | ||
| 826 | |||
| 827 | void send_byte(uint8_t number) { | ||
| 828 | uint8_t nibble = number >> 4; | ||
| 829 | send_nibble(nibble); | ||
| 830 | send_nibble(number & 0xF); | ||
| 831 | } | ||
| 832 | |||
| 833 | void send_nibble(uint8_t number) { | ||
| 834 | switch (number) { | ||
| 835 | case 0: | ||
| 836 | register_code(KC_0); | ||
| 837 | unregister_code(KC_0); | ||
| 838 | break; | ||
| 839 | case 1 ... 9: | ||
| 840 | register_code(KC_1 + (number - 1)); | ||
| 841 | unregister_code(KC_1 + (number - 1)); | ||
| 842 | break; | ||
| 843 | case 0xA ... 0xF: | ||
| 844 | register_code(KC_A + (number - 0xA)); | ||
| 845 | unregister_code(KC_A + (number - 0xA)); | ||
| 846 | break; | ||
| 847 | } | ||
| 848 | } | ||
| 849 | |||
| 850 | void api_send_unicode(uint32_t unicode) { | ||
| 851 | #ifdef API_ENABLE | ||
| 852 | uint8_t chunk[4]; | ||
| 853 | dword_to_bytes(unicode, chunk); | ||
| 854 | MT_SEND_DATA(DT_UNICODE, chunk, 5); | ||
| 855 | #endif | ||
| 856 | } | ||
| 802 | 857 | ||
| 803 | __attribute__ ((weak)) | 858 | __attribute__ ((weak)) |
| 804 | void led_set_user(uint8_t usb_led) { | 859 | void led_set_user(uint8_t usb_led) { |
