aboutsummaryrefslogtreecommitdiff
path: root/quantum/process_keycode/process_combo.c
diff options
context:
space:
mode:
authorShihpin Tseng <deftsp@gmail.com>2018-08-20 02:16:06 +0800
committerShihpin Tseng <deftsp@gmail.com>2018-08-20 02:29:08 +0800
commit1950a145c7d7c14167c8192b850e6edbadf67dc7 (patch)
tree08a2022d1b6d0bac420f6a0e8a81c1184a8bcf40 /quantum/process_keycode/process_combo.c
parent19fdfccca28f923a12351fbee6c8c8282dca004e (diff)
downloadqmk_firmware-1950a145c7d7c14167c8192b850e6edbadf67dc7.tar.gz
qmk_firmware-1950a145c7d7c14167c8192b850e6edbadf67dc7.zip
Fix process_combo which assign -1 to uint16_t
Diffstat (limited to 'quantum/process_keycode/process_combo.c')
-rw-r--r--quantum/process_keycode/process_combo.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c
index 6e9c28e4f..13f8bbb33 100644
--- a/quantum/process_keycode/process_combo.c
+++ b/quantum/process_keycode/process_combo.c
@@ -18,9 +18,6 @@
18#include "print.h" 18#include "print.h"
19 19
20 20
21#define COMBO_TIMER_ELAPSED -1
22
23
24__attribute__ ((weak)) 21__attribute__ ((weak))
25combo_t key_combos[COMBO_COUNT] = { 22combo_t key_combos[COMBO_COUNT] = {
26 23
@@ -65,7 +62,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
65 if (-1 == (int8_t)index) return false; 62 if (-1 == (int8_t)index) return false;
66 63
67 /* The combos timer is used to signal whether the combo is active */ 64 /* The combos timer is used to signal whether the combo is active */
68 bool is_combo_active = COMBO_TIMER_ELAPSED == combo->timer ? false : true; 65 bool is_combo_active = combo->is_active;
69 66
70 if (record->event.pressed) { 67 if (record->event.pressed) {
71 KEY_STATE_DOWN(index); 68 KEY_STATE_DOWN(index);
@@ -73,9 +70,10 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
73 if (is_combo_active) { 70 if (is_combo_active) {
74 if (ALL_COMBO_KEYS_ARE_DOWN) { /* Combo was pressed */ 71 if (ALL_COMBO_KEYS_ARE_DOWN) { /* Combo was pressed */
75 send_combo(combo->keycode, true); 72 send_combo(combo->keycode, true);
76 combo->timer = COMBO_TIMER_ELAPSED; 73 combo->is_active = false;
77 } else { /* Combo key was pressed */ 74 } else { /* Combo key was pressed */
78 combo->timer = timer_read(); 75 combo->timer = timer_read();
76 combo->is_active = true;
79#ifdef COMBO_ALLOW_ACTION_KEYS 77#ifdef COMBO_ALLOW_ACTION_KEYS
80 combo->prev_record = *record; 78 combo->prev_record = *record;
81#else 79#else
@@ -99,6 +97,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
99 send_keyboard_report(); 97 send_keyboard_report();
100 unregister_code16(keycode); 98 unregister_code16(keycode);
101#endif 99#endif
100 combo->is_active = false;
102 combo->timer = 0; 101 combo->timer = 0;
103 } 102 }
104 103
@@ -106,6 +105,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
106 } 105 }
107 106
108 if (NO_COMBO_KEYS_ARE_DOWN) { 107 if (NO_COMBO_KEYS_ARE_DOWN) {
108 combo->is_active = true;
109 combo->timer = 0; 109 combo->timer = 0;
110 } 110 }
111 111
@@ -132,14 +132,14 @@ void matrix_scan_combo(void)
132 #pragma GCC diagnostic ignored "-Warray-bounds" 132 #pragma GCC diagnostic ignored "-Warray-bounds"
133 combo_t *combo = &key_combos[i]; 133 combo_t *combo = &key_combos[i];
134 #pragma GCC diagnostic pop 134 #pragma GCC diagnostic pop
135 if (combo->timer && 135 if (combo->is_active &&
136 combo->timer != COMBO_TIMER_ELAPSED && 136 combo->timer &&
137 timer_elapsed(combo->timer) > COMBO_TERM) { 137 timer_elapsed(combo->timer) > COMBO_TERM) {
138 138
139 /* This disables the combo, meaning key events for this 139 /* This disables the combo, meaning key events for this
140 * combo will be handled by the next processors in the chain 140 * combo will be handled by the next processors in the chain
141 */ 141 */
142 combo->timer = COMBO_TIMER_ELAPSED; 142 combo->is_active = false;
143 143
144#ifdef COMBO_ALLOW_ACTION_KEYS 144#ifdef COMBO_ALLOW_ACTION_KEYS
145 process_action(&combo->prev_record, 145 process_action(&combo->prev_record,