aboutsummaryrefslogtreecommitdiff
path: root/quantum/process_keycode
diff options
context:
space:
mode:
authorGreg Wright <kwip000@protonmail.com>2020-08-15 16:55:13 -0400
committerJames Young <18669334+noroadsleft@users.noreply.github.com>2020-08-29 14:30:02 -0700
commit568cae28ec41acc84a4a60bc3e20120e33ebee89 (patch)
tree11399d2b3865d08a73249ef6ebbdd14e952804ef /quantum/process_keycode
parent167daa9cf8c6376a1c9b92ae7dfaa8bdac21f62a (diff)
downloadqmk_firmware-568cae28ec41acc84a4a60bc3e20120e33ebee89.tar.gz
qmk_firmware-568cae28ec41acc84a4a60bc3e20120e33ebee89.zip
#define AUTO_SHIFT_SETUP (#8441)
* #define AUTO_SHIFT_SETUP * Clarification Changed `#ifndef` to `#ifdef` and moved enable disable outside AUTO_SHIFT_SETUP * AUTO_SHIFT_NO_SETUp
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r--quantum/process_keycode/process_auto_shift.c70
1 files changed, 37 insertions, 33 deletions
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;
25static uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT; 25static uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT;
26static uint16_t autoshift_lastkey = KC_NO; 26static uint16_t autoshift_lastkey = KC_NO;
27 27
28void 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
36void autoshift_on(uint16_t keycode) {
37 autoshift_time = timer_read();
38 autoshift_lastkey = keycode;
39}
40
41void autoshift_flush(void) { 28void 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
56void autoshift_enable(void) { autoshift_enabled = true; } 43void autoshift_on(uint16_t keycode) {
57void autoshift_disable(void) { 44 autoshift_time = timer_read();
45 autoshift_lastkey = keycode;
46}
47
48void 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
62void autoshift_toggle(void) { 57void autoshift_enable(void) { autoshift_enabled = true; }
63 if (autoshift_enabled) { 58void 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
64void 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
71bool get_autoshift_state(void) { return autoshift_enabled; } 73bool get_autoshift_state(void) { return autoshift_enabled; }
72 74
73uint16_t get_autoshift_timeout(void) { return autoshift_timeout; } 75uint16_t get_autoshift_timeout(void) { return autoshift_timeout; }
@@ -77,21 +79,11 @@ void set_autoshift_timeout(uint16_t timeout) { autoshift_timeout = timeout; }
77bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { 79bool 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