aboutsummaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/process_keycode/process_auto_shift.c70
-rw-r--r--quantum/quantum_keycodes.h4
2 files changed, 40 insertions, 34 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
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,