diff options
-rw-r--r-- | docs/feature_auto_shift.md | 2 | ||||
-rw-r--r-- | quantum/process_keycode/process_auto_shift.c | 70 | ||||
-rw-r--r-- | quantum/quantum_keycodes.h | 4 |
3 files changed, 41 insertions, 35 deletions
diff --git a/docs/feature_auto_shift.md b/docs/feature_auto_shift.md index f0b507bc6..b21a7690d 100644 --- a/docs/feature_auto_shift.md +++ b/docs/feature_auto_shift.md | |||
@@ -139,7 +139,7 @@ completely normal and with no intention of shifted keys. | |||
139 | `KC_ASRP`. The keyboard will type by itself the value of your | 139 | `KC_ASRP`. The keyboard will type by itself the value of your |
140 | `AUTO_SHIFT_TIMEOUT`. | 140 | `AUTO_SHIFT_TIMEOUT`. |
141 | 7. Update `AUTO_SHIFT_TIMEOUT` in your `config.h` with the value reported. | 141 | 7. Update `AUTO_SHIFT_TIMEOUT` in your `config.h` with the value reported. |
142 | 8. Remove `AUTO_SHIFT_SETUP` from your `config.h`. | 142 | 8. Add `AUTO_SHIFT_NO_SETUP` to your `config.h`. |
143 | 9. Remove the key bindings `KC_ASDN`, `KC_ASUP` and `KC_ASRP`. | 143 | 9. Remove the key bindings `KC_ASDN`, `KC_ASUP` and `KC_ASRP`. |
144 | 10. Compile and upload your new firmware. | 144 | 10. Compile and upload your new firmware. |
145 | 145 | ||
diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index b474bda69..330037cef 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c | |||
@@ -25,19 +25,6 @@ static uint16_t autoshift_time = 0; | |||
25 | static uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT; | 25 | static uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT; |
26 | static uint16_t autoshift_lastkey = KC_NO; | 26 | static uint16_t autoshift_lastkey = KC_NO; |
27 | 27 | ||
28 | void autoshift_timer_report(void) { | ||
29 | char display[8]; | ||
30 | |||
31 | snprintf(display, 8, "\n%d\n", autoshift_timeout); | ||
32 | |||
33 | send_string((const char *)display); | ||
34 | } | ||
35 | |||
36 | void autoshift_on(uint16_t keycode) { | ||
37 | autoshift_time = timer_read(); | ||
38 | autoshift_lastkey = keycode; | ||
39 | } | ||
40 | |||
41 | void autoshift_flush(void) { | 28 | void autoshift_flush(void) { |
42 | if (autoshift_lastkey != KC_NO) { | 29 | if (autoshift_lastkey != KC_NO) { |
43 | uint16_t elapsed = timer_elapsed(autoshift_time); | 30 | uint16_t elapsed = timer_elapsed(autoshift_time); |
@@ -53,21 +40,36 @@ void autoshift_flush(void) { | |||
53 | } | 40 | } |
54 | } | 41 | } |
55 | 42 | ||
56 | void autoshift_enable(void) { autoshift_enabled = true; } | 43 | void autoshift_on(uint16_t keycode) { |
57 | void autoshift_disable(void) { | 44 | autoshift_time = timer_read(); |
45 | autoshift_lastkey = keycode; | ||
46 | } | ||
47 | |||
48 | void autoshift_toggle(void) { | ||
49 | if (autoshift_enabled) { | ||
58 | autoshift_enabled = false; | 50 | autoshift_enabled = false; |
59 | autoshift_flush(); | 51 | autoshift_flush(); |
52 | } else { | ||
53 | autoshift_enabled = true; | ||
54 | } | ||
60 | } | 55 | } |
61 | 56 | ||
62 | void autoshift_toggle(void) { | 57 | void autoshift_enable(void) { autoshift_enabled = true; } |
63 | if (autoshift_enabled) { | 58 | void autoshift_disable(void) { |
64 | autoshift_enabled = false; | 59 | autoshift_enabled = false; |
65 | autoshift_flush(); | 60 | autoshift_flush(); |
66 | } else { | ||
67 | autoshift_enabled = true; | ||
68 | } | ||
69 | } | 61 | } |
70 | 62 | ||
63 | #ifndef AUTO_SHIFT_NO_SETUP | ||
64 | void autoshift_timer_report(void) { | ||
65 | char display[8]; | ||
66 | |||
67 | snprintf(display, 8, "\n%d\n", autoshift_timeout); | ||
68 | |||
69 | send_string((const char *)display); | ||
70 | } | ||
71 | #endif | ||
72 | |||
71 | bool get_autoshift_state(void) { return autoshift_enabled; } | 73 | bool get_autoshift_state(void) { return autoshift_enabled; } |
72 | 74 | ||
73 | uint16_t get_autoshift_timeout(void) { return autoshift_timeout; } | 75 | uint16_t get_autoshift_timeout(void) { return autoshift_timeout; } |
@@ -77,21 +79,11 @@ void set_autoshift_timeout(uint16_t timeout) { autoshift_timeout = timeout; } | |||
77 | bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { | 79 | bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { |
78 | if (record->event.pressed) { | 80 | if (record->event.pressed) { |
79 | switch (keycode) { | 81 | switch (keycode) { |
80 | case KC_ASUP: | ||
81 | autoshift_timeout += 5; | ||
82 | return true; | ||
83 | |||
84 | case KC_ASDN: | ||
85 | autoshift_timeout -= 5; | ||
86 | return true; | ||
87 | |||
88 | case KC_ASRP: | ||
89 | autoshift_timer_report(); | ||
90 | return true; | ||
91 | 82 | ||
92 | case KC_ASTG: | 83 | case KC_ASTG: |
93 | autoshift_toggle(); | 84 | autoshift_toggle(); |
94 | return true; | 85 | return true; |
86 | |||
95 | case KC_ASON: | 87 | case KC_ASON: |
96 | autoshift_enable(); | 88 | autoshift_enable(); |
97 | return true; | 89 | return true; |
@@ -99,6 +91,18 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { | |||
99 | autoshift_disable(); | 91 | autoshift_disable(); |
100 | return true; | 92 | return true; |
101 | 93 | ||
94 | # ifndef AUTO_SHIFT_NO_SETUP | ||
95 | case KC_ASUP: | ||
96 | autoshift_timeout += 5; | ||
97 | return true; | ||
98 | case KC_ASDN: | ||
99 | autoshift_timeout -= 5; | ||
100 | return true; | ||
101 | |||
102 | case KC_ASRP: | ||
103 | autoshift_timer_report(); | ||
104 | return true; | ||
105 | # endif | ||
102 | # ifndef NO_AUTO_SHIFT_ALPHA | 106 | # ifndef NO_AUTO_SHIFT_ALPHA |
103 | case KC_A ... KC_Z: | 107 | case KC_A ... KC_Z: |
104 | # endif | 108 | # endif |
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 5e7c9ad33..a0a7bc340 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h | |||
@@ -123,10 +123,12 @@ enum quantum_keycodes { | |||
123 | KC_LEAD, | 123 | KC_LEAD, |
124 | #endif | 124 | #endif |
125 | 125 | ||
126 | // Auto Shift setup | 126 | // Auto Shift setup |
127 | #ifndef AUTO_SHIFT_NO_SETUP | ||
127 | KC_ASUP, | 128 | KC_ASUP, |
128 | KC_ASDN, | 129 | KC_ASDN, |
129 | KC_ASRP, | 130 | KC_ASRP, |
131 | #endif | ||
130 | KC_ASTG, | 132 | KC_ASTG, |
131 | KC_ASON, | 133 | KC_ASON, |
132 | KC_ASOFF, | 134 | KC_ASOFF, |