aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/qwiic/micro_oled.c2
-rw-r--r--drivers/sensors/adns5050.c23
-rw-r--r--drivers/sensors/adns5050.h18
-rw-r--r--drivers/sensors/adns9800.c119
-rw-r--r--drivers/sensors/adns9800.h4
-rw-r--r--drivers/sensors/pmw3360.c96
-rw-r--r--drivers/sensors/pmw3360.h19
-rw-r--r--keyboards/checkerboards/phoenix45_ortho/keymaps/via/rules.mk2
-rw-r--r--keyboards/sneakbox/ava/info.json2
-rw-r--r--platforms/chibios/drivers/analog.c2
-rw-r--r--quantum/action.c83
-rw-r--r--quantum/action.h2
-rw-r--r--quantum/action_tapping.c38
-rw-r--r--quantum/debounce/asym_eager_defer_pk.c22
-rw-r--r--quantum/debounce/sym_defer_g.c2
-rw-r--r--quantum/debounce/sym_defer_pk.c6
-rw-r--r--quantum/debounce/sym_eager_pk.c8
-rw-r--r--quantum/debounce/sym_eager_pr.c8
-rw-r--r--quantum/debounce/tests/asym_eager_defer_pk_tests.cpp66
-rw-r--r--quantum/debounce/tests/debounce_test_common.cpp72
-rw-r--r--quantum/debounce/tests/debounce_test_common.h24
-rw-r--r--quantum/debounce/tests/sym_defer_g_tests.cpp45
-rw-r--r--quantum/debounce/tests/sym_defer_pk_tests.cpp45
-rw-r--r--quantum/debounce/tests/sym_eager_pk_tests.cpp48
-rw-r--r--quantum/debounce/tests/sym_eager_pr_tests.cpp57
-rw-r--r--quantum/keymap_extras/keymap_steno.h3
-rw-r--r--quantum/process_keycode/process_combo.c184
-rw-r--r--quantum/process_keycode/process_combo.h4
-rw-r--r--quantum/process_keycode/process_steno.c9
-rw-r--r--quantum/quantum.c11
-rw-r--r--quantum/quantum_keycodes.h12
-rw-r--r--quantum/split_common/transactions.c48
-rw-r--r--tmk_core/common/chibios/sleep_led.c4
-rw-r--r--tmk_core/common/report.c4
-rw-r--r--tmk_core/protocol/ps2_mouse.c4
35 files changed, 578 insertions, 518 deletions
diff --git a/drivers/qwiic/micro_oled.c b/drivers/qwiic/micro_oled.c
index 8dfff6968..d011ad225 100644
--- a/drivers/qwiic/micro_oled.c
+++ b/drivers/qwiic/micro_oled.c
@@ -149,7 +149,7 @@ void micro_oled_init(void) {
149#endif 149#endif
150 150
151 send_command(MEMORYMODE); 151 send_command(MEMORYMODE);
152 send_command(0x02); // 0x02 = 10b, Page addressing mode 152 send_command(0x02); // 0x02 = 10b, Page addressing mode
153 153
154 send_command(SETCOMPINS); // 0xDA 154 send_command(SETCOMPINS); // 0xDA
155 if (LCDHEIGHT > 32) { 155 if (LCDHEIGHT > 32) {
diff --git a/drivers/sensors/adns5050.c b/drivers/sensors/adns5050.c
index e7273977d..254ef2ee8 100644
--- a/drivers/sensors/adns5050.c
+++ b/drivers/sensors/adns5050.c
@@ -17,7 +17,6 @@
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */ 18 */
19 19
20
21#include "adns5050.h" 20#include "adns5050.h"
22#include "wait.h" 21#include "wait.h"
23#include "debug.h" 22#include "debug.h"
@@ -61,13 +60,9 @@ void adns_sync(void) {
61 writePinHigh(ADNS_CS_PIN); 60 writePinHigh(ADNS_CS_PIN);
62} 61}
63 62
64void adns_cs_select(void) { 63void adns_cs_select(void) { writePinLow(ADNS_CS_PIN); }
65 writePinLow(ADNS_CS_PIN);
66}
67 64
68void adns_cs_deselect(void) { 65void adns_cs_deselect(void) { writePinHigh(ADNS_CS_PIN); }
69 writePinHigh(ADNS_CS_PIN);
70}
71 66
72uint8_t adns_serial_read(void) { 67uint8_t adns_serial_read(void) {
73 setPinInput(ADNS_SDIO_PIN); 68 setPinInput(ADNS_SDIO_PIN);
@@ -121,7 +116,7 @@ uint8_t adns_read_reg(uint8_t reg_addr) {
121 // We don't need a minimum tSRAD here. That's because a 4ms wait time is 116 // We don't need a minimum tSRAD here. That's because a 4ms wait time is
122 // already included in adns_serial_write(), so we're good. 117 // already included in adns_serial_write(), so we're good.
123 // See page 10 and 15 of the ADNS spec sheet. 118 // See page 10 and 15 of the ADNS spec sheet.
124 //wait_us(4); 119 // wait_us(4);
125 120
126 uint8_t byte = adns_serial_read(); 121 uint8_t byte = adns_serial_read();
127 122
@@ -138,7 +133,7 @@ uint8_t adns_read_reg(uint8_t reg_addr) {
138 133
139void adns_write_reg(uint8_t reg_addr, uint8_t data) { 134void adns_write_reg(uint8_t reg_addr, uint8_t data) {
140 adns_cs_select(); 135 adns_cs_select();
141 adns_serial_write( 0b10000000 | reg_addr ); 136 adns_serial_write(0b10000000 | reg_addr);
142 adns_serial_write(data); 137 adns_serial_write(data);
143 adns_cs_deselect(); 138 adns_cs_deselect();
144} 139}
@@ -155,7 +150,7 @@ report_adns_t adns_read_burst(void) {
155 // We don't need a minimum tSRAD here. That's because a 4ms wait time is 150 // We don't need a minimum tSRAD here. That's because a 4ms wait time is
156 // already included in adns_serial_write(), so we're good. 151 // already included in adns_serial_write(), so we're good.
157 // See page 10 and 15 of the ADNS spec sheet. 152 // See page 10 and 15 of the ADNS spec sheet.
158 //wait_us(4); 153 // wait_us(4);
159 154
160 uint8_t x = adns_serial_read(); 155 uint8_t x = adns_serial_read();
161 uint8_t y = adns_serial_read(); 156 uint8_t y = adns_serial_read();
@@ -180,13 +175,11 @@ int8_t convert_twoscomp(uint8_t data) {
180} 175}
181 176
182// Don't forget to use the definitions for CPI in the header file. 177// Don't forget to use the definitions for CPI in the header file.
183void adns_set_cpi(uint8_t cpi) { 178void adns_set_cpi(uint8_t cpi) { adns_write_reg(REG_MOUSE_CONTROL2, cpi); }
184 adns_write_reg(REG_MOUSE_CONTROL2, cpi);
185}
186 179
187bool adns_check_signature(void) { 180bool adns_check_signature(void) {
188 uint8_t pid = adns_read_reg(REG_PRODUCT_ID); 181 uint8_t pid = adns_read_reg(REG_PRODUCT_ID);
189 uint8_t rid = adns_read_reg(REG_REVISION_ID); 182 uint8_t rid = adns_read_reg(REG_REVISION_ID);
190 uint8_t pid2 = adns_read_reg(REG_PRODUCT_ID2); 183 uint8_t pid2 = adns_read_reg(REG_PRODUCT_ID2);
191 184
192 return (pid == 0x12 && rid == 0x01 && pid2 == 0x26); 185 return (pid == 0x12 && rid == 0x01 && pid2 == 0x26);
diff --git a/drivers/sensors/adns5050.h b/drivers/sensors/adns5050.h
index ff8e8f78e..5e9edc296 100644
--- a/drivers/sensors/adns5050.h
+++ b/drivers/sensors/adns5050.h
@@ -67,13 +67,13 @@ typedef struct {
67// A bunch of functions to implement the ADNS5050-specific serial protocol. 67// A bunch of functions to implement the ADNS5050-specific serial protocol.
68// Note that the "serial.h" driver is insufficient, because it does not 68// Note that the "serial.h" driver is insufficient, because it does not
69// manually manipulate a serial clock signal. 69// manually manipulate a serial clock signal.
70void adns_init(void); 70void adns_init(void);
71void adns_sync(void); 71void adns_sync(void);
72uint8_t adns_serial_read(void); 72uint8_t adns_serial_read(void);
73void adns_serial_write(uint8_t data); 73void adns_serial_write(uint8_t data);
74uint8_t adns_read_reg(uint8_t reg_addr); 74uint8_t adns_read_reg(uint8_t reg_addr);
75void adns_write_reg(uint8_t reg_addr, uint8_t data); 75void adns_write_reg(uint8_t reg_addr, uint8_t data);
76report_adns_t adns_read_burst(void); 76report_adns_t adns_read_burst(void);
77int8_t convert_twoscomp(uint8_t data); 77int8_t convert_twoscomp(uint8_t data);
78void adns_set_cpi(uint8_t cpi); 78void adns_set_cpi(uint8_t cpi);
79bool adns_check_signature(void); 79bool adns_check_signature(void);
diff --git a/drivers/sensors/adns9800.c b/drivers/sensors/adns9800.c
index 17966b81f..b4f683452 100644
--- a/drivers/sensors/adns9800.c
+++ b/drivers/sensors/adns9800.c
@@ -20,57 +20,57 @@
20#include "adns9800.h" 20#include "adns9800.h"
21 21
22// registers 22// registers
23#define REG_Product_ID 0x00 23#define REG_Product_ID 0x00
24#define REG_Revision_ID 0x01 24#define REG_Revision_ID 0x01
25#define REG_Motion 0x02 25#define REG_Motion 0x02
26#define REG_Delta_X_L 0x03 26#define REG_Delta_X_L 0x03
27#define REG_Delta_X_H 0x04 27#define REG_Delta_X_H 0x04
28#define REG_Delta_Y_L 0x05 28#define REG_Delta_Y_L 0x05
29#define REG_Delta_Y_H 0x06 29#define REG_Delta_Y_H 0x06
30#define REG_SQUAL 0x07 30#define REG_SQUAL 0x07
31#define REG_Pixel_Sum 0x08 31#define REG_Pixel_Sum 0x08
32#define REG_Maximum_Pixel 0x09 32#define REG_Maximum_Pixel 0x09
33#define REG_Minimum_Pixel 0x0a 33#define REG_Minimum_Pixel 0x0a
34#define REG_Shutter_Lower 0x0b 34#define REG_Shutter_Lower 0x0b
35#define REG_Shutter_Upper 0x0c 35#define REG_Shutter_Upper 0x0c
36#define REG_Frame_Period_Lower 0x0d 36#define REG_Frame_Period_Lower 0x0d
37#define REG_Frame_Period_Upper 0x0e 37#define REG_Frame_Period_Upper 0x0e
38#define REG_Configuration_I 0x0f 38#define REG_Configuration_I 0x0f
39#define REG_Configuration_II 0x10 39#define REG_Configuration_II 0x10
40#define REG_Frame_Capture 0x12 40#define REG_Frame_Capture 0x12
41#define REG_SROM_Enable 0x13 41#define REG_SROM_Enable 0x13
42#define REG_Run_Downshift 0x14 42#define REG_Run_Downshift 0x14
43#define REG_Rest1_Rate 0x15 43#define REG_Rest1_Rate 0x15
44#define REG_Rest1_Downshift 0x16 44#define REG_Rest1_Downshift 0x16
45#define REG_Rest2_Rate 0x17 45#define REG_Rest2_Rate 0x17
46#define REG_Rest2_Downshift 0x18 46#define REG_Rest2_Downshift 0x18
47#define REG_Rest3_Rate 0x19 47#define REG_Rest3_Rate 0x19
48#define REG_Frame_Period_Max_Bound_Lower 0x1a 48#define REG_Frame_Period_Max_Bound_Lower 0x1a
49#define REG_Frame_Period_Max_Bound_Upper 0x1b 49#define REG_Frame_Period_Max_Bound_Upper 0x1b
50#define REG_Frame_Period_Min_Bound_Lower 0x1c 50#define REG_Frame_Period_Min_Bound_Lower 0x1c
51#define REG_Frame_Period_Min_Bound_Upper 0x1d 51#define REG_Frame_Period_Min_Bound_Upper 0x1d
52#define REG_Shutter_Max_Bound_Lower 0x1e 52#define REG_Shutter_Max_Bound_Lower 0x1e
53#define REG_Shutter_Max_Bound_Upper 0x1f 53#define REG_Shutter_Max_Bound_Upper 0x1f
54#define REG_LASER_CTRL0 0x20 54#define REG_LASER_CTRL0 0x20
55#define REG_Observation 0x24 55#define REG_Observation 0x24
56#define REG_Data_Out_Lower 0x25 56#define REG_Data_Out_Lower 0x25
57#define REG_Data_Out_Upper 0x26 57#define REG_Data_Out_Upper 0x26
58#define REG_SROM_ID 0x2a 58#define REG_SROM_ID 0x2a
59#define REG_Lift_Detection_Thr 0x2e 59#define REG_Lift_Detection_Thr 0x2e
60#define REG_Configuration_V 0x2f 60#define REG_Configuration_V 0x2f
61#define REG_Configuration_IV 0x39 61#define REG_Configuration_IV 0x39
62#define REG_Power_Up_Reset 0x3a 62#define REG_Power_Up_Reset 0x3a
63#define REG_Shutdown 0x3b 63#define REG_Shutdown 0x3b
64#define REG_Inverse_Product_ID 0x3f 64#define REG_Inverse_Product_ID 0x3f
65#define REG_Motion_Burst 0x50 65#define REG_Motion_Burst 0x50
66#define REG_SROM_Load_Burst 0x62 66#define REG_SROM_Load_Burst 0x62
67#define REG_Pixel_Burst 0x64 67#define REG_Pixel_Burst 0x64
68 68
69#define ADNS_CLOCK_SPEED 2000000 69#define ADNS_CLOCK_SPEED 2000000
70#define MIN_CPI 200 70#define MIN_CPI 200
71#define MAX_CPI 8200 71#define MAX_CPI 8200
72#define CPI_STEP 200 72#define CPI_STEP 200
73#define CLAMP_CPI(value) value < MIN_CPI ? MIN_CPI : value > MAX_CPI ? MAX_CPI : value 73#define CLAMP_CPI(value) value<MIN_CPI ? MIN_CPI : value> MAX_CPI ? MAX_CPI : value
74#define SPI_MODE 3 74#define SPI_MODE 3
75#define SPI_DIVISOR (F_CPU / ADNS_CLOCK_SPEED) 75#define SPI_DIVISOR (F_CPU / ADNS_CLOCK_SPEED)
76#define US_BETWEEN_WRITES 120 76#define US_BETWEEN_WRITES 120
@@ -80,12 +80,9 @@
80 80
81extern const uint8_t firmware_data[]; 81extern const uint8_t firmware_data[];
82 82
83void adns_spi_start(void){ 83void adns_spi_start(void) { spi_start(SPI_SS_PIN, false, SPI_MODE, SPI_DIVISOR); }
84 spi_start(SPI_SS_PIN, false, SPI_MODE, SPI_DIVISOR);
85}
86
87void adns_write(uint8_t reg_addr, uint8_t data){
88 84
85void adns_write(uint8_t reg_addr, uint8_t data) {
89 adns_spi_start(); 86 adns_spi_start();
90 spi_write(reg_addr | MSB1); 87 spi_write(reg_addr | MSB1);
91 spi_write(data); 88 spi_write(data);
@@ -93,10 +90,9 @@ void adns_write(uint8_t reg_addr, uint8_t data){
93 wait_us(US_BETWEEN_WRITES); 90 wait_us(US_BETWEEN_WRITES);
94} 91}
95 92
96uint8_t adns_read(uint8_t reg_addr){ 93uint8_t adns_read(uint8_t reg_addr) {
97
98 adns_spi_start(); 94 adns_spi_start();
99 spi_write(reg_addr & 0x7f ); 95 spi_write(reg_addr & 0x7f);
100 uint8_t data = spi_read(); 96 uint8_t data = spi_read();
101 spi_stop(); 97 spi_stop();
102 wait_us(US_BETWEEN_READS); 98 wait_us(US_BETWEEN_READS);
@@ -105,7 +101,6 @@ uint8_t adns_read(uint8_t reg_addr){
105} 101}
106 102
107void adns_init() { 103void adns_init() {
108
109 setPinOutput(SPI_SS_PIN); 104 setPinOutput(SPI_SS_PIN);
110 105
111 spi_init(); 106 spi_init();
@@ -144,7 +139,7 @@ void adns_init() {
144 139
145 // send all bytes of the firmware 140 // send all bytes of the firmware
146 unsigned char c; 141 unsigned char c;
147 for(int i = 0; i < FIRMWARE_LENGTH; i++){ 142 for (int i = 0; i < FIRMWARE_LENGTH; i++) {
148 c = (unsigned char)pgm_read_byte(firmware_data + i); 143 c = (unsigned char)pgm_read_byte(firmware_data + i);
149 spi_write(c); 144 spi_write(c);
150 wait_us(15); 145 wait_us(15);
@@ -161,7 +156,7 @@ void adns_init() {
161 156
162config_adns_t adns_get_config(void) { 157config_adns_t adns_get_config(void) {
163 uint8_t config_1 = adns_read(REG_Configuration_I); 158 uint8_t config_1 = adns_read(REG_Configuration_I);
164 return (config_adns_t){ (config_1 & 0xFF) * CPI_STEP }; 159 return (config_adns_t){(config_1 & 0xFF) * CPI_STEP};
165} 160}
166 161
167void adns_set_config(config_adns_t config) { 162void adns_set_config(config_adns_t config) {
@@ -169,20 +164,17 @@ void adns_set_config(config_adns_t config) {
169 adns_write(REG_Configuration_I, config_1); 164 adns_write(REG_Configuration_I, config_1);
170} 165}
171 166
172static int16_t convertDeltaToInt(uint8_t high, uint8_t low){ 167static int16_t convertDeltaToInt(uint8_t high, uint8_t low) {
173
174 // join bytes into twos compliment 168 // join bytes into twos compliment
175 uint16_t twos_comp = (high << 8) | low; 169 uint16_t twos_comp = (high << 8) | low;
176 170
177 // convert twos comp to int 171 // convert twos comp to int
178 if (twos_comp & 0x8000) 172 if (twos_comp & 0x8000) return -1 * (~twos_comp + 1);
179 return -1 * (~twos_comp + 1);
180 173
181 return twos_comp; 174 return twos_comp;
182} 175}
183 176
184report_adns_t adns_get_report(void) { 177report_adns_t adns_get_report(void) {
185
186 report_adns_t report = {0, 0}; 178 report_adns_t report = {0, 0};
187 179
188 adns_spi_start(); 180 adns_spi_start();
@@ -194,8 +186,7 @@ report_adns_t adns_get_report(void) {
194 186
195 uint8_t motion = spi_read(); 187 uint8_t motion = spi_read();
196 188
197 if(motion & 0x80) { 189 if (motion & 0x80) {
198
199 // clear observation register 190 // clear observation register
200 spi_read(); 191 spi_read();
201 192
diff --git a/drivers/sensors/adns9800.h b/drivers/sensors/adns9800.h
index 2f50b8f1b..d19ded401 100644
--- a/drivers/sensors/adns9800.h
+++ b/drivers/sensors/adns9800.h
@@ -28,8 +28,8 @@ typedef struct {
28 int16_t y; 28 int16_t y;
29} report_adns_t; 29} report_adns_t;
30 30
31void adns_init(void); 31void adns_init(void);
32config_adns_t adns_get_config(void); 32config_adns_t adns_get_config(void);
33void adns_set_config(config_adns_t); 33void adns_set_config(config_adns_t);
34/* Reads and clears the current delta values on the ADNS sensor */ 34/* Reads and clears the current delta values on the ADNS sensor */
35report_adns_t adns_get_report(void); 35report_adns_t adns_get_report(void);
diff --git a/drivers/sensors/pmw3360.c b/drivers/sensors/pmw3360.c
index 5463bfc59..79b653e45 100644
--- a/drivers/sensors/pmw3360.c
+++ b/drivers/sensors/pmw3360.c
@@ -23,55 +23,55 @@
23#include "pmw3360_firmware.h" 23#include "pmw3360_firmware.h"
24 24
25// Registers 25// Registers
26#define REG_Product_ID 0x00 26#define REG_Product_ID 0x00
27#define REG_Revision_ID 0x01 27#define REG_Revision_ID 0x01
28#define REG_Motion 0x02 28#define REG_Motion 0x02
29#define REG_Delta_X_L 0x03 29#define REG_Delta_X_L 0x03
30#define REG_Delta_X_H 0x04 30#define REG_Delta_X_H 0x04
31#define REG_Delta_Y_L 0x05 31#define REG_Delta_Y_L 0x05
32#define REG_Delta_Y_H 0x06 32#define REG_Delta_Y_H 0x06
33#define REG_SQUAL 0x07 33#define REG_SQUAL 0x07
34#define REG_Raw_Data_Sum 0x08 34#define REG_Raw_Data_Sum 0x08
35#define REG_Maximum_Raw_data 0x09 35#define REG_Maximum_Raw_data 0x09
36#define REG_Minimum_Raw_data 0x0A 36#define REG_Minimum_Raw_data 0x0A
37#define REG_Shutter_Lower 0x0B 37#define REG_Shutter_Lower 0x0B
38#define REG_Shutter_Upper 0x0C 38#define REG_Shutter_Upper 0x0C
39#define REG_Control 0x0D 39#define REG_Control 0x0D
40#define REG_Config1 0x0F 40#define REG_Config1 0x0F
41#define REG_Config2 0x10 41#define REG_Config2 0x10
42#define REG_Angle_Tune 0x11 42#define REG_Angle_Tune 0x11
43#define REG_Frame_Capture 0x12 43#define REG_Frame_Capture 0x12
44#define REG_SROM_Enable 0x13 44#define REG_SROM_Enable 0x13
45#define REG_Run_Downshift 0x14 45#define REG_Run_Downshift 0x14
46#define REG_Rest1_Rate_Lower 0x15 46#define REG_Rest1_Rate_Lower 0x15
47#define REG_Rest1_Rate_Upper 0x16 47#define REG_Rest1_Rate_Upper 0x16
48#define REG_Rest1_Downshift 0x17 48#define REG_Rest1_Downshift 0x17
49#define REG_Rest2_Rate_Lower 0x18 49#define REG_Rest2_Rate_Lower 0x18
50#define REG_Rest2_Rate_Upper 0x19 50#define REG_Rest2_Rate_Upper 0x19
51#define REG_Rest2_Downshift 0x1A 51#define REG_Rest2_Downshift 0x1A
52#define REG_Rest3_Rate_Lower 0x1B 52#define REG_Rest3_Rate_Lower 0x1B
53#define REG_Rest3_Rate_Upper 0x1C 53#define REG_Rest3_Rate_Upper 0x1C
54#define REG_Observation 0x24 54#define REG_Observation 0x24
55#define REG_Data_Out_Lower 0x25 55#define REG_Data_Out_Lower 0x25
56#define REG_Data_Out_Upper 0x26 56#define REG_Data_Out_Upper 0x26
57#define REG_Raw_Data_Dump 0x29 57#define REG_Raw_Data_Dump 0x29
58#define REG_SROM_ID 0x2A 58#define REG_SROM_ID 0x2A
59#define REG_Min_SQ_Run 0x2B 59#define REG_Min_SQ_Run 0x2B
60#define REG_Raw_Data_Threshold 0x2C 60#define REG_Raw_Data_Threshold 0x2C
61#define REG_Config5 0x2F 61#define REG_Config5 0x2F
62#define REG_Power_Up_Reset 0x3A 62#define REG_Power_Up_Reset 0x3A
63#define REG_Shutdown 0x3B 63#define REG_Shutdown 0x3B
64#define REG_Inverse_Product_ID 0x3F 64#define REG_Inverse_Product_ID 0x3F
65#define REG_LiftCutoff_Tune3 0x41 65#define REG_LiftCutoff_Tune3 0x41
66#define REG_Angle_Snap 0x42 66#define REG_Angle_Snap 0x42
67#define REG_LiftCutoff_Tune1 0x4A 67#define REG_LiftCutoff_Tune1 0x4A
68#define REG_Motion_Burst 0x50 68#define REG_Motion_Burst 0x50
69#define REG_LiftCutoff_Tune_Timeout 0x58 69#define REG_LiftCutoff_Tune_Timeout 0x58
70#define REG_LiftCutoff_Tune_Min_Length 0x5A 70#define REG_LiftCutoff_Tune_Min_Length 0x5A
71#define REG_SROM_Load_Burst 0x62 71#define REG_SROM_Load_Burst 0x62
72#define REG_Lift_Config 0x63 72#define REG_Lift_Config 0x63
73#define REG_Raw_Data_Burst 0x64 73#define REG_Raw_Data_Burst 0x64
74#define REG_LiftCutoff_Tune2 0x65 74#define REG_LiftCutoff_Tune2 0x65
75 75
76bool _inBurst = false; 76bool _inBurst = false;
77 77
diff --git a/drivers/sensors/pmw3360.h b/drivers/sensors/pmw3360.h
index 124c62cf0..7429a6ba0 100644
--- a/drivers/sensors/pmw3360.h
+++ b/drivers/sensors/pmw3360.h
@@ -66,20 +66,17 @@ typedef struct {
66 int8_t mdy; 66 int8_t mdy;
67} report_pmw_t; 67} report_pmw_t;
68 68
69 69bool spi_start_adv(void);
70 70void spi_stop_adv(void);
71bool spi_start_adv(void);
72void spi_stop_adv(void);
73spi_status_t spi_write_adv(uint8_t reg_addr, uint8_t data); 71spi_status_t spi_write_adv(uint8_t reg_addr, uint8_t data);
74uint8_t spi_read_adv(uint8_t reg_addr); 72uint8_t spi_read_adv(uint8_t reg_addr);
75bool pmw_spi_init(void); 73bool pmw_spi_init(void);
76void pmw_set_cpi(uint16_t cpi); 74void pmw_set_cpi(uint16_t cpi);
77uint16_t pmw_get_cpi(void); 75uint16_t pmw_get_cpi(void);
78void pmw_upload_firmware(void); 76void pmw_upload_firmware(void);
79bool pmw_check_signature(void); 77bool pmw_check_signature(void);
80report_pmw_t pmw_read_burst(void); 78report_pmw_t pmw_read_burst(void);
81 79
82
83#define degToRad(angleInDegrees) ((angleInDegrees)*M_PI / 180.0) 80#define degToRad(angleInDegrees) ((angleInDegrees)*M_PI / 180.0)
84#define radToDeg(angleInRadians) ((angleInRadians)*180.0 / M_PI) 81#define radToDeg(angleInRadians) ((angleInRadians)*180.0 / M_PI)
85#define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt))) 82#define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt)))
diff --git a/keyboards/checkerboards/phoenix45_ortho/keymaps/via/rules.mk b/keyboards/checkerboards/phoenix45_ortho/keymaps/via/rules.mk
index 69de2e4c5..1e5b99807 100644
--- a/keyboards/checkerboards/phoenix45_ortho/keymaps/via/rules.mk
+++ b/keyboards/checkerboards/phoenix45_ortho/keymaps/via/rules.mk
@@ -1 +1 @@
VIA_ENABLE = yes VIA_ENABLE = yes
diff --git a/keyboards/sneakbox/ava/info.json b/keyboards/sneakbox/ava/info.json
index 55b52a5c5..276efce01 100644
--- a/keyboards/sneakbox/ava/info.json
+++ b/keyboards/sneakbox/ava/info.json
@@ -1,4 +1,4 @@
1{ 1{
2 "keyboard_name": "AVA", 2 "keyboard_name": "AVA",
3 "url": "https://sneakbox.com", 3 "url": "https://sneakbox.com",
4 "maintainer": "mujimanic", 4 "maintainer": "mujimanic",
diff --git a/platforms/chibios/drivers/analog.c b/platforms/chibios/drivers/analog.c
index 8c476fcac..b1081623d 100644
--- a/platforms/chibios/drivers/analog.c
+++ b/platforms/chibios/drivers/analog.c
@@ -123,7 +123,7 @@ static ADCConversionGroup adcConversionGroup = {
123 .smpr = ADC_SAMPLING_RATE, 123 .smpr = ADC_SAMPLING_RATE,
124#elif defined(USE_ADCV2) 124#elif defined(USE_ADCV2)
125# if !defined(STM32F1XX) 125# if !defined(STM32F1XX)
126 .cr2 = ADC_CR2_SWSTART, // F103 seem very unhappy with, F401 seems very unhappy without... 126 .cr2 = ADC_CR2_SWSTART, // F103 seem very unhappy with, F401 seems very unhappy without...
127# endif 127# endif
128 .smpr2 = ADC_SMPR2_SMP_AN0(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN1(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN2(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN3(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN4(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN5(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN6(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN7(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN8(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN9(ADC_SAMPLING_RATE), 128 .smpr2 = ADC_SMPR2_SMP_AN0(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN1(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN2(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN3(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN4(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN5(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN6(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN7(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN8(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN9(ADC_SAMPLING_RATE),
129 .smpr1 = ADC_SMPR1_SMP_AN10(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN11(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN12(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN13(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN14(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN15(ADC_SAMPLING_RATE), 129 .smpr1 = ADC_SMPR1_SMP_AN10(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN11(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN12(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN13(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN14(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN15(ADC_SAMPLING_RATE),
diff --git a/quantum/action.c b/quantum/action.c
index be135f18f..208690f5e 100644
--- a/quantum/action.c
+++ b/quantum/action.c
@@ -782,9 +782,10 @@ void register_code(uint8_t code) {
782 } 782 }
783#endif 783#endif
784 784
785 else if IS_KEY (code) { 785 else if
786 // TODO: should push command_proc out of this block? 786 IS_KEY(code) {
787 if (command_proc(code)) return; 787 // TODO: should push command_proc out of this block?
788 if (command_proc(code)) return;
788 789
789#ifndef NO_ACTION_ONESHOT 790#ifndef NO_ACTION_ONESHOT
790/* TODO: remove 791/* TODO: remove
@@ -801,33 +802,35 @@ void register_code(uint8_t code) {
801 } else 802 } else
802*/ 803*/
803#endif 804#endif
804 { 805 {
805 // Force a new key press if the key is already pressed 806 // Force a new key press if the key is already pressed
806 // without this, keys with the same keycode, but different 807 // without this, keys with the same keycode, but different
807 // modifiers will be reported incorrectly, see issue #1708 808 // modifiers will be reported incorrectly, see issue #1708
808 if (is_key_pressed(keyboard_report, code)) { 809 if (is_key_pressed(keyboard_report, code)) {
809 del_key(code); 810 del_key(code);
811 send_keyboard_report();
812 }
813 add_key(code);
810 send_keyboard_report(); 814 send_keyboard_report();
811 } 815 }
812 add_key(code); 816 }
817 else if
818 IS_MOD(code) {
819 add_mods(MOD_BIT(code));
813 send_keyboard_report(); 820 send_keyboard_report();
814 } 821 }
815 } else if IS_MOD (code) {
816 add_mods(MOD_BIT(code));
817 send_keyboard_report();
818 }
819#ifdef EXTRAKEY_ENABLE 822#ifdef EXTRAKEY_ENABLE
820 else if IS_SYSTEM (code) { 823 else if
821 host_system_send(KEYCODE2SYSTEM(code)); 824 IS_SYSTEM(code) { host_system_send(KEYCODE2SYSTEM(code)); }
822 } else if IS_CONSUMER (code) { 825 else if
823 host_consumer_send(KEYCODE2CONSUMER(code)); 826 IS_CONSUMER(code) { host_consumer_send(KEYCODE2CONSUMER(code)); }
824 }
825#endif 827#endif
826#ifdef MOUSEKEY_ENABLE 828#ifdef MOUSEKEY_ENABLE
827 else if IS_MOUSEKEY (code) { 829 else if
828 mousekey_on(code); 830 IS_MOUSEKEY(code) {
829 mousekey_send(); 831 mousekey_on(code);
830 } 832 mousekey_send();
833 }
831#endif 834#endif
832} 835}
833 836
@@ -872,22 +875,26 @@ void unregister_code(uint8_t code) {
872 } 875 }
873#endif 876#endif
874 877
875 else if IS_KEY (code) { 878 else if
876 del_key(code); 879 IS_KEY(code) {
877 send_keyboard_report(); 880 del_key(code);
878 } else if IS_MOD (code) { 881 send_keyboard_report();
879 del_mods(MOD_BIT(code)); 882 }
880 send_keyboard_report(); 883 else if
881 } else if IS_SYSTEM (code) { 884 IS_MOD(code) {
882 host_system_send(0); 885 del_mods(MOD_BIT(code));
883 } else if IS_CONSUMER (code) { 886 send_keyboard_report();
884 host_consumer_send(0); 887 }
885 } 888 else if
889 IS_SYSTEM(code) { host_system_send(0); }
890 else if
891 IS_CONSUMER(code) { host_consumer_send(0); }
886#ifdef MOUSEKEY_ENABLE 892#ifdef MOUSEKEY_ENABLE
887 else if IS_MOUSEKEY (code) { 893 else if
888 mousekey_off(code); 894 IS_MOUSEKEY(code) {
889 mousekey_send(); 895 mousekey_off(code);
890 } 896 mousekey_send();
897 }
891#endif 898#endif
892} 899}
893 900
diff --git a/quantum/action.h b/quantum/action.h
index 8a357ded8..b562f18c5 100644
--- a/quantum/action.h
+++ b/quantum/action.h
@@ -88,7 +88,7 @@ extern bool disable_action_cache;
88 88
89/* Code for handling one-handed key modifiers. */ 89/* Code for handling one-handed key modifiers. */
90#ifdef SWAP_HANDS_ENABLE 90#ifdef SWAP_HANDS_ENABLE
91extern bool swap_hands; 91extern bool swap_hands;
92extern const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS]; 92extern const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS];
93# if (MATRIX_COLS <= 8) 93# if (MATRIX_COLS <= 8)
94typedef uint8_t swap_state_row_t; 94typedef uint8_t swap_state_row_t;
diff --git a/quantum/action_tapping.c b/quantum/action_tapping.c
index 36839f9fa..60e56fb81 100644
--- a/quantum/action_tapping.c
+++ b/quantum/action_tapping.c
@@ -18,11 +18,11 @@
18# define IS_TAPPING_PRESSED() (IS_TAPPING() && tapping_key.event.pressed) 18# define IS_TAPPING_PRESSED() (IS_TAPPING() && tapping_key.event.pressed)
19# define IS_TAPPING_RELEASED() (IS_TAPPING() && !tapping_key.event.pressed) 19# define IS_TAPPING_RELEASED() (IS_TAPPING() && !tapping_key.event.pressed)
20# define IS_TAPPING_KEY(k) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (k))) 20# define IS_TAPPING_KEY(k) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (k)))
21#ifndef COMBO_ENABLE 21# ifndef COMBO_ENABLE
22# define IS_TAPPING_RECORD(r) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (r->event.key))) 22# define IS_TAPPING_RECORD(r) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (r->event.key)))
23#else 23# else
24# define IS_TAPPING_RECORD(r) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (r->event.key)) && tapping_key.keycode == r->keycode) 24# define IS_TAPPING_RECORD(r) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (r->event.key)) && tapping_key.keycode == r->keycode)
25#endif 25# endif
26 26
27__attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) { return TAPPING_TERM; } 27__attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) { return TAPPING_TERM; }
28 28
@@ -212,11 +212,15 @@ bool process_tapping(keyrecord_t *keyp) {
212 if (tapping_key.tap.count > 1) { 212 if (tapping_key.tap.count > 1) {
213 debug("Tapping: Start new tap with releasing last tap(>1).\n"); 213 debug("Tapping: Start new tap with releasing last tap(>1).\n");
214 // unregister key 214 // unregister key
215 process_record(&(keyrecord_t){.tap = tapping_key.tap, .event.key = tapping_key.event.key, .event.time = event.time, .event.pressed = false, 215 process_record(&(keyrecord_t){
216#ifdef COMBO_ENABLE 216 .tap = tapping_key.tap,
217 .keycode = tapping_key.keycode, 217 .event.key = tapping_key.event.key,
218#endif 218 .event.time = event.time,
219 }); 219 .event.pressed = false,
220# ifdef COMBO_ENABLE
221 .keycode = tapping_key.keycode,
222# endif
223 });
220 } else { 224 } else {
221 debug("Tapping: Start while last tap(1).\n"); 225 debug("Tapping: Start while last tap(1).\n");
222 } 226 }
@@ -254,11 +258,15 @@ bool process_tapping(keyrecord_t *keyp) {
254 if (tapping_key.tap.count > 1) { 258 if (tapping_key.tap.count > 1) {
255 debug("Tapping: Start new tap with releasing last timeout tap(>1).\n"); 259 debug("Tapping: Start new tap with releasing last timeout tap(>1).\n");
256 // unregister key 260 // unregister key
257 process_record(&(keyrecord_t){.tap = tapping_key.tap, .event.key = tapping_key.event.key, .event.time = event.time, .event.pressed = false, 261 process_record(&(keyrecord_t){
258#ifdef COMBO_ENABLE 262 .tap = tapping_key.tap,
259 .keycode = tapping_key.keycode, 263 .event.key = tapping_key.event.key,
260#endif 264 .event.time = event.time,
261 }); 265 .event.pressed = false,
266# ifdef COMBO_ENABLE
267 .keycode = tapping_key.keycode,
268# endif
269 });
262 } else { 270 } else {
263 debug("Tapping: Start while last timeout tap(1).\n"); 271 debug("Tapping: Start while last timeout tap(1).\n");
264 } 272 }
diff --git a/quantum/debounce/asym_eager_defer_pk.c b/quantum/debounce/asym_eager_defer_pk.c
index 24380dc5e..81f39383c 100644
--- a/quantum/debounce/asym_eager_defer_pk.c
+++ b/quantum/debounce/asym_eager_defer_pk.c
@@ -46,17 +46,17 @@ When no state changes have occured for DEBOUNCE milliseconds, we push the state.
46#define ROW_SHIFTER ((matrix_row_t)1) 46#define ROW_SHIFTER ((matrix_row_t)1)
47 47
48typedef struct { 48typedef struct {
49 bool pressed : 1; 49 bool pressed : 1;
50 uint8_t time : 7; 50 uint8_t time : 7;
51} debounce_counter_t; 51} debounce_counter_t;
52 52
53#if DEBOUNCE > 0 53#if DEBOUNCE > 0
54static debounce_counter_t *debounce_counters; 54static debounce_counter_t *debounce_counters;
55static fast_timer_t last_time; 55static fast_timer_t last_time;
56static bool counters_need_update; 56static bool counters_need_update;
57static bool matrix_need_update; 57static bool matrix_need_update;
58 58
59#define DEBOUNCE_ELAPSED 0 59# define DEBOUNCE_ELAPSED 0
60 60
61static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t elapsed_time); 61static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t elapsed_time);
62static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows); 62static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows);
@@ -64,7 +64,7 @@ static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], ui
64// we use num_rows rather than MATRIX_ROWS to support split keyboards 64// we use num_rows rather than MATRIX_ROWS to support split keyboards
65void debounce_init(uint8_t num_rows) { 65void debounce_init(uint8_t num_rows) {
66 debounce_counters = malloc(num_rows * MATRIX_COLS * sizeof(debounce_counter_t)); 66 debounce_counters = malloc(num_rows * MATRIX_COLS * sizeof(debounce_counter_t));
67 int i = 0; 67 int i = 0;
68 for (uint8_t r = 0; r < num_rows; r++) { 68 for (uint8_t r = 0; r < num_rows; r++) {
69 for (uint8_t c = 0; c < MATRIX_COLS; c++) { 69 for (uint8_t c = 0; c < MATRIX_COLS; c++) {
70 debounce_counters[i++].time = DEBOUNCE_ELAPSED; 70 debounce_counters[i++].time = DEBOUNCE_ELAPSED;
@@ -81,10 +81,10 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool
81 bool updated_last = false; 81 bool updated_last = false;
82 82
83 if (counters_need_update) { 83 if (counters_need_update) {
84 fast_timer_t now = timer_read_fast(); 84 fast_timer_t now = timer_read_fast();
85 fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time); 85 fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time);
86 86
87 last_time = now; 87 last_time = now;
88 updated_last = true; 88 updated_last = true;
89 if (elapsed_time > UINT8_MAX) { 89 if (elapsed_time > UINT8_MAX) {
90 elapsed_time = UINT8_MAX; 90 elapsed_time = UINT8_MAX;
@@ -108,7 +108,7 @@ static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[],
108 debounce_counter_t *debounce_pointer = debounce_counters; 108 debounce_counter_t *debounce_pointer = debounce_counters;
109 109
110 counters_need_update = false; 110 counters_need_update = false;
111 matrix_need_update = false; 111 matrix_need_update = false;
112 112
113 for (uint8_t row = 0; row < num_rows; row++) { 113 for (uint8_t row = 0; row < num_rows; row++) {
114 for (uint8_t col = 0; col < MATRIX_COLS; col++) { 114 for (uint8_t col = 0; col < MATRIX_COLS; col++) {
@@ -146,8 +146,8 @@ static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], ui
146 if (delta & col_mask) { 146 if (delta & col_mask) {
147 if (debounce_pointer->time == DEBOUNCE_ELAPSED) { 147 if (debounce_pointer->time == DEBOUNCE_ELAPSED) {
148 debounce_pointer->pressed = (raw[row] & col_mask); 148 debounce_pointer->pressed = (raw[row] & col_mask);
149 debounce_pointer->time = DEBOUNCE; 149 debounce_pointer->time = DEBOUNCE;
150 counters_need_update = true; 150 counters_need_update = true;
151 151
152 if (debounce_pointer->pressed) { 152 if (debounce_pointer->pressed) {
153 // key-down: eager 153 // key-down: eager
diff --git a/quantum/debounce/sym_defer_g.c b/quantum/debounce/sym_defer_g.c
index fbefd55ed..9155eb914 100644
--- a/quantum/debounce/sym_defer_g.c
+++ b/quantum/debounce/sym_defer_g.c
@@ -25,7 +25,7 @@ When no state changes have occured for DEBOUNCE milliseconds, we push the state.
25#endif 25#endif
26 26
27#if DEBOUNCE > 0 27#if DEBOUNCE > 0
28static bool debouncing = false; 28static bool debouncing = false;
29static fast_timer_t debouncing_time; 29static fast_timer_t debouncing_time;
30 30
31void debounce_init(uint8_t num_rows) {} 31void debounce_init(uint8_t num_rows) {}
diff --git a/quantum/debounce/sym_defer_pk.c b/quantum/debounce/sym_defer_pk.c
index 626a9be84..1b698ba34 100644
--- a/quantum/debounce/sym_defer_pk.c
+++ b/quantum/debounce/sym_defer_pk.c
@@ -49,7 +49,7 @@ static debounce_counter_t *debounce_counters;
49static fast_timer_t last_time; 49static fast_timer_t last_time;
50static bool counters_need_update; 50static bool counters_need_update;
51 51
52#define DEBOUNCE_ELAPSED 0 52# define DEBOUNCE_ELAPSED 0
53 53
54static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t elapsed_time); 54static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t elapsed_time);
55static void start_debounce_counters(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows); 55static void start_debounce_counters(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows);
@@ -74,10 +74,10 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool
74 bool updated_last = false; 74 bool updated_last = false;
75 75
76 if (counters_need_update) { 76 if (counters_need_update) {
77 fast_timer_t now = timer_read_fast(); 77 fast_timer_t now = timer_read_fast();
78 fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time); 78 fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time);
79 79
80 last_time = now; 80 last_time = now;
81 updated_last = true; 81 updated_last = true;
82 if (elapsed_time > UINT8_MAX) { 82 if (elapsed_time > UINT8_MAX) {
83 elapsed_time = UINT8_MAX; 83 elapsed_time = UINT8_MAX;
diff --git a/quantum/debounce/sym_eager_pk.c b/quantum/debounce/sym_eager_pk.c
index 15a3242e6..9da000ea9 100644
--- a/quantum/debounce/sym_eager_pk.c
+++ b/quantum/debounce/sym_eager_pk.c
@@ -50,7 +50,7 @@ static fast_timer_t last_time;
50static bool counters_need_update; 50static bool counters_need_update;
51static bool matrix_need_update; 51static bool matrix_need_update;
52 52
53#define DEBOUNCE_ELAPSED 0 53# define DEBOUNCE_ELAPSED 0
54 54
55static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time); 55static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time);
56static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows); 56static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows);
@@ -75,10 +75,10 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool
75 bool updated_last = false; 75 bool updated_last = false;
76 76
77 if (counters_need_update) { 77 if (counters_need_update) {
78 fast_timer_t now = timer_read_fast(); 78 fast_timer_t now = timer_read_fast();
79 fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time); 79 fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time);
80 80
81 last_time = now; 81 last_time = now;
82 updated_last = true; 82 updated_last = true;
83 if (elapsed_time > UINT8_MAX) { 83 if (elapsed_time > UINT8_MAX) {
84 elapsed_time = UINT8_MAX; 84 elapsed_time = UINT8_MAX;
@@ -107,7 +107,7 @@ static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time) {
107 for (uint8_t col = 0; col < MATRIX_COLS; col++) { 107 for (uint8_t col = 0; col < MATRIX_COLS; col++) {
108 if (*debounce_pointer != DEBOUNCE_ELAPSED) { 108 if (*debounce_pointer != DEBOUNCE_ELAPSED) {
109 if (*debounce_pointer <= elapsed_time) { 109 if (*debounce_pointer <= elapsed_time) {
110 *debounce_pointer = DEBOUNCE_ELAPSED; 110 *debounce_pointer = DEBOUNCE_ELAPSED;
111 matrix_need_update = true; 111 matrix_need_update = true;
112 } else { 112 } else {
113 *debounce_pointer -= elapsed_time; 113 *debounce_pointer -= elapsed_time;
diff --git a/quantum/debounce/sym_eager_pr.c b/quantum/debounce/sym_eager_pr.c
index 2ad592c5a..eda92a263 100644
--- a/quantum/debounce/sym_eager_pr.c
+++ b/quantum/debounce/sym_eager_pr.c
@@ -49,7 +49,7 @@ static debounce_counter_t *debounce_counters;
49static fast_timer_t last_time; 49static fast_timer_t last_time;
50static bool counters_need_update; 50static bool counters_need_update;
51 51
52#define DEBOUNCE_ELAPSED 0 52# define DEBOUNCE_ELAPSED 0
53 53
54static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time); 54static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time);
55static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows); 55static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows);
@@ -71,10 +71,10 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool
71 bool updated_last = false; 71 bool updated_last = false;
72 72
73 if (counters_need_update) { 73 if (counters_need_update) {
74 fast_timer_t now = timer_read_fast(); 74 fast_timer_t now = timer_read_fast();
75 fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time); 75 fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time);
76 76
77 last_time = now; 77 last_time = now;
78 updated_last = true; 78 updated_last = true;
79 if (elapsed_time > UINT8_MAX) { 79 if (elapsed_time > UINT8_MAX) {
80 elapsed_time = UINT8_MAX; 80 elapsed_time = UINT8_MAX;
@@ -102,7 +102,7 @@ static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time) {
102 for (uint8_t row = 0; row < num_rows; row++) { 102 for (uint8_t row = 0; row < num_rows; row++) {
103 if (*debounce_pointer != DEBOUNCE_ELAPSED) { 103 if (*debounce_pointer != DEBOUNCE_ELAPSED) {
104 if (*debounce_pointer <= elapsed_time) { 104 if (*debounce_pointer <= elapsed_time) {
105 *debounce_pointer = DEBOUNCE_ELAPSED; 105 *debounce_pointer = DEBOUNCE_ELAPSED;
106 matrix_need_update = true; 106 matrix_need_update = true;
107 } else { 107 } else {
108 *debounce_pointer -= elapsed_time; 108 *debounce_pointer -= elapsed_time;
diff --git a/quantum/debounce/tests/asym_eager_defer_pk_tests.cpp b/quantum/debounce/tests/asym_eager_defer_pk_tests.cpp
index fe374c3df..44b4fe195 100644
--- a/quantum/debounce/tests/asym_eager_defer_pk_tests.cpp
+++ b/quantum/debounce/tests/asym_eager_defer_pk_tests.cpp
@@ -19,7 +19,8 @@
19#include "debounce_test_common.h" 19#include "debounce_test_common.h"
20 20
21TEST_F(DebounceTest, OneKeyShort1) { 21TEST_F(DebounceTest, OneKeyShort1) {
22 addEvents({ /* Time, Inputs, Outputs */ 22 addEvents({
23 /* Time, Inputs, Outputs */
23 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 24 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
24 /* Release key after 1ms delay */ 25 /* Release key after 1ms delay */
25 {1, {{0, 1, UP}}, {}}, 26 {1, {{0, 1, UP}}, {}},
@@ -43,7 +44,8 @@ TEST_F(DebounceTest, OneKeyShort1) {
43} 44}
44 45
45TEST_F(DebounceTest, OneKeyShort2) { 46TEST_F(DebounceTest, OneKeyShort2) {
46 addEvents({ /* Time, Inputs, Outputs */ 47 addEvents({
48 /* Time, Inputs, Outputs */
47 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 49 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
48 /* Release key after 2ms delay */ 50 /* Release key after 2ms delay */
49 {2, {{0, 1, UP}}, {}}, 51 {2, {{0, 1, UP}}, {}},
@@ -58,7 +60,8 @@ TEST_F(DebounceTest, OneKeyShort2) {
58} 60}
59 61
60TEST_F(DebounceTest, OneKeyShort3) { 62TEST_F(DebounceTest, OneKeyShort3) {
61 addEvents({ /* Time, Inputs, Outputs */ 63 addEvents({
64 /* Time, Inputs, Outputs */
62 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 65 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
63 /* Release key after 3ms delay */ 66 /* Release key after 3ms delay */
64 {3, {{0, 1, UP}}, {}}, 67 {3, {{0, 1, UP}}, {}},
@@ -73,7 +76,8 @@ TEST_F(DebounceTest, OneKeyShort3) {
73} 76}
74 77
75TEST_F(DebounceTest, OneKeyShort4) { 78TEST_F(DebounceTest, OneKeyShort4) {
76 addEvents({ /* Time, Inputs, Outputs */ 79 addEvents({
80 /* Time, Inputs, Outputs */
77 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 81 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
78 /* Release key after 4ms delay */ 82 /* Release key after 4ms delay */
79 {4, {{0, 1, UP}}, {}}, 83 {4, {{0, 1, UP}}, {}},
@@ -88,7 +92,8 @@ TEST_F(DebounceTest, OneKeyShort4) {
88} 92}
89 93
90TEST_F(DebounceTest, OneKeyShort5) { 94TEST_F(DebounceTest, OneKeyShort5) {
91 addEvents({ /* Time, Inputs, Outputs */ 95 addEvents({
96 /* Time, Inputs, Outputs */
92 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 97 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
93 98
94 /* Release key after 5ms delay */ 99 /* Release key after 5ms delay */
@@ -102,7 +107,8 @@ TEST_F(DebounceTest, OneKeyShort5) {
102} 107}
103 108
104TEST_F(DebounceTest, OneKeyShort6) { 109TEST_F(DebounceTest, OneKeyShort6) {
105 addEvents({ /* Time, Inputs, Outputs */ 110 addEvents({
111 /* Time, Inputs, Outputs */
106 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 112 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
107 113
108 /* Release key after 6ms delay */ 114 /* Release key after 6ms delay */
@@ -116,7 +122,8 @@ TEST_F(DebounceTest, OneKeyShort6) {
116} 122}
117 123
118TEST_F(DebounceTest, OneKeyShort7) { 124TEST_F(DebounceTest, OneKeyShort7) {
119 addEvents({ /* Time, Inputs, Outputs */ 125 addEvents({
126 /* Time, Inputs, Outputs */
120 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 127 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
121 128
122 /* Release key after 7ms delay */ 129 /* Release key after 7ms delay */
@@ -130,7 +137,8 @@ TEST_F(DebounceTest, OneKeyShort7) {
130} 137}
131 138
132TEST_F(DebounceTest, OneKeyShort8) { 139TEST_F(DebounceTest, OneKeyShort8) {
133 addEvents({ /* Time, Inputs, Outputs */ 140 addEvents({
141 /* Time, Inputs, Outputs */
134 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 142 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
135 /* Release key after 1ms delay */ 143 /* Release key after 1ms delay */
136 {1, {{0, 1, UP}}, {}}, 144 {1, {{0, 1, UP}}, {}},
@@ -145,7 +153,8 @@ TEST_F(DebounceTest, OneKeyShort8) {
145} 153}
146 154
147TEST_F(DebounceTest, OneKeyShort9) { 155TEST_F(DebounceTest, OneKeyShort9) {
148 addEvents({ /* Time, Inputs, Outputs */ 156 addEvents({
157 /* Time, Inputs, Outputs */
149 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 158 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
150 /* Release key after 1ms delay */ 159 /* Release key after 1ms delay */
151 {1, {{0, 1, UP}}, {}}, 160 {1, {{0, 1, UP}}, {}},
@@ -159,7 +168,8 @@ TEST_F(DebounceTest, OneKeyShort9) {
159} 168}
160 169
161TEST_F(DebounceTest, OneKeyBouncing1) { 170TEST_F(DebounceTest, OneKeyBouncing1) {
162 addEvents({ /* Time, Inputs, Outputs */ 171 addEvents({
172 /* Time, Inputs, Outputs */
163 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 173 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
164 {1, {{0, 1, UP}}, {}}, 174 {1, {{0, 1, UP}}, {}},
165 {2, {{0, 1, DOWN}}, {}}, 175 {2, {{0, 1, DOWN}}, {}},
@@ -185,7 +195,8 @@ TEST_F(DebounceTest, OneKeyBouncing1) {
185} 195}
186 196
187TEST_F(DebounceTest, OneKeyBouncing2) { 197TEST_F(DebounceTest, OneKeyBouncing2) {
188 addEvents({ /* Time, Inputs, Outputs */ 198 addEvents({
199 /* Time, Inputs, Outputs */
189 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 200 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
190 /* Change twice in the same time period */ 201 /* Change twice in the same time period */
191 {1, {{0, 1, UP}}, {}}, 202 {1, {{0, 1, UP}}, {}},
@@ -217,7 +228,8 @@ TEST_F(DebounceTest, OneKeyBouncing2) {
217} 228}
218 229
219TEST_F(DebounceTest, OneKeyLong) { 230TEST_F(DebounceTest, OneKeyLong) {
220 addEvents({ /* Time, Inputs, Outputs */ 231 addEvents({
232 /* Time, Inputs, Outputs */
221 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 233 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
222 234
223 {25, {{0, 1, UP}}, {}}, 235 {25, {{0, 1, UP}}, {}},
@@ -236,7 +248,8 @@ TEST_F(DebounceTest, OneKeyLong) {
236} 248}
237 249
238TEST_F(DebounceTest, TwoKeysShort) { 250TEST_F(DebounceTest, TwoKeysShort) {
239 addEvents({ /* Time, Inputs, Outputs */ 251 addEvents({
252 /* Time, Inputs, Outputs */
240 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 253 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
241 {1, {{0, 2, DOWN}}, {{0, 2, DOWN}}}, 254 {1, {{0, 2, DOWN}}, {{0, 2, DOWN}}},
242 /* Release key after 2ms delay */ 255 /* Release key after 2ms delay */
@@ -249,14 +262,14 @@ TEST_F(DebounceTest, TwoKeysShort) {
249 {10, {}, {{0, 1, UP}}}, /* 5ms+5ms after DOWN at time 0 */ 262 {10, {}, {{0, 1, UP}}}, /* 5ms+5ms after DOWN at time 0 */
250 /* Press key again after 1ms delay */ 263 /* Press key again after 1ms delay */
251 {11, {{0, 1, DOWN}}, {{0, 1, DOWN}, {0, 2, UP}}}, /* 5ms+5ms after DOWN at time 0 */ 264 {11, {{0, 1, DOWN}}, {{0, 1, DOWN}, {0, 2, UP}}}, /* 5ms+5ms after DOWN at time 0 */
252 {12, {{0, 2, DOWN}}, {{0, 2, DOWN}}}, /* 5ms+5ms after DOWN at time 0 */ 265 {12, {{0, 2, DOWN}}, {{0, 2, DOWN}}}, /* 5ms+5ms after DOWN at time 0 */
253 }); 266 });
254 runEvents(); 267 runEvents();
255} 268}
256 269
257
258TEST_F(DebounceTest, OneKeyDelayedScan1) { 270TEST_F(DebounceTest, OneKeyDelayedScan1) {
259 addEvents({ /* Time, Inputs, Outputs */ 271 addEvents({
272 /* Time, Inputs, Outputs */
260 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 273 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
261 274
262 /* Processing is very late, immediately release key */ 275 /* Processing is very late, immediately release key */
@@ -269,7 +282,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan1) {
269} 282}
270 283
271TEST_F(DebounceTest, OneKeyDelayedScan2) { 284TEST_F(DebounceTest, OneKeyDelayedScan2) {
272 addEvents({ /* Time, Inputs, Outputs */ 285 addEvents({
286 /* Time, Inputs, Outputs */
273 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 287 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
274 288
275 /* Processing is very late, immediately release key */ 289 /* Processing is very late, immediately release key */
@@ -283,7 +297,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan2) {
283} 297}
284 298
285TEST_F(DebounceTest, OneKeyDelayedScan3) { 299TEST_F(DebounceTest, OneKeyDelayedScan3) {
286 addEvents({ /* Time, Inputs, Outputs */ 300 addEvents({
301 /* Time, Inputs, Outputs */
287 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 302 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
288 303
289 /* Processing is very late */ 304 /* Processing is very late */
@@ -298,7 +313,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan3) {
298} 313}
299 314
300TEST_F(DebounceTest, OneKeyDelayedScan4) { 315TEST_F(DebounceTest, OneKeyDelayedScan4) {
301 addEvents({ /* Time, Inputs, Outputs */ 316 addEvents({
317 /* Time, Inputs, Outputs */
302 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 318 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
303 319
304 /* Processing is very late */ 320 /* Processing is very late */
@@ -314,7 +330,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan4) {
314} 330}
315 331
316TEST_F(DebounceTest, OneKeyDelayedScan5) { 332TEST_F(DebounceTest, OneKeyDelayedScan5) {
317 addEvents({ /* Time, Inputs, Outputs */ 333 addEvents({
334 /* Time, Inputs, Outputs */
318 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 335 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
319 336
320 {5, {{0, 1, UP}}, {}}, 337 {5, {{0, 1, UP}}, {}},
@@ -329,7 +346,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan5) {
329} 346}
330 347
331TEST_F(DebounceTest, OneKeyDelayedScan6) { 348TEST_F(DebounceTest, OneKeyDelayedScan6) {
332 addEvents({ /* Time, Inputs, Outputs */ 349 addEvents({
350 /* Time, Inputs, Outputs */
333 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 351 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
334 352
335 {5, {{0, 1, UP}}, {}}, 353 {5, {{0, 1, UP}}, {}},
@@ -345,7 +363,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan6) {
345} 363}
346 364
347TEST_F(DebounceTest, OneKeyDelayedScan7) { 365TEST_F(DebounceTest, OneKeyDelayedScan7) {
348 addEvents({ /* Time, Inputs, Outputs */ 366 addEvents({
367 /* Time, Inputs, Outputs */
349 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 368 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
350 369
351 {5, {{0, 1, UP}}, {}}, 370 {5, {{0, 1, UP}}, {}},
@@ -358,7 +377,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan7) {
358} 377}
359 378
360TEST_F(DebounceTest, OneKeyDelayedScan8) { 379TEST_F(DebounceTest, OneKeyDelayedScan8) {
361 addEvents({ /* Time, Inputs, Outputs */ 380 addEvents({
381 /* Time, Inputs, Outputs */
362 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 382 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
363 383
364 /* Processing is a bit late */ 384 /* Processing is a bit late */
diff --git a/quantum/debounce/tests/debounce_test_common.cpp b/quantum/debounce/tests/debounce_test_common.cpp
index 1c5e7c9f4..f9414e571 100644
--- a/quantum/debounce/tests/debounce_test_common.cpp
+++ b/quantum/debounce/tests/debounce_test_common.cpp
@@ -31,9 +31,7 @@ void set_time(uint32_t t);
31void advance_time(uint32_t ms); 31void advance_time(uint32_t ms);
32} 32}
33 33
34void DebounceTest::addEvents(std::initializer_list<DebounceTestEvent> events) { 34void DebounceTest::addEvents(std::initializer_list<DebounceTestEvent> events) { events_.insert(events_.end(), events.begin(), events.end()); }
35 events_.insert(events_.end(), events.begin(), events.end());
36}
37 35
38void DebounceTest::runEvents() { 36void DebounceTest::runEvents() {
39 /* Run the test multiple times, from 1kHz to 10kHz scan rate */ 37 /* Run the test multiple times, from 1kHz to 10kHz scan rate */
@@ -54,7 +52,7 @@ void DebounceTest::runEvents() {
54 52
55void DebounceTest::runEventsInternal() { 53void DebounceTest::runEventsInternal() {
56 fast_timer_t previous = 0; 54 fast_timer_t previous = 0;
57 bool first = true; 55 bool first = true;
58 56
59 /* Initialise keyboard with start time (offset to avoid testing at 0) and all keys UP */ 57 /* Initialise keyboard with start time (offset to avoid testing at 0) and all keys UP */
60 debounce_init(MATRIX_ROWS); 58 debounce_init(MATRIX_ROWS);
@@ -80,7 +78,7 @@ void DebounceTest::runEventsInternal() {
80 } 78 }
81 } 79 }
82 80
83 first = false; 81 first = false;
84 previous = event.time_; 82 previous = event.time_;
85 83
86 /* Prepare input matrix */ 84 /* Prepare input matrix */
@@ -98,12 +96,7 @@ void DebounceTest::runEventsInternal() {
98 96
99 /* Check output matrix has expected change events */ 97 /* Check output matrix has expected change events */
100 for (auto &output : event.outputs_) { 98 for (auto &output : event.outputs_) {
101 EXPECT_EQ(!!(cooked_matrix_[output.row_] & (1U << output.col_)), directionValue(output.direction_)) 99 EXPECT_EQ(!!(cooked_matrix_[output.row_] & (1U << output.col_)), directionValue(output.direction_)) << "Missing event at " << strTime() << " expected key " << output.row_ << "," << output.col_ << " " << directionLabel(output.direction_) << "\ninput_matrix: changed=" << !event.inputs_.empty() << "\n" << strMatrix(input_matrix_) << "\nexpected_matrix:\n" << strMatrix(output_matrix_) << "\nactual_matrix:\n" << strMatrix(cooked_matrix_);
102 << "Missing event at " << strTime()
103 << " expected key " << output.row_ << "," << output.col_ << " " << directionLabel(output.direction_)
104 << "\ninput_matrix: changed=" << !event.inputs_.empty() << "\n" << strMatrix(input_matrix_)
105 << "\nexpected_matrix:\n" << strMatrix(output_matrix_)
106 << "\nactual_matrix:\n" << strMatrix(cooked_matrix_);
107 } 100 }
108 101
109 /* Check output matrix has no other changes */ 102 /* Check output matrix has no other changes */
@@ -133,27 +126,20 @@ void DebounceTest::runDebounce(bool changed) {
133 debounce(raw_matrix_, cooked_matrix_, MATRIX_ROWS, changed); 126 debounce(raw_matrix_, cooked_matrix_, MATRIX_ROWS, changed);
134 127
135 if (!std::equal(std::begin(input_matrix_), std::end(input_matrix_), std::begin(raw_matrix_))) { 128 if (!std::equal(std::begin(input_matrix_), std::end(input_matrix_), std::begin(raw_matrix_))) {
136 FAIL() << "Fatal error: debounce() modified raw matrix at " << strTime() 129 FAIL() << "Fatal error: debounce() modified raw matrix at " << strTime() << "\ninput_matrix: changed=" << changed << "\n" << strMatrix(input_matrix_) << "\nraw_matrix:\n" << strMatrix(raw_matrix_);
137 << "\ninput_matrix: changed=" << changed << "\n" << strMatrix(input_matrix_)
138 << "\nraw_matrix:\n" << strMatrix(raw_matrix_);
139 } 130 }
140} 131}
141 132
142void DebounceTest::checkCookedMatrix(bool changed, const std::string &error_message) { 133void DebounceTest::checkCookedMatrix(bool changed, const std::string &error_message) {
143 if (!std::equal(std::begin(output_matrix_), std::end(output_matrix_), std::begin(cooked_matrix_))) { 134 if (!std::equal(std::begin(output_matrix_), std::end(output_matrix_), std::begin(cooked_matrix_))) {
144 FAIL() << "Unexpected event: " << error_message << " at " << strTime() 135 FAIL() << "Unexpected event: " << error_message << " at " << strTime() << "\ninput_matrix: changed=" << changed << "\n" << strMatrix(input_matrix_) << "\nexpected_matrix:\n" << strMatrix(output_matrix_) << "\nactual_matrix:\n" << strMatrix(cooked_matrix_);
145 << "\ninput_matrix: changed=" << changed << "\n" << strMatrix(input_matrix_)
146 << "\nexpected_matrix:\n" << strMatrix(output_matrix_)
147 << "\nactual_matrix:\n" << strMatrix(cooked_matrix_);
148 } 136 }
149} 137}
150 138
151std::string DebounceTest::strTime() { 139std::string DebounceTest::strTime() {
152 std::stringstream text; 140 std::stringstream text;
153 141
154 text << "time " << (timer_read_fast() - time_offset_) 142 text << "time " << (timer_read_fast() - time_offset_) << " (extra_iterations=" << extra_iterations_ << ", auto_advance_time=" << auto_advance_time_ << ")";
155 << " (extra_iterations=" << extra_iterations_
156 << ", auto_advance_time=" << auto_advance_time_ << ")";
157 143
158 return text.str(); 144 return text.str();
159} 145}
@@ -181,49 +167,39 @@ std::string DebounceTest::strMatrix(matrix_row_t matrix[]) {
181 167
182bool DebounceTest::directionValue(Direction direction) { 168bool DebounceTest::directionValue(Direction direction) {
183 switch (direction) { 169 switch (direction) {
184 case DOWN: 170 case DOWN:
185 return true; 171 return true;
186 172
187 case UP: 173 case UP:
188 return false; 174 return false;
189 } 175 }
190} 176}
191 177
192std::string DebounceTest::directionLabel(Direction direction) { 178std::string DebounceTest::directionLabel(Direction direction) {
193 switch (direction) { 179 switch (direction) {
194 case DOWN: 180 case DOWN:
195 return "DOWN"; 181 return "DOWN";
196 182
197 case UP: 183 case UP:
198 return "UP"; 184 return "UP";
199 } 185 }
200} 186}
201 187
202/* Modify a matrix and verify that events always specify a change */ 188/* Modify a matrix and verify that events always specify a change */
203void DebounceTest::matrixUpdate(matrix_row_t matrix[], const std::string &name, const MatrixTestEvent &event) { 189void DebounceTest::matrixUpdate(matrix_row_t matrix[], const std::string &name, const MatrixTestEvent &event) {
204 ASSERT_NE(!!(matrix[event.row_] & (1U << event.col_)), directionValue(event.direction_)) 190 ASSERT_NE(!!(matrix[event.row_] & (1U << event.col_)), directionValue(event.direction_)) << "Test " << name << " at " << strTime() << " sets key " << event.row_ << "," << event.col_ << " " << directionLabel(event.direction_) << " but it is already " << directionLabel(event.direction_) << "\n" << name << "_matrix:\n" << strMatrix(matrix);
205 << "Test " << name << " at " << strTime()
206 << " sets key " << event.row_ << "," << event.col_ << " " << directionLabel(event.direction_)
207 << " but it is already " << directionLabel(event.direction_)
208 << "\n" << name << "_matrix:\n" << strMatrix(matrix);
209 191
210 switch (event.direction_) { 192 switch (event.direction_) {
211 case DOWN: 193 case DOWN:
212 matrix[event.row_] |= (1U << event.col_); 194 matrix[event.row_] |= (1U << event.col_);
213 break; 195 break;
214 196
215 case UP: 197 case UP:
216 matrix[event.row_] &= ~(1U << event.col_); 198 matrix[event.row_] &= ~(1U << event.col_);
217 break; 199 break;
218 } 200 }
219} 201}
220 202
221DebounceTestEvent::DebounceTestEvent(fast_timer_t time, 203DebounceTestEvent::DebounceTestEvent(fast_timer_t time, std::initializer_list<MatrixTestEvent> inputs, std::initializer_list<MatrixTestEvent> outputs) : time_(time), inputs_(inputs), outputs_(outputs) {}
222 std::initializer_list<MatrixTestEvent> inputs,
223 std::initializer_list<MatrixTestEvent> outputs)
224 : time_(time), inputs_(inputs), outputs_(outputs) {
225}
226 204
227MatrixTestEvent::MatrixTestEvent(int row, int col, Direction direction) 205MatrixTestEvent::MatrixTestEvent(int row, int col, Direction direction) : row_(row), col_(col), direction_(direction) {}
228 : row_(row), col_(col), direction_(direction) {
229}
diff --git a/quantum/debounce/tests/debounce_test_common.h b/quantum/debounce/tests/debounce_test_common.h
index d87e31059..b7becb378 100644
--- a/quantum/debounce/tests/debounce_test_common.h
+++ b/quantum/debounce/tests/debounce_test_common.h
@@ -31,36 +31,34 @@ enum Direction {
31}; 31};
32 32
33class MatrixTestEvent { 33class MatrixTestEvent {
34public: 34 public:
35 MatrixTestEvent(int row, int col, Direction direction); 35 MatrixTestEvent(int row, int col, Direction direction);
36 36
37 const int row_; 37 const int row_;
38 const int col_; 38 const int col_;
39 const Direction direction_; 39 const Direction direction_;
40}; 40};
41 41
42class DebounceTestEvent { 42class DebounceTestEvent {
43public: 43 public:
44 // 0, {{0, 1, DOWN}}, {{0, 1, DOWN}}) 44 // 0, {{0, 1, DOWN}}, {{0, 1, DOWN}})
45 DebounceTestEvent(fast_timer_t time, 45 DebounceTestEvent(fast_timer_t time, std::initializer_list<MatrixTestEvent> inputs, std::initializer_list<MatrixTestEvent> outputs);
46 std::initializer_list<MatrixTestEvent> inputs,
47 std::initializer_list<MatrixTestEvent> outputs);
48 46
49 const fast_timer_t time_; 47 const fast_timer_t time_;
50 const std::list<MatrixTestEvent> inputs_; 48 const std::list<MatrixTestEvent> inputs_;
51 const std::list<MatrixTestEvent> outputs_; 49 const std::list<MatrixTestEvent> outputs_;
52}; 50};
53 51
54class DebounceTest : public ::testing::Test { 52class DebounceTest : public ::testing::Test {
55protected: 53 protected:
56 void addEvents(std::initializer_list<DebounceTestEvent> events); 54 void addEvents(std::initializer_list<DebounceTestEvent> events);
57 void runEvents(); 55 void runEvents();
58 56
59 fast_timer_t time_offset_ = 7777; 57 fast_timer_t time_offset_ = 7777;
60 bool time_jumps_ = false; 58 bool time_jumps_ = false;
61 59
62private: 60 private:
63 static bool directionValue(Direction direction); 61 static bool directionValue(Direction direction);
64 static std::string directionLabel(Direction direction); 62 static std::string directionLabel(Direction direction);
65 63
66 void runEventsInternal(); 64 void runEventsInternal();
@@ -78,6 +76,6 @@ private:
78 matrix_row_t cooked_matrix_[MATRIX_ROWS]; 76 matrix_row_t cooked_matrix_[MATRIX_ROWS];
79 matrix_row_t output_matrix_[MATRIX_ROWS]; 77 matrix_row_t output_matrix_[MATRIX_ROWS];
80 78
81 int extra_iterations_; 79 int extra_iterations_;
82 bool auto_advance_time_; 80 bool auto_advance_time_;
83}; 81};
diff --git a/quantum/debounce/tests/sym_defer_g_tests.cpp b/quantum/debounce/tests/sym_defer_g_tests.cpp
index a56aecd8f..73d3d45e3 100644
--- a/quantum/debounce/tests/sym_defer_g_tests.cpp
+++ b/quantum/debounce/tests/sym_defer_g_tests.cpp
@@ -19,7 +19,8 @@
19#include "debounce_test_common.h" 19#include "debounce_test_common.h"
20 20
21TEST_F(DebounceTest, OneKeyShort1) { 21TEST_F(DebounceTest, OneKeyShort1) {
22 addEvents({ /* Time, Inputs, Outputs */ 22 addEvents({
23 /* Time, Inputs, Outputs */
23 {0, {{0, 1, DOWN}}, {}}, 24 {0, {{0, 1, DOWN}}, {}},
24 25
25 {5, {}, {{0, 1, DOWN}}}, 26 {5, {}, {{0, 1, DOWN}}},
@@ -32,7 +33,8 @@ TEST_F(DebounceTest, OneKeyShort1) {
32} 33}
33 34
34TEST_F(DebounceTest, OneKeyShort2) { 35TEST_F(DebounceTest, OneKeyShort2) {
35 addEvents({ /* Time, Inputs, Outputs */ 36 addEvents({
37 /* Time, Inputs, Outputs */
36 {0, {{0, 1, DOWN}}, {}}, 38 {0, {{0, 1, DOWN}}, {}},
37 39
38 {5, {}, {{0, 1, DOWN}}}, 40 {5, {}, {{0, 1, DOWN}}},
@@ -45,7 +47,8 @@ TEST_F(DebounceTest, OneKeyShort2) {
45} 47}
46 48
47TEST_F(DebounceTest, OneKeyShort3) { 49TEST_F(DebounceTest, OneKeyShort3) {
48 addEvents({ /* Time, Inputs, Outputs */ 50 addEvents({
51 /* Time, Inputs, Outputs */
49 {0, {{0, 1, DOWN}}, {}}, 52 {0, {{0, 1, DOWN}}, {}},
50 53
51 {5, {}, {{0, 1, DOWN}}}, 54 {5, {}, {{0, 1, DOWN}}},
@@ -58,7 +61,8 @@ TEST_F(DebounceTest, OneKeyShort3) {
58} 61}
59 62
60TEST_F(DebounceTest, OneKeyTooQuick1) { 63TEST_F(DebounceTest, OneKeyTooQuick1) {
61 addEvents({ /* Time, Inputs, Outputs */ 64 addEvents({
65 /* Time, Inputs, Outputs */
62 {0, {{0, 1, DOWN}}, {}}, 66 {0, {{0, 1, DOWN}}, {}},
63 /* Release key exactly on the debounce time */ 67 /* Release key exactly on the debounce time */
64 {5, {{0, 1, UP}}, {}}, 68 {5, {{0, 1, UP}}, {}},
@@ -67,7 +71,8 @@ TEST_F(DebounceTest, OneKeyTooQuick1) {
67} 71}
68 72
69TEST_F(DebounceTest, OneKeyTooQuick2) { 73TEST_F(DebounceTest, OneKeyTooQuick2) {
70 addEvents({ /* Time, Inputs, Outputs */ 74 addEvents({
75 /* Time, Inputs, Outputs */
71 {0, {{0, 1, DOWN}}, {}}, 76 {0, {{0, 1, DOWN}}, {}},
72 77
73 {5, {}, {{0, 1, DOWN}}}, 78 {5, {}, {{0, 1, DOWN}}},
@@ -80,7 +85,8 @@ TEST_F(DebounceTest, OneKeyTooQuick2) {
80} 85}
81 86
82TEST_F(DebounceTest, OneKeyBouncing1) { 87TEST_F(DebounceTest, OneKeyBouncing1) {
83 addEvents({ /* Time, Inputs, Outputs */ 88 addEvents({
89 /* Time, Inputs, Outputs */
84 {0, {{0, 1, DOWN}}, {}}, 90 {0, {{0, 1, DOWN}}, {}},
85 {1, {{0, 1, UP}}, {}}, 91 {1, {{0, 1, UP}}, {}},
86 {2, {{0, 1, DOWN}}, {}}, 92 {2, {{0, 1, DOWN}}, {}},
@@ -94,7 +100,8 @@ TEST_F(DebounceTest, OneKeyBouncing1) {
94} 100}
95 101
96TEST_F(DebounceTest, OneKeyBouncing2) { 102TEST_F(DebounceTest, OneKeyBouncing2) {
97 addEvents({ /* Time, Inputs, Outputs */ 103 addEvents({
104 /* Time, Inputs, Outputs */
98 {0, {{0, 1, DOWN}}, {}}, 105 {0, {{0, 1, DOWN}}, {}},
99 {5, {}, {{0, 1, DOWN}}}, 106 {5, {}, {{0, 1, DOWN}}},
100 {6, {{0, 1, UP}}, {}}, 107 {6, {{0, 1, UP}}, {}},
@@ -108,7 +115,8 @@ TEST_F(DebounceTest, OneKeyBouncing2) {
108} 115}
109 116
110TEST_F(DebounceTest, OneKeyLong) { 117TEST_F(DebounceTest, OneKeyLong) {
111 addEvents({ /* Time, Inputs, Outputs */ 118 addEvents({
119 /* Time, Inputs, Outputs */
112 {0, {{0, 1, DOWN}}, {}}, 120 {0, {{0, 1, DOWN}}, {}},
113 121
114 {5, {}, {{0, 1, DOWN}}}, 122 {5, {}, {{0, 1, DOWN}}},
@@ -125,7 +133,8 @@ TEST_F(DebounceTest, OneKeyLong) {
125} 133}
126 134
127TEST_F(DebounceTest, TwoKeysShort) { 135TEST_F(DebounceTest, TwoKeysShort) {
128 addEvents({ /* Time, Inputs, Outputs */ 136 addEvents({
137 /* Time, Inputs, Outputs */
129 {0, {{0, 1, DOWN}}, {}}, 138 {0, {{0, 1, DOWN}}, {}},
130 {1, {{0, 2, DOWN}}, {}}, 139 {1, {{0, 2, DOWN}}, {}},
131 140
@@ -140,7 +149,8 @@ TEST_F(DebounceTest, TwoKeysShort) {
140} 149}
141 150
142TEST_F(DebounceTest, TwoKeysSimultaneous1) { 151TEST_F(DebounceTest, TwoKeysSimultaneous1) {
143 addEvents({ /* Time, Inputs, Outputs */ 152 addEvents({
153 /* Time, Inputs, Outputs */
144 {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {}}, 154 {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {}},
145 155
146 {5, {}, {{0, 1, DOWN}, {0, 2, DOWN}}}, 156 {5, {}, {{0, 1, DOWN}, {0, 2, DOWN}}},
@@ -152,7 +162,8 @@ TEST_F(DebounceTest, TwoKeysSimultaneous1) {
152} 162}
153 163
154TEST_F(DebounceTest, TwoKeysSimultaneous2) { 164TEST_F(DebounceTest, TwoKeysSimultaneous2) {
155 addEvents({ /* Time, Inputs, Outputs */ 165 addEvents({
166 /* Time, Inputs, Outputs */
156 {0, {{0, 1, DOWN}}, {}}, 167 {0, {{0, 1, DOWN}}, {}},
157 {1, {{0, 2, DOWN}}, {}}, 168 {1, {{0, 2, DOWN}}, {}},
158 169
@@ -167,7 +178,8 @@ TEST_F(DebounceTest, TwoKeysSimultaneous2) {
167} 178}
168 179
169TEST_F(DebounceTest, OneKeyDelayedScan1) { 180TEST_F(DebounceTest, OneKeyDelayedScan1) {
170 addEvents({ /* Time, Inputs, Outputs */ 181 addEvents({
182 /* Time, Inputs, Outputs */
171 {0, {{0, 1, DOWN}}, {}}, 183 {0, {{0, 1, DOWN}}, {}},
172 184
173 /* Processing is very late */ 185 /* Processing is very late */
@@ -182,7 +194,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan1) {
182} 194}
183 195
184TEST_F(DebounceTest, OneKeyDelayedScan2) { 196TEST_F(DebounceTest, OneKeyDelayedScan2) {
185 addEvents({ /* Time, Inputs, Outputs */ 197 addEvents({
198 /* Time, Inputs, Outputs */
186 {0, {{0, 1, DOWN}}, {}}, 199 {0, {{0, 1, DOWN}}, {}},
187 200
188 /* Processing is very late */ 201 /* Processing is very late */
@@ -197,7 +210,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan2) {
197} 210}
198 211
199TEST_F(DebounceTest, OneKeyDelayedScan3) { 212TEST_F(DebounceTest, OneKeyDelayedScan3) {
200 addEvents({ /* Time, Inputs, Outputs */ 213 addEvents({
214 /* Time, Inputs, Outputs */
201 {0, {{0, 1, DOWN}}, {}}, 215 {0, {{0, 1, DOWN}}, {}},
202 216
203 /* Release key before debounce expires */ 217 /* Release key before debounce expires */
@@ -208,7 +222,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan3) {
208} 222}
209 223
210TEST_F(DebounceTest, OneKeyDelayedScan4) { 224TEST_F(DebounceTest, OneKeyDelayedScan4) {
211 addEvents({ /* Time, Inputs, Outputs */ 225 addEvents({
226 /* Time, Inputs, Outputs */
212 {0, {{0, 1, DOWN}}, {}}, 227 {0, {{0, 1, DOWN}}, {}},
213 228
214 /* Processing is a bit late */ 229 /* Processing is a bit late */
diff --git a/quantum/debounce/tests/sym_defer_pk_tests.cpp b/quantum/debounce/tests/sym_defer_pk_tests.cpp
index 1f3061e59..7542c2dad 100644
--- a/quantum/debounce/tests/sym_defer_pk_tests.cpp
+++ b/quantum/debounce/tests/sym_defer_pk_tests.cpp
@@ -19,7 +19,8 @@
19#include "debounce_test_common.h" 19#include "debounce_test_common.h"
20 20
21TEST_F(DebounceTest, OneKeyShort1) { 21TEST_F(DebounceTest, OneKeyShort1) {
22 addEvents({ /* Time, Inputs, Outputs */ 22 addEvents({
23 /* Time, Inputs, Outputs */
23 {0, {{0, 1, DOWN}}, {}}, 24 {0, {{0, 1, DOWN}}, {}},
24 25
25 {5, {}, {{0, 1, DOWN}}}, 26 {5, {}, {{0, 1, DOWN}}},
@@ -32,7 +33,8 @@ TEST_F(DebounceTest, OneKeyShort1) {
32} 33}
33 34
34TEST_F(DebounceTest, OneKeyShort2) { 35TEST_F(DebounceTest, OneKeyShort2) {
35 addEvents({ /* Time, Inputs, Outputs */ 36 addEvents({
37 /* Time, Inputs, Outputs */
36 {0, {{0, 1, DOWN}}, {}}, 38 {0, {{0, 1, DOWN}}, {}},
37 39
38 {5, {}, {{0, 1, DOWN}}}, 40 {5, {}, {{0, 1, DOWN}}},
@@ -45,7 +47,8 @@ TEST_F(DebounceTest, OneKeyShort2) {
45} 47}
46 48
47TEST_F(DebounceTest, OneKeyShort3) { 49TEST_F(DebounceTest, OneKeyShort3) {
48 addEvents({ /* Time, Inputs, Outputs */ 50 addEvents({
51 /* Time, Inputs, Outputs */
49 {0, {{0, 1, DOWN}}, {}}, 52 {0, {{0, 1, DOWN}}, {}},
50 53
51 {5, {}, {{0, 1, DOWN}}}, 54 {5, {}, {{0, 1, DOWN}}},
@@ -58,7 +61,8 @@ TEST_F(DebounceTest, OneKeyShort3) {
58} 61}
59 62
60TEST_F(DebounceTest, OneKeyTooQuick1) { 63TEST_F(DebounceTest, OneKeyTooQuick1) {
61 addEvents({ /* Time, Inputs, Outputs */ 64 addEvents({
65 /* Time, Inputs, Outputs */
62 {0, {{0, 1, DOWN}}, {}}, 66 {0, {{0, 1, DOWN}}, {}},
63 /* Release key exactly on the debounce time */ 67 /* Release key exactly on the debounce time */
64 {5, {{0, 1, UP}}, {}}, 68 {5, {{0, 1, UP}}, {}},
@@ -67,7 +71,8 @@ TEST_F(DebounceTest, OneKeyTooQuick1) {
67} 71}
68 72
69TEST_F(DebounceTest, OneKeyTooQuick2) { 73TEST_F(DebounceTest, OneKeyTooQuick2) {
70 addEvents({ /* Time, Inputs, Outputs */ 74 addEvents({
75 /* Time, Inputs, Outputs */
71 {0, {{0, 1, DOWN}}, {}}, 76 {0, {{0, 1, DOWN}}, {}},
72 77
73 {5, {}, {{0, 1, DOWN}}}, 78 {5, {}, {{0, 1, DOWN}}},
@@ -80,7 +85,8 @@ TEST_F(DebounceTest, OneKeyTooQuick2) {
80} 85}
81 86
82TEST_F(DebounceTest, OneKeyBouncing1) { 87TEST_F(DebounceTest, OneKeyBouncing1) {
83 addEvents({ /* Time, Inputs, Outputs */ 88 addEvents({
89 /* Time, Inputs, Outputs */
84 {0, {{0, 1, DOWN}}, {}}, 90 {0, {{0, 1, DOWN}}, {}},
85 {1, {{0, 1, UP}}, {}}, 91 {1, {{0, 1, UP}}, {}},
86 {2, {{0, 1, DOWN}}, {}}, 92 {2, {{0, 1, DOWN}}, {}},
@@ -94,7 +100,8 @@ TEST_F(DebounceTest, OneKeyBouncing1) {
94} 100}
95 101
96TEST_F(DebounceTest, OneKeyBouncing2) { 102TEST_F(DebounceTest, OneKeyBouncing2) {
97 addEvents({ /* Time, Inputs, Outputs */ 103 addEvents({
104 /* Time, Inputs, Outputs */
98 {0, {{0, 1, DOWN}}, {}}, 105 {0, {{0, 1, DOWN}}, {}},
99 {5, {}, {{0, 1, DOWN}}}, 106 {5, {}, {{0, 1, DOWN}}},
100 {6, {{0, 1, UP}}, {}}, 107 {6, {{0, 1, UP}}, {}},
@@ -108,7 +115,8 @@ TEST_F(DebounceTest, OneKeyBouncing2) {
108} 115}
109 116
110TEST_F(DebounceTest, OneKeyLong) { 117TEST_F(DebounceTest, OneKeyLong) {
111 addEvents({ /* Time, Inputs, Outputs */ 118 addEvents({
119 /* Time, Inputs, Outputs */
112 {0, {{0, 1, DOWN}}, {}}, 120 {0, {{0, 1, DOWN}}, {}},
113 121
114 {5, {}, {{0, 1, DOWN}}}, 122 {5, {}, {{0, 1, DOWN}}},
@@ -125,7 +133,8 @@ TEST_F(DebounceTest, OneKeyLong) {
125} 133}
126 134
127TEST_F(DebounceTest, TwoKeysShort) { 135TEST_F(DebounceTest, TwoKeysShort) {
128 addEvents({ /* Time, Inputs, Outputs */ 136 addEvents({
137 /* Time, Inputs, Outputs */
129 {0, {{0, 1, DOWN}}, {}}, 138 {0, {{0, 1, DOWN}}, {}},
130 {1, {{0, 2, DOWN}}, {}}, 139 {1, {{0, 2, DOWN}}, {}},
131 140
@@ -142,7 +151,8 @@ TEST_F(DebounceTest, TwoKeysShort) {
142} 151}
143 152
144TEST_F(DebounceTest, TwoKeysSimultaneous1) { 153TEST_F(DebounceTest, TwoKeysSimultaneous1) {
145 addEvents({ /* Time, Inputs, Outputs */ 154 addEvents({
155 /* Time, Inputs, Outputs */
146 {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {}}, 156 {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {}},
147 157
148 {5, {}, {{0, 1, DOWN}, {0, 2, DOWN}}}, 158 {5, {}, {{0, 1, DOWN}, {0, 2, DOWN}}},
@@ -154,7 +164,8 @@ TEST_F(DebounceTest, TwoKeysSimultaneous1) {
154} 164}
155 165
156TEST_F(DebounceTest, TwoKeysSimultaneous2) { 166TEST_F(DebounceTest, TwoKeysSimultaneous2) {
157 addEvents({ /* Time, Inputs, Outputs */ 167 addEvents({
168 /* Time, Inputs, Outputs */
158 {0, {{0, 1, DOWN}}, {}}, 169 {0, {{0, 1, DOWN}}, {}},
159 {1, {{0, 2, DOWN}}, {}}, 170 {1, {{0, 2, DOWN}}, {}},
160 171
@@ -169,7 +180,8 @@ TEST_F(DebounceTest, TwoKeysSimultaneous2) {
169} 180}
170 181
171TEST_F(DebounceTest, OneKeyDelayedScan1) { 182TEST_F(DebounceTest, OneKeyDelayedScan1) {
172 addEvents({ /* Time, Inputs, Outputs */ 183 addEvents({
184 /* Time, Inputs, Outputs */
173 {0, {{0, 1, DOWN}}, {}}, 185 {0, {{0, 1, DOWN}}, {}},
174 186
175 /* Processing is very late */ 187 /* Processing is very late */
@@ -184,7 +196,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan1) {
184} 196}
185 197
186TEST_F(DebounceTest, OneKeyDelayedScan2) { 198TEST_F(DebounceTest, OneKeyDelayedScan2) {
187 addEvents({ /* Time, Inputs, Outputs */ 199 addEvents({
200 /* Time, Inputs, Outputs */
188 {0, {{0, 1, DOWN}}, {}}, 201 {0, {{0, 1, DOWN}}, {}},
189 202
190 /* Processing is very late */ 203 /* Processing is very late */
@@ -199,7 +212,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan2) {
199} 212}
200 213
201TEST_F(DebounceTest, OneKeyDelayedScan3) { 214TEST_F(DebounceTest, OneKeyDelayedScan3) {
202 addEvents({ /* Time, Inputs, Outputs */ 215 addEvents({
216 /* Time, Inputs, Outputs */
203 {0, {{0, 1, DOWN}}, {}}, 217 {0, {{0, 1, DOWN}}, {}},
204 218
205 /* Release key before debounce expires */ 219 /* Release key before debounce expires */
@@ -210,7 +224,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan3) {
210} 224}
211 225
212TEST_F(DebounceTest, OneKeyDelayedScan4) { 226TEST_F(DebounceTest, OneKeyDelayedScan4) {
213 addEvents({ /* Time, Inputs, Outputs */ 227 addEvents({
228 /* Time, Inputs, Outputs */
214 {0, {{0, 1, DOWN}}, {}}, 229 {0, {{0, 1, DOWN}}, {}},
215 230
216 /* Processing is a bit late */ 231 /* Processing is a bit late */
diff --git a/quantum/debounce/tests/sym_eager_pk_tests.cpp b/quantum/debounce/tests/sym_eager_pk_tests.cpp
index e0fc205e3..d9a02fe33 100644
--- a/quantum/debounce/tests/sym_eager_pk_tests.cpp
+++ b/quantum/debounce/tests/sym_eager_pk_tests.cpp
@@ -19,7 +19,8 @@
19#include "debounce_test_common.h" 19#include "debounce_test_common.h"
20 20
21TEST_F(DebounceTest, OneKeyShort1) { 21TEST_F(DebounceTest, OneKeyShort1) {
22 addEvents({ /* Time, Inputs, Outputs */ 22 addEvents({
23 /* Time, Inputs, Outputs */
23 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 24 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
24 {1, {{0, 1, UP}}, {}}, 25 {1, {{0, 1, UP}}, {}},
25 26
@@ -32,7 +33,8 @@ TEST_F(DebounceTest, OneKeyShort1) {
32} 33}
33 34
34TEST_F(DebounceTest, OneKeyShort2) { 35TEST_F(DebounceTest, OneKeyShort2) {
35 addEvents({ /* Time, Inputs, Outputs */ 36 addEvents({
37 /* Time, Inputs, Outputs */
36 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 38 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
37 {1, {{0, 1, UP}}, {}}, 39 {1, {{0, 1, UP}}, {}},
38 40
@@ -45,7 +47,8 @@ TEST_F(DebounceTest, OneKeyShort2) {
45} 47}
46 48
47TEST_F(DebounceTest, OneKeyShort3) { 49TEST_F(DebounceTest, OneKeyShort3) {
48 addEvents({ /* Time, Inputs, Outputs */ 50 addEvents({
51 /* Time, Inputs, Outputs */
49 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 52 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
50 {1, {{0, 1, UP}}, {}}, 53 {1, {{0, 1, UP}}, {}},
51 54
@@ -58,7 +61,8 @@ TEST_F(DebounceTest, OneKeyShort3) {
58} 61}
59 62
60TEST_F(DebounceTest, OneKeyShort4) { 63TEST_F(DebounceTest, OneKeyShort4) {
61 addEvents({ /* Time, Inputs, Outputs */ 64 addEvents({
65 /* Time, Inputs, Outputs */
62 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 66 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
63 {1, {{0, 1, UP}}, {}}, 67 {1, {{0, 1, UP}}, {}},
64 68
@@ -71,7 +75,8 @@ TEST_F(DebounceTest, OneKeyShort4) {
71} 75}
72 76
73TEST_F(DebounceTest, OneKeyShort5) { 77TEST_F(DebounceTest, OneKeyShort5) {
74 addEvents({ /* Time, Inputs, Outputs */ 78 addEvents({
79 /* Time, Inputs, Outputs */
75 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 80 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
76 {1, {{0, 1, UP}}, {}}, 81 {1, {{0, 1, UP}}, {}},
77 82
@@ -83,7 +88,8 @@ TEST_F(DebounceTest, OneKeyShort5) {
83} 88}
84 89
85TEST_F(DebounceTest, OneKeyShort6) { 90TEST_F(DebounceTest, OneKeyShort6) {
86 addEvents({ /* Time, Inputs, Outputs */ 91 addEvents({
92 /* Time, Inputs, Outputs */
87 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 93 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
88 {1, {{0, 1, UP}}, {}}, 94 {1, {{0, 1, UP}}, {}},
89 95
@@ -95,7 +101,8 @@ TEST_F(DebounceTest, OneKeyShort6) {
95} 101}
96 102
97TEST_F(DebounceTest, OneKeyBouncing1) { 103TEST_F(DebounceTest, OneKeyBouncing1) {
98 addEvents({ /* Time, Inputs, Outputs */ 104 addEvents({
105 /* Time, Inputs, Outputs */
99 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 106 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
100 {1, {{0, 1, UP}}, {}}, 107 {1, {{0, 1, UP}}, {}},
101 {2, {{0, 1, DOWN}}, {}}, 108 {2, {{0, 1, DOWN}}, {}},
@@ -110,7 +117,8 @@ TEST_F(DebounceTest, OneKeyBouncing1) {
110} 117}
111 118
112TEST_F(DebounceTest, OneKeyBouncing2) { 119TEST_F(DebounceTest, OneKeyBouncing2) {
113 addEvents({ /* Time, Inputs, Outputs */ 120 addEvents({
121 /* Time, Inputs, Outputs */
114 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 122 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
115 /* Change twice in the same time period */ 123 /* Change twice in the same time period */
116 {1, {{0, 1, UP}}, {}}, 124 {1, {{0, 1, UP}}, {}},
@@ -135,7 +143,8 @@ TEST_F(DebounceTest, OneKeyBouncing2) {
135} 143}
136 144
137TEST_F(DebounceTest, OneKeyLong) { 145TEST_F(DebounceTest, OneKeyLong) {
138 addEvents({ /* Time, Inputs, Outputs */ 146 addEvents({
147 /* Time, Inputs, Outputs */
139 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 148 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
140 149
141 {25, {{0, 1, UP}}, {{0, 1, UP}}}, 150 {25, {{0, 1, UP}}, {{0, 1, UP}}},
@@ -146,7 +155,8 @@ TEST_F(DebounceTest, OneKeyLong) {
146} 155}
147 156
148TEST_F(DebounceTest, TwoKeysShort) { 157TEST_F(DebounceTest, TwoKeysShort) {
149 addEvents({ /* Time, Inputs, Outputs */ 158 addEvents({
159 /* Time, Inputs, Outputs */
150 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 160 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
151 {1, {{0, 1, UP}}, {}}, 161 {1, {{0, 1, UP}}, {}},
152 {2, {{0, 2, DOWN}}, {{0, 2, DOWN}}}, 162 {2, {{0, 2, DOWN}}, {{0, 2, DOWN}}},
@@ -167,7 +177,8 @@ TEST_F(DebounceTest, TwoKeysShort) {
167} 177}
168 178
169TEST_F(DebounceTest, OneKeyDelayedScan1) { 179TEST_F(DebounceTest, OneKeyDelayedScan1) {
170 addEvents({ /* Time, Inputs, Outputs */ 180 addEvents({
181 /* Time, Inputs, Outputs */
171 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 182 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
172 183
173 /* Processing is very late but the change will now be accepted */ 184 /* Processing is very late but the change will now be accepted */
@@ -178,7 +189,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan1) {
178} 189}
179 190
180TEST_F(DebounceTest, OneKeyDelayedScan2) { 191TEST_F(DebounceTest, OneKeyDelayedScan2) {
181 addEvents({ /* Time, Inputs, Outputs */ 192 addEvents({
193 /* Time, Inputs, Outputs */
182 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 194 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
183 195
184 /* Processing is very late but the change will now be accepted even with a 1 scan delay */ 196 /* Processing is very late but the change will now be accepted even with a 1 scan delay */
@@ -190,7 +202,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan2) {
190} 202}
191 203
192TEST_F(DebounceTest, OneKeyDelayedScan3) { 204TEST_F(DebounceTest, OneKeyDelayedScan3) {
193 addEvents({ /* Time, Inputs, Outputs */ 205 addEvents({
206 /* Time, Inputs, Outputs */
194 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 207 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
195 208
196 /* Processing is very late but the change will now be accepted even with a 1ms delay */ 209 /* Processing is very late but the change will now be accepted even with a 1ms delay */
@@ -202,7 +215,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan3) {
202} 215}
203 216
204TEST_F(DebounceTest, OneKeyDelayedScan4) { 217TEST_F(DebounceTest, OneKeyDelayedScan4) {
205 addEvents({ /* Time, Inputs, Outputs */ 218 addEvents({
219 /* Time, Inputs, Outputs */
206 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 220 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
207 221
208 /* Processing is a bit late but the change will now be accepted */ 222 /* Processing is a bit late but the change will now be accepted */
@@ -213,7 +227,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan4) {
213} 227}
214 228
215TEST_F(DebounceTest, OneKeyDelayedScan5) { 229TEST_F(DebounceTest, OneKeyDelayedScan5) {
216 addEvents({ /* Time, Inputs, Outputs */ 230 addEvents({
231 /* Time, Inputs, Outputs */
217 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 232 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
218 233
219 /* Processing is very late but the change will now be accepted even with a 1 scan delay */ 234 /* Processing is very late but the change will now be accepted even with a 1 scan delay */
@@ -225,7 +240,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan5) {
225} 240}
226 241
227TEST_F(DebounceTest, OneKeyDelayedScan6) { 242TEST_F(DebounceTest, OneKeyDelayedScan6) {
228 addEvents({ /* Time, Inputs, Outputs */ 243 addEvents({
244 /* Time, Inputs, Outputs */
229 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 245 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
230 246
231 /* Processing is very late but the change will now be accepted even with a 1ms delay */ 247 /* Processing is very late but the change will now be accepted even with a 1ms delay */
diff --git a/quantum/debounce/tests/sym_eager_pr_tests.cpp b/quantum/debounce/tests/sym_eager_pr_tests.cpp
index 2c4bca127..e91dd9cb8 100644
--- a/quantum/debounce/tests/sym_eager_pr_tests.cpp
+++ b/quantum/debounce/tests/sym_eager_pr_tests.cpp
@@ -19,7 +19,8 @@
19#include "debounce_test_common.h" 19#include "debounce_test_common.h"
20 20
21TEST_F(DebounceTest, OneKeyShort1) { 21TEST_F(DebounceTest, OneKeyShort1) {
22 addEvents({ /* Time, Inputs, Outputs */ 22 addEvents({
23 /* Time, Inputs, Outputs */
23 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 24 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
24 {1, {{0, 1, UP}}, {}}, 25 {1, {{0, 1, UP}}, {}},
25 26
@@ -32,7 +33,8 @@ TEST_F(DebounceTest, OneKeyShort1) {
32} 33}
33 34
34TEST_F(DebounceTest, OneKeyShort2) { 35TEST_F(DebounceTest, OneKeyShort2) {
35 addEvents({ /* Time, Inputs, Outputs */ 36 addEvents({
37 /* Time, Inputs, Outputs */
36 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 38 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
37 {1, {{0, 1, UP}}, {}}, 39 {1, {{0, 1, UP}}, {}},
38 40
@@ -45,7 +47,8 @@ TEST_F(DebounceTest, OneKeyShort2) {
45} 47}
46 48
47TEST_F(DebounceTest, OneKeyShort3) { 49TEST_F(DebounceTest, OneKeyShort3) {
48 addEvents({ /* Time, Inputs, Outputs */ 50 addEvents({
51 /* Time, Inputs, Outputs */
49 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 52 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
50 {1, {{0, 1, UP}}, {}}, 53 {1, {{0, 1, UP}}, {}},
51 54
@@ -58,7 +61,8 @@ TEST_F(DebounceTest, OneKeyShort3) {
58} 61}
59 62
60TEST_F(DebounceTest, OneKeyShort4) { 63TEST_F(DebounceTest, OneKeyShort4) {
61 addEvents({ /* Time, Inputs, Outputs */ 64 addEvents({
65 /* Time, Inputs, Outputs */
62 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 66 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
63 {1, {{0, 1, UP}}, {}}, 67 {1, {{0, 1, UP}}, {}},
64 68
@@ -71,7 +75,8 @@ TEST_F(DebounceTest, OneKeyShort4) {
71} 75}
72 76
73TEST_F(DebounceTest, OneKeyShort5) { 77TEST_F(DebounceTest, OneKeyShort5) {
74 addEvents({ /* Time, Inputs, Outputs */ 78 addEvents({
79 /* Time, Inputs, Outputs */
75 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 80 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
76 {1, {{0, 1, UP}}, {}}, 81 {1, {{0, 1, UP}}, {}},
77 82
@@ -83,7 +88,8 @@ TEST_F(DebounceTest, OneKeyShort5) {
83} 88}
84 89
85TEST_F(DebounceTest, OneKeyShort6) { 90TEST_F(DebounceTest, OneKeyShort6) {
86 addEvents({ /* Time, Inputs, Outputs */ 91 addEvents({
92 /* Time, Inputs, Outputs */
87 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 93 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
88 {1, {{0, 1, UP}}, {}}, 94 {1, {{0, 1, UP}}, {}},
89 95
@@ -95,7 +101,8 @@ TEST_F(DebounceTest, OneKeyShort6) {
95} 101}
96 102
97TEST_F(DebounceTest, OneKeyBouncing1) { 103TEST_F(DebounceTest, OneKeyBouncing1) {
98 addEvents({ /* Time, Inputs, Outputs */ 104 addEvents({
105 /* Time, Inputs, Outputs */
99 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 106 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
100 {1, {{0, 1, UP}}, {}}, 107 {1, {{0, 1, UP}}, {}},
101 {2, {{0, 1, DOWN}}, {}}, 108 {2, {{0, 1, DOWN}}, {}},
@@ -110,7 +117,8 @@ TEST_F(DebounceTest, OneKeyBouncing1) {
110} 117}
111 118
112TEST_F(DebounceTest, OneKeyBouncing2) { 119TEST_F(DebounceTest, OneKeyBouncing2) {
113 addEvents({ /* Time, Inputs, Outputs */ 120 addEvents({
121 /* Time, Inputs, Outputs */
114 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 122 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
115 /* Change twice in the same time period */ 123 /* Change twice in the same time period */
116 {1, {{0, 1, UP}}, {}}, 124 {1, {{0, 1, UP}}, {}},
@@ -135,7 +143,8 @@ TEST_F(DebounceTest, OneKeyBouncing2) {
135} 143}
136 144
137TEST_F(DebounceTest, OneKeyLong) { 145TEST_F(DebounceTest, OneKeyLong) {
138 addEvents({ /* Time, Inputs, Outputs */ 146 addEvents({
147 /* Time, Inputs, Outputs */
139 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 148 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
140 149
141 {25, {{0, 1, UP}}, {{0, 1, UP}}}, 150 {25, {{0, 1, UP}}, {{0, 1, UP}}},
@@ -146,7 +155,8 @@ TEST_F(DebounceTest, OneKeyLong) {
146} 155}
147 156
148TEST_F(DebounceTest, TwoRowsShort) { 157TEST_F(DebounceTest, TwoRowsShort) {
149 addEvents({ /* Time, Inputs, Outputs */ 158 addEvents({
159 /* Time, Inputs, Outputs */
150 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 160 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
151 {1, {{0, 1, UP}}, {}}, 161 {1, {{0, 1, UP}}, {}},
152 {2, {{2, 0, DOWN}}, {{2, 0, DOWN}}}, 162 {2, {{2, 0, DOWN}}, {{2, 0, DOWN}}},
@@ -167,7 +177,8 @@ TEST_F(DebounceTest, TwoRowsShort) {
167} 177}
168 178
169TEST_F(DebounceTest, TwoKeysOverlap) { 179TEST_F(DebounceTest, TwoKeysOverlap) {
170 addEvents({ /* Time, Inputs, Outputs */ 180 addEvents({
181 /* Time, Inputs, Outputs */
171 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 182 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
172 {1, {{0, 1, UP}}, {}}, 183 {1, {{0, 1, UP}}, {}},
173 /* Press a second key during the first debounce */ 184 /* Press a second key during the first debounce */
@@ -190,7 +201,8 @@ TEST_F(DebounceTest, TwoKeysOverlap) {
190} 201}
191 202
192TEST_F(DebounceTest, TwoKeysSimultaneous1) { 203TEST_F(DebounceTest, TwoKeysSimultaneous1) {
193 addEvents({ /* Time, Inputs, Outputs */ 204 addEvents({
205 /* Time, Inputs, Outputs */
194 {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {{0, 1, DOWN}, {0, 2, DOWN}}}, 206 {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {{0, 1, DOWN}, {0, 2, DOWN}}},
195 {20, {{0, 1, UP}}, {{0, 1, UP}}}, 207 {20, {{0, 1, UP}}, {{0, 1, UP}}},
196 {21, {{0, 2, UP}}, {}}, 208 {21, {{0, 2, UP}}, {}},
@@ -202,7 +214,8 @@ TEST_F(DebounceTest, TwoKeysSimultaneous1) {
202} 214}
203 215
204TEST_F(DebounceTest, TwoKeysSimultaneous2) { 216TEST_F(DebounceTest, TwoKeysSimultaneous2) {
205 addEvents({ /* Time, Inputs, Outputs */ 217 addEvents({
218 /* Time, Inputs, Outputs */
206 {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {{0, 1, DOWN}, {0, 2, DOWN}}}, 219 {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {{0, 1, DOWN}, {0, 2, DOWN}}},
207 {20, {{0, 1, UP}, {0, 2, UP}}, {{0, 1, UP}, {0, 2, UP}}}, 220 {20, {{0, 1, UP}, {0, 2, UP}}, {{0, 1, UP}, {0, 2, UP}}},
208 }); 221 });
@@ -210,7 +223,8 @@ TEST_F(DebounceTest, TwoKeysSimultaneous2) {
210} 223}
211 224
212TEST_F(DebounceTest, OneKeyDelayedScan1) { 225TEST_F(DebounceTest, OneKeyDelayedScan1) {
213 addEvents({ /* Time, Inputs, Outputs */ 226 addEvents({
227 /* Time, Inputs, Outputs */
214 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 228 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
215 229
216 /* Processing is very late but the change will now be accepted */ 230 /* Processing is very late but the change will now be accepted */
@@ -221,7 +235,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan1) {
221} 235}
222 236
223TEST_F(DebounceTest, OneKeyDelayedScan2) { 237TEST_F(DebounceTest, OneKeyDelayedScan2) {
224 addEvents({ /* Time, Inputs, Outputs */ 238 addEvents({
239 /* Time, Inputs, Outputs */
225 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 240 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
226 241
227 /* Processing is very late but the change will now be accepted even with a 1 scan delay */ 242 /* Processing is very late but the change will now be accepted even with a 1 scan delay */
@@ -233,7 +248,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan2) {
233} 248}
234 249
235TEST_F(DebounceTest, OneKeyDelayedScan3) { 250TEST_F(DebounceTest, OneKeyDelayedScan3) {
236 addEvents({ /* Time, Inputs, Outputs */ 251 addEvents({
252 /* Time, Inputs, Outputs */
237 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 253 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
238 254
239 /* Processing is very late but the change will now be accepted even with a 1ms delay */ 255 /* Processing is very late but the change will now be accepted even with a 1ms delay */
@@ -245,7 +261,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan3) {
245} 261}
246 262
247TEST_F(DebounceTest, OneKeyDelayedScan4) { 263TEST_F(DebounceTest, OneKeyDelayedScan4) {
248 addEvents({ /* Time, Inputs, Outputs */ 264 addEvents({
265 /* Time, Inputs, Outputs */
249 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 266 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
250 267
251 /* Processing is a bit late but the change will now be accepted */ 268 /* Processing is a bit late but the change will now be accepted */
@@ -256,7 +273,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan4) {
256} 273}
257 274
258TEST_F(DebounceTest, OneKeyDelayedScan5) { 275TEST_F(DebounceTest, OneKeyDelayedScan5) {
259 addEvents({ /* Time, Inputs, Outputs */ 276 addEvents({
277 /* Time, Inputs, Outputs */
260 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 278 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
261 279
262 /* Processing is very late but the change will now be accepted even with a 1 scan delay */ 280 /* Processing is very late but the change will now be accepted even with a 1 scan delay */
@@ -268,7 +286,8 @@ TEST_F(DebounceTest, OneKeyDelayedScan5) {
268} 286}
269 287
270TEST_F(DebounceTest, OneKeyDelayedScan6) { 288TEST_F(DebounceTest, OneKeyDelayedScan6) {
271 addEvents({ /* Time, Inputs, Outputs */ 289 addEvents({
290 /* Time, Inputs, Outputs */
272 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}}, 291 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
273 292
274 /* Processing is very late but the change will now be accepted even with a 1ms delay */ 293 /* Processing is very late but the change will now be accepted even with a 1ms delay */
diff --git a/quantum/keymap_extras/keymap_steno.h b/quantum/keymap_extras/keymap_steno.h
index ab95b43fd..310aa0740 100644
--- a/quantum/keymap_extras/keymap_steno.h
+++ b/quantum/keymap_extras/keymap_steno.h
@@ -74,8 +74,7 @@ enum steno_keycodes {
74}; 74};
75 75
76#ifdef STENO_COMBINEDMAP 76#ifdef STENO_COMBINEDMAP
77enum steno_combined_keycodes 77enum steno_combined_keycodes {
78{
79 STN_S3 = QK_STENO_COMB, 78 STN_S3 = QK_STENO_COMB,
80 STN_TKL, 79 STN_TKL,
81 STN_PWL, 80 STN_PWL,
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c
index e8661839c..a050161ed 100644
--- a/quantum/process_keycode/process_combo.c
+++ b/quantum/process_keycode/process_combo.c
@@ -18,10 +18,9 @@
18#include "process_combo.h" 18#include "process_combo.h"
19#include "action_tapping.h" 19#include "action_tapping.h"
20 20
21
22#ifdef COMBO_COUNT 21#ifdef COMBO_COUNT
23__attribute__((weak)) combo_t key_combos[COMBO_COUNT]; 22__attribute__((weak)) combo_t key_combos[COMBO_COUNT];
24uint16_t COMBO_LEN = COMBO_COUNT; 23uint16_t COMBO_LEN = COMBO_COUNT;
25#else 24#else
26extern combo_t key_combos[]; 25extern combo_t key_combos[];
27extern uint16_t COMBO_LEN; 26extern uint16_t COMBO_LEN;
@@ -46,64 +45,86 @@ __attribute__((weak)) bool process_combo_key_release(uint16_t combo_index, combo
46#endif 45#endif
47 46
48#ifndef COMBO_NO_TIMER 47#ifndef COMBO_NO_TIMER
49static uint16_t timer = 0; 48static uint16_t timer = 0;
50#endif 49#endif
51static bool b_combo_enable = true; // defaults to enabled 50static bool b_combo_enable = true; // defaults to enabled
52static uint16_t longest_term = 0; 51static uint16_t longest_term = 0;
53 52
54typedef struct { 53typedef struct {
55 keyrecord_t record; 54 keyrecord_t record;
56 uint16_t combo_index; 55 uint16_t combo_index;
57 uint16_t keycode; 56 uint16_t keycode;
58} queued_record_t; 57} queued_record_t;
59static uint8_t key_buffer_size = 0; 58static uint8_t key_buffer_size = 0;
60static queued_record_t key_buffer[COMBO_KEY_BUFFER_LENGTH]; 59static queued_record_t key_buffer[COMBO_KEY_BUFFER_LENGTH];
61 60
62typedef struct { 61typedef struct {
63 uint16_t combo_index; 62 uint16_t combo_index;
64} queued_combo_t; 63} queued_combo_t;
65static uint8_t combo_buffer_write= 0; 64static uint8_t combo_buffer_write = 0;
66static uint8_t combo_buffer_read = 0; 65static uint8_t combo_buffer_read = 0;
67static queued_combo_t combo_buffer[COMBO_BUFFER_LENGTH]; 66static queued_combo_t combo_buffer[COMBO_BUFFER_LENGTH];
68 67
69#define INCREMENT_MOD(i) i = (i + 1) % COMBO_BUFFER_LENGTH 68#define INCREMENT_MOD(i) i = (i + 1) % COMBO_BUFFER_LENGTH
70 69
71#define COMBO_KEY_POS ((keypos_t){.col=254, .row=254}) 70#define COMBO_KEY_POS ((keypos_t){.col = 254, .row = 254})
72
73 71
74#ifndef EXTRA_SHORT_COMBOS 72#ifndef EXTRA_SHORT_COMBOS
75/* flags are their own elements in combo_t struct. */ 73/* flags are their own elements in combo_t struct. */
76# define COMBO_ACTIVE(combo) (combo->active) 74# define COMBO_ACTIVE(combo) (combo->active)
77# define COMBO_DISABLED(combo) (combo->disabled) 75# define COMBO_DISABLED(combo) (combo->disabled)
78# define COMBO_STATE(combo) (combo->state) 76# define COMBO_STATE(combo) (combo->state)
79 77
80# define ACTIVATE_COMBO(combo) do {combo->active = true;}while(0) 78# define ACTIVATE_COMBO(combo) \
81# define DEACTIVATE_COMBO(combo) do {combo->active = false;}while(0) 79 do { \
82# define DISABLE_COMBO(combo) do {combo->disabled = true;}while(0) 80 combo->active = true; \
83# define RESET_COMBO_STATE(combo) do { \ 81 } while (0)
84 combo->disabled = false; \ 82# define DEACTIVATE_COMBO(combo) \
85 combo->state = 0; \ 83 do { \
86}while(0) 84 combo->active = false; \
85 } while (0)
86# define DISABLE_COMBO(combo) \
87 do { \
88 combo->disabled = true; \
89 } while (0)
90# define RESET_COMBO_STATE(combo) \
91 do { \
92 combo->disabled = false; \
93 combo->state = 0; \
94 } while (0)
87#else 95#else
88/* flags are at the two high bits of state. */ 96/* flags are at the two high bits of state. */
89# define COMBO_ACTIVE(combo) (combo->state & 0x80) 97# define COMBO_ACTIVE(combo) (combo->state & 0x80)
90# define COMBO_DISABLED(combo) (combo->state & 0x40) 98# define COMBO_DISABLED(combo) (combo->state & 0x40)
91# define COMBO_STATE(combo) (combo->state & 0x3F) 99# define COMBO_STATE(combo) (combo->state & 0x3F)
92 100
93# define ACTIVATE_COMBO(combo) do {combo->state |= 0x80;}while(0) 101# define ACTIVATE_COMBO(combo) \
94# define DEACTIVATE_COMBO(combo) do {combo->state &= ~0x80;}while(0) 102 do { \
95# define DISABLE_COMBO(combo) do {combo->state |= 0x40;}while(0) 103 combo->state |= 0x80; \
96# define RESET_COMBO_STATE(combo) do {combo->state &= ~0x7F;}while(0) 104 } while (0)
105# define DEACTIVATE_COMBO(combo) \
106 do { \
107 combo->state &= ~0x80; \
108 } while (0)
109# define DISABLE_COMBO(combo) \
110 do { \
111 combo->state |= 0x40; \
112 } while (0)
113# define RESET_COMBO_STATE(combo) \
114 do { \
115 combo->state &= ~0x7F; \
116 } while (0)
97#endif 117#endif
98 118
99static inline void release_combo(uint16_t combo_index, combo_t *combo) { 119static inline void release_combo(uint16_t combo_index, combo_t *combo) {
100 if (combo->keycode) { 120 if (combo->keycode) {
101 keyrecord_t record = { 121 keyrecord_t record = {
102 .event = { 122 .event =
103 .key = COMBO_KEY_POS, 123 {
104 .time = timer_read()|1, 124 .key = COMBO_KEY_POS,
105 .pressed = false, 125 .time = timer_read() | 1,
106 }, 126 .pressed = false,
127 },
107 .keycode = combo->keycode, 128 .keycode = combo->keycode,
108 }; 129 };
109#ifndef NO_ACTION_TAPPING 130#ifndef NO_ACTION_TAPPING
@@ -123,18 +144,17 @@ static inline bool _get_combo_must_hold(uint16_t combo_index, combo_t *combo) {
123#elif defined(COMBO_MUST_HOLD_PER_COMBO) 144#elif defined(COMBO_MUST_HOLD_PER_COMBO)
124 return get_combo_must_hold(combo_index, combo); 145 return get_combo_must_hold(combo_index, combo);
125#elif defined(COMBO_MUST_HOLD_MODS) 146#elif defined(COMBO_MUST_HOLD_MODS)
126 return (KEYCODE_IS_MOD(combo->keycode) || 147 return (KEYCODE_IS_MOD(combo->keycode) || (combo->keycode >= QK_MOMENTARY && combo->keycode <= QK_MOMENTARY_MAX));
127 (combo->keycode >= QK_MOMENTARY && combo->keycode <= QK_MOMENTARY_MAX));
128#endif 148#endif
129 return false; 149 return false;
130} 150}
131 151
132static inline uint16_t _get_wait_time(uint16_t combo_index, combo_t *combo ) { 152static inline uint16_t _get_wait_time(uint16_t combo_index, combo_t *combo) {
133 if (_get_combo_must_hold(combo_index, combo) 153 if (_get_combo_must_hold(combo_index, combo)
134#ifdef COMBO_MUST_TAP_PER_COMBO 154#ifdef COMBO_MUST_TAP_PER_COMBO
135 || get_combo_must_tap(combo_index, combo) 155 || get_combo_must_tap(combo_index, combo)
136#endif 156#endif
137 ) { 157 ) {
138 if (longest_term < COMBO_HOLD_TERM) { 158 if (longest_term < COMBO_HOLD_TERM) {
139 return COMBO_HOLD_TERM; 159 return COMBO_HOLD_TERM;
140 } 160 }
@@ -144,9 +164,8 @@ static inline uint16_t _get_wait_time(uint16_t combo_index, combo_t *combo ) {
144} 164}
145 165
146static inline uint16_t _get_combo_term(uint16_t combo_index, combo_t *combo) { 166static inline uint16_t _get_combo_term(uint16_t combo_index, combo_t *combo) {
147
148#if defined(COMBO_TERM_PER_COMBO) 167#if defined(COMBO_TERM_PER_COMBO)
149 return get_combo_term(combo_index, combo); 168 return get_combo_term(combo_index, combo);
150#endif 169#endif
151 170
152 return COMBO_TERM; 171 return COMBO_TERM;
@@ -154,7 +173,7 @@ static inline uint16_t _get_combo_term(uint16_t combo_index, combo_t *combo) {
154 173
155void clear_combos(void) { 174void clear_combos(void) {
156 uint16_t index = 0; 175 uint16_t index = 0;
157 longest_term = 0; 176 longest_term = 0;
158 for (index = 0; index < COMBO_LEN; ++index) { 177 for (index = 0; index < COMBO_LEN; ++index) {
159 combo_t *combo = &key_combos[index]; 178 combo_t *combo = &key_combos[index];
160 if (!COMBO_ACTIVE(combo)) { 179 if (!COMBO_ACTIVE(combo)) {
@@ -175,7 +194,7 @@ static inline void dump_key_buffer(void) {
175 key_buffer_next = key_buffer_i + 1; 194 key_buffer_next = key_buffer_i + 1;
176 195
177 queued_record_t *qrecord = &key_buffer[key_buffer_i]; 196 queued_record_t *qrecord = &key_buffer[key_buffer_i];
178 keyrecord_t *record = &qrecord->record; 197 keyrecord_t * record = &qrecord->record;
179 198
180 if (IS_NOEVENT(record->event)) { 199 if (IS_NOEVENT(record->event)) {
181 continue; 200 continue;
@@ -185,9 +204,9 @@ static inline void dump_key_buffer(void) {
185 process_combo_event(qrecord->combo_index, true); 204 process_combo_event(qrecord->combo_index, true);
186 } else { 205 } else {
187#ifndef NO_ACTION_TAPPING 206#ifndef NO_ACTION_TAPPING
188 action_tapping_process(*record); 207 action_tapping_process(*record);
189#else 208#else
190 process_record(record); 209 process_record(record);
191#endif 210#endif
192 } 211 }
193 record->event.time = 0; 212 record->event.time = 0;
@@ -242,7 +261,9 @@ void apply_combo(uint16_t combo_index, combo_t *combo) {
242 /* Apply combo's result keycode to the last chord key of the combo and 261 /* Apply combo's result keycode to the last chord key of the combo and
243 * disable the other keys. */ 262 * disable the other keys. */
244 263
245 if (COMBO_DISABLED(combo)) { return; } 264 if (COMBO_DISABLED(combo)) {
265 return;
266 }
246 267
247 // state to check against so we find the last key of the combo from the buffer 268 // state to check against so we find the last key of the combo from the buffer
248#if defined(EXTRA_EXTRA_LONG_COMBOS) 269#if defined(EXTRA_EXTRA_LONG_COMBOS)
@@ -254,12 +275,11 @@ void apply_combo(uint16_t combo_index, combo_t *combo) {
254#endif 275#endif
255 276
256 for (uint8_t key_buffer_i = 0; key_buffer_i < key_buffer_size; key_buffer_i++) { 277 for (uint8_t key_buffer_i = 0; key_buffer_i < key_buffer_size; key_buffer_i++) {
257
258 queued_record_t *qrecord = &key_buffer[key_buffer_i]; 278 queued_record_t *qrecord = &key_buffer[key_buffer_i];
259 keyrecord_t *record = &qrecord->record; 279 keyrecord_t * record = &qrecord->record;
260 uint16_t keycode = qrecord->keycode; 280 uint16_t keycode = qrecord->keycode;
261 281
262 uint8_t key_count = 0; 282 uint8_t key_count = 0;
263 uint16_t key_index = -1; 283 uint16_t key_index = -1;
264 _find_key_index_and_count(combo->keys, keycode, &key_index, &key_count); 284 _find_key_index_and_count(combo->keys, keycode, &key_index, &key_count);
265 285
@@ -271,7 +291,7 @@ void apply_combo(uint16_t combo_index, combo_t *combo) {
271 KEY_STATE_DOWN(state, key_index); 291 KEY_STATE_DOWN(state, key_index);
272 if (ALL_COMBO_KEYS_ARE_DOWN(state, key_count)) { 292 if (ALL_COMBO_KEYS_ARE_DOWN(state, key_count)) {
273 // this in the end executes the combo when the key_buffer is dumped. 293 // this in the end executes the combo when the key_buffer is dumped.
274 record->keycode = combo->keycode; 294 record->keycode = combo->keycode;
275 record->event.key = COMBO_KEY_POS; 295 record->event.key = COMBO_KEY_POS;
276 296
277 qrecord->combo_index = combo_index; 297 qrecord->combo_index = combo_index;
@@ -283,19 +303,15 @@ void apply_combo(uint16_t combo_index, combo_t *combo) {
283 // by making it a TICK event. 303 // by making it a TICK event.
284 record->event.time = 0; 304 record->event.time = 0;
285 } 305 }
286
287 } 306 }
288 drop_combo_from_buffer(combo_index); 307 drop_combo_from_buffer(combo_index);
289} 308}
290 309
291static inline void apply_combos(void) { 310static inline void apply_combos(void) {
292 // Apply all buffered normal combos. 311 // Apply all buffered normal combos.
293 for (uint8_t i = combo_buffer_read; 312 for (uint8_t i = combo_buffer_read; i != combo_buffer_write; INCREMENT_MOD(i)) {
294 i != combo_buffer_write;
295 INCREMENT_MOD(i)) {
296
297 queued_combo_t *buffered_combo = &combo_buffer[i]; 313 queued_combo_t *buffered_combo = &combo_buffer[i];
298 combo_t *combo = &key_combos[buffered_combo->combo_index]; 314 combo_t * combo = &key_combos[buffered_combo->combo_index];
299 315
300#ifdef COMBO_MUST_TAP_PER_COMBO 316#ifdef COMBO_MUST_TAP_PER_COMBO
301 if (get_combo_must_tap(buffered_combo->combo_index, combo)) { 317 if (get_combo_must_tap(buffered_combo->combo_index, combo)) {
@@ -310,15 +326,15 @@ static inline void apply_combos(void) {
310 clear_combos(); 326 clear_combos();
311} 327}
312 328
313combo_t* overlaps(combo_t *combo1, combo_t *combo2) { 329combo_t *overlaps(combo_t *combo1, combo_t *combo2) {
314 /* Checks if the combos overlap and returns the combo that should be 330 /* Checks if the combos overlap and returns the combo that should be
315 * dropped from the combo buffer. 331 * dropped from the combo buffer.
316 * The combo that has less keys will be dropped. If they have the same 332 * The combo that has less keys will be dropped. If they have the same
317 * amount of keys, drop combo1. */ 333 * amount of keys, drop combo1. */
318 334
319 uint8_t idx1 = 0, idx2 = 0; 335 uint8_t idx1 = 0, idx2 = 0;
320 uint16_t key1, key2; 336 uint16_t key1, key2;
321 bool overlaps = false; 337 bool overlaps = false;
322 338
323 while ((key1 = pgm_read_word(&combo1->keys[idx1])) != COMBO_END) { 339 while ((key1 = pgm_read_word(&combo1->keys[idx1])) != COMBO_END) {
324 idx2 = 0; 340 idx2 = 0;
@@ -335,7 +351,7 @@ combo_t* overlaps(combo_t *combo1, combo_t *combo2) {
335} 351}
336 352
337static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *record, uint16_t combo_index) { 353static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *record, uint16_t combo_index) {
338 uint8_t key_count = 0; 354 uint8_t key_count = 0;
339 uint16_t key_index = -1; 355 uint16_t key_index = -1;
340 _find_key_index_and_count(combo->keys, keycode, &key_index, &key_count); 356 _find_key_index_and_count(combo->keys, keycode, &key_index, &key_count);
341 357
@@ -369,12 +385,9 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
369 385
370 // disable readied combos that overlap with this combo 386 // disable readied combos that overlap with this combo
371 combo_t *drop = NULL; 387 combo_t *drop = NULL;
372 for (uint8_t combo_buffer_i = combo_buffer_read; 388 for (uint8_t combo_buffer_i = combo_buffer_read; combo_buffer_i != combo_buffer_write; INCREMENT_MOD(combo_buffer_i)) {
373 combo_buffer_i != combo_buffer_write; 389 queued_combo_t *qcombo = &combo_buffer[combo_buffer_i];
374 INCREMENT_MOD(combo_buffer_i)) { 390 combo_t * buffered_combo = &key_combos[qcombo->combo_index];
375
376 queued_combo_t *qcombo = &combo_buffer[combo_buffer_i];
377 combo_t *buffered_combo = &key_combos[qcombo->combo_index];
378 391
379 if ((drop = overlaps(buffered_combo, combo))) { 392 if ((drop = overlaps(buffered_combo, combo))) {
380 DISABLE_COMBO(drop); 393 DISABLE_COMBO(drop);
@@ -387,21 +400,19 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
387 INCREMENT_MOD(combo_buffer_read); 400 INCREMENT_MOD(combo_buffer_read);
388 } 401 }
389 } 402 }
390
391 } 403 }
392 404
393 if (drop != combo) { 405 if (drop != combo) {
394 // save this combo to buffer 406 // save this combo to buffer
395 combo_buffer[combo_buffer_write] = (queued_combo_t){ 407 combo_buffer[combo_buffer_write] = (queued_combo_t){
396 .combo_index=combo_index, 408 .combo_index = combo_index,
397 }; 409 };
398 INCREMENT_MOD(combo_buffer_write); 410 INCREMENT_MOD(combo_buffer_write);
399 411
400 // get possible longer waiting time for tap-/hold-only combos. 412 // get possible longer waiting time for tap-/hold-only combos.
401 longest_term = _get_wait_time(combo_index, combo); 413 longest_term = _get_wait_time(combo_index, combo);
402 } 414 }
403 } // if timer elapsed end 415 } // if timer elapsed end
404
405 } 416 }
406 } else { 417 } else {
407 // chord releases 418 // chord releases
@@ -416,7 +427,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
416 else if (get_combo_must_tap(combo_index, combo)) { 427 else if (get_combo_must_tap(combo_index, combo)) {
417 // immediately apply tap-only combo 428 // immediately apply tap-only combo
418 apply_combo(combo_index, combo); 429 apply_combo(combo_index, combo);
419 apply_combos(); // also apply other prepared combos and dump key buffer 430 apply_combos(); // also apply other prepared combos and dump key buffer
420# ifdef COMBO_PROCESS_KEY_RELEASE 431# ifdef COMBO_PROCESS_KEY_RELEASE
421 if (process_combo_key_release(combo_index, combo, key_index, keycode)) { 432 if (process_combo_key_release(combo_index, combo, key_index, keycode)) {
422 release_combo(combo_index, combo); 433 release_combo(combo_index, combo);
@@ -424,10 +435,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
424# endif 435# endif
425 } 436 }
426#endif 437#endif
427 } else if (COMBO_ACTIVE(combo) 438 } else if (COMBO_ACTIVE(combo) && ONLY_ONE_KEY_IS_DOWN(COMBO_STATE(combo)) && KEY_NOT_YET_RELEASED(COMBO_STATE(combo), key_index)) {
428 && ONLY_ONE_KEY_IS_DOWN(COMBO_STATE(combo))
429 && KEY_NOT_YET_RELEASED(COMBO_STATE(combo), key_index)
430 ) {
431 /* last key released */ 439 /* last key released */
432 release_combo(combo_index, combo); 440 release_combo(combo_index, combo);
433 key_is_part_of_combo = true; 441 key_is_part_of_combo = true;
@@ -435,9 +443,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
435#ifdef COMBO_PROCESS_KEY_RELEASE 443#ifdef COMBO_PROCESS_KEY_RELEASE
436 process_combo_key_release(combo_index, combo, key_index, keycode); 444 process_combo_key_release(combo_index, combo, key_index, keycode);
437#endif 445#endif
438 } else if (COMBO_ACTIVE(combo) 446 } else if (COMBO_ACTIVE(combo) && KEY_NOT_YET_RELEASED(COMBO_STATE(combo), key_index)) {
439 && KEY_NOT_YET_RELEASED(COMBO_STATE(combo), key_index)
440 ) {
441 /* first or middle key released */ 447 /* first or middle key released */
442 key_is_part_of_combo = true; 448 key_is_part_of_combo = true;
443 449
@@ -489,21 +495,21 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) {
489 495
490 if (record->event.pressed && is_combo_key) { 496 if (record->event.pressed && is_combo_key) {
491#ifndef COMBO_NO_TIMER 497#ifndef COMBO_NO_TIMER
492# ifdef COMBO_STRICT_TIMER 498# ifdef COMBO_STRICT_TIMER
493 if (!timer) { 499 if (!timer) {
494 // timer is set only on the first key 500 // timer is set only on the first key
495 timer = timer_read(); 501 timer = timer_read();
496 } 502 }
497# else 503# else
498 timer = timer_read(); 504 timer = timer_read();
499# endif 505# endif
500#endif 506#endif
501 507
502 if (key_buffer_size < COMBO_KEY_BUFFER_LENGTH) { 508 if (key_buffer_size < COMBO_KEY_BUFFER_LENGTH) {
503 key_buffer[key_buffer_size++] = (queued_record_t){ 509 key_buffer[key_buffer_size++] = (queued_record_t){
504 .record = *record, 510 .record = *record,
505 .keycode = keycode, 511 .keycode = keycode,
506 .combo_index = -1, // this will be set when applying combos 512 .combo_index = -1, // this will be set when applying combos
507 }; 513 };
508 } 514 }
509 } else { 515 } else {
@@ -532,7 +538,7 @@ void combo_task(void) {
532 if (combo_buffer_read != combo_buffer_write) { 538 if (combo_buffer_read != combo_buffer_write) {
533 apply_combos(); 539 apply_combos();
534 longest_term = 0; 540 longest_term = 0;
535 timer = 0; 541 timer = 0;
536 } else { 542 } else {
537 dump_key_buffer(); 543 dump_key_buffer();
538 timer = 0; 544 timer = 0;
@@ -546,9 +552,9 @@ void combo_enable(void) { b_combo_enable = true; }
546 552
547void combo_disable(void) { 553void combo_disable(void) {
548#ifndef COMBO_NO_TIMER 554#ifndef COMBO_NO_TIMER
549 timer = 0; 555 timer = 0;
550#endif 556#endif
551 b_combo_enable = false; 557 b_combo_enable = false;
552 combo_buffer_read = combo_buffer_write; 558 combo_buffer_read = combo_buffer_write;
553 clear_combos(); 559 clear_combos();
554 dump_key_buffer(); 560 dump_key_buffer();
diff --git a/quantum/process_keycode/process_combo.h b/quantum/process_keycode/process_combo.h
index 43c36d79e..4c4e574e3 100644
--- a/quantum/process_keycode/process_combo.h
+++ b/quantum/process_keycode/process_combo.h
@@ -43,8 +43,8 @@ typedef struct {
43#ifdef EXTRA_SHORT_COMBOS 43#ifdef EXTRA_SHORT_COMBOS
44 uint8_t state; 44 uint8_t state;
45#else 45#else
46 bool disabled; 46 bool disabled;
47 bool active; 47 bool active;
48# if defined(EXTRA_EXTRA_LONG_COMBOS) 48# if defined(EXTRA_EXTRA_LONG_COMBOS)
49 uint32_t state; 49 uint32_t state;
50# elif defined(EXTRA_LONG_COMBOS) 50# elif defined(EXTRA_LONG_COMBOS)
diff --git a/quantum/process_keycode/process_steno.c b/quantum/process_keycode/process_steno.c
index a964aead3..5d0bb313b 100644
--- a/quantum/process_keycode/process_steno.c
+++ b/quantum/process_keycode/process_steno.c
@@ -67,7 +67,7 @@ static const uint8_t boltmap[64] PROGMEM = {TXB_NUL, TXB_NUM, TXB_NUM, TXB_NUM,
67 67
68#ifdef STENO_COMBINEDMAP 68#ifdef STENO_COMBINEDMAP
69/* Used to look up when pressing the middle row key to combine two consonant or vowel keys */ 69/* Used to look up when pressing the middle row key to combine two consonant or vowel keys */
70static const uint16_t combinedmap_first[] PROGMEM = {STN_S1, STN_TL, STN_PL, STN_HL, STN_FR, STN_PR, STN_LR, STN_TR, STN_DR, STN_A, STN_E}; 70static const uint16_t combinedmap_first[] PROGMEM = {STN_S1, STN_TL, STN_PL, STN_HL, STN_FR, STN_PR, STN_LR, STN_TR, STN_DR, STN_A, STN_E};
71static const uint16_t combinedmap_second[] PROGMEM = {STN_S2, STN_KL, STN_WL, STN_RL, STN_RR, STN_BR, STN_GR, STN_SR, STN_ZR, STN_O, STN_U}; 71static const uint16_t combinedmap_second[] PROGMEM = {STN_S2, STN_KL, STN_WL, STN_RL, STN_RR, STN_BR, STN_GR, STN_SR, STN_ZR, STN_O, STN_U};
72#endif 72#endif
73 73
@@ -174,11 +174,10 @@ bool process_steno(uint16_t keycode, keyrecord_t *record) {
174 return false; 174 return false;
175 175
176#ifdef STENO_COMBINEDMAP 176#ifdef STENO_COMBINEDMAP
177 case QK_STENO_COMB ... QK_STENO_COMB_MAX: 177 case QK_STENO_COMB ... QK_STENO_COMB_MAX: {
178 {
179 uint8_t result; 178 uint8_t result;
180 result = process_steno(combinedmap_first[keycode-QK_STENO_COMB], record); 179 result = process_steno(combinedmap_first[keycode - QK_STENO_COMB], record);
181 result &= process_steno(combinedmap_second[keycode-QK_STENO_COMB], record); 180 result &= process_steno(combinedmap_second[keycode - QK_STENO_COMB], record);
182 return result; 181 return result;
183 } 182 }
184#endif 183#endif
diff --git a/quantum/quantum.c b/quantum/quantum.c
index e60378afe..0ae12b583 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -145,12 +145,13 @@ void reset_keyboard(void) {
145/* Convert record into usable keycode via the contained event. */ 145/* Convert record into usable keycode via the contained event. */
146uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) { 146uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) {
147#ifdef COMBO_ENABLE 147#ifdef COMBO_ENABLE
148 if (record->keycode) { return record->keycode; } 148 if (record->keycode) {
149 return record->keycode;
150 }
149#endif 151#endif
150 return get_event_keycode(record->event, update_layer_cache); 152 return get_event_keycode(record->event, update_layer_cache);
151} 153}
152 154
153
154/* Convert event into usable keycode. Checks the layer cache to ensure that it 155/* Convert event into usable keycode. Checks the layer cache to ensure that it
155 * retains the correct keycode after a layer change, if the key is still pressed. 156 * retains the correct keycode after a layer change, if the key is still pressed.
156 * "update_layer_cache" is to ensure that it only updates the layer cache when 157 * "update_layer_cache" is to ensure that it only updates the layer cache when
@@ -179,12 +180,12 @@ uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache) {
179bool pre_process_record_quantum(keyrecord_t *record) { 180bool pre_process_record_quantum(keyrecord_t *record) {
180 if (!( 181 if (!(
181#ifdef COMBO_ENABLE 182#ifdef COMBO_ENABLE
182 process_combo(get_record_keycode(record, true), record) && 183 process_combo(get_record_keycode(record, true), record) &&
183#endif 184#endif
184 true)) { 185 true)) {
185 return false; 186 return false;
186 } 187 }
187 return true; // continue processing 188 return true; // continue processing
188} 189}
189 190
190/* Get keycode, and then call keyboard function */ 191/* Get keycode, and then call keyboard function */
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index ef4b0f457..99eade0e0 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -775,12 +775,12 @@ enum quantum_keycodes {
775#define CMD_T(kc) LCMD_T(kc) 775#define CMD_T(kc) LCMD_T(kc)
776#define WIN_T(kc) LWIN_T(kc) 776#define WIN_T(kc) LWIN_T(kc)
777 777
778#define C_S_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) // Left Control + Shift e.g. for gnome-terminal 778#define C_S_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) // Left Control + Shift e.g. for gnome-terminal
779#define MEH_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT, kc) // Meh is a less hyper version of the Hyper key -- doesn't include GUI, so just Left Control + Shift + Alt 779#define MEH_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT, kc) // Meh is a less hyper version of the Hyper key -- doesn't include GUI, so just Left Control + Shift + Alt
780#define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) // Left Control + Alt + GUI 780#define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) // Left Control + Alt + GUI
781#define RCAG_T(kc) MT(MOD_RCTL | MOD_RALT | MOD_RGUI, kc) // Right Control + Alt + GUI 781#define RCAG_T(kc) MT(MOD_RCTL | MOD_RALT | MOD_RGUI, kc) // Right Control + Alt + GUI
782#define HYPR_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI, kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/ 782#define HYPR_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI, kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/
783#define LSG_T(kc) MT(MOD_LSFT | MOD_LGUI, kc) // Left Shift + GUI 783#define LSG_T(kc) MT(MOD_LSFT | MOD_LGUI, kc) // Left Shift + GUI
784#define SGUI_T(kc) LSG_T(kc) 784#define SGUI_T(kc) LSG_T(kc)
785#define SCMD_T(kc) LSG_T(kc) 785#define SCMD_T(kc) LSG_T(kc)
786#define SWIN_T(kc) LSG_T(kc) 786#define SWIN_T(kc) LSG_T(kc)
@@ -811,7 +811,7 @@ enum quantum_keycodes {
811 811
812#define UC_M_MA UNICODE_MODE_MAC 812#define UC_M_MA UNICODE_MODE_MAC
813#define UNICODE_MODE_OSX UNICODE_MODE_MAC // Deprecated alias 813#define UNICODE_MODE_OSX UNICODE_MODE_MAC // Deprecated alias
814#define UC_M_OS UNICODE_MODE_MAC // Deprecated alias 814#define UC_M_OS UNICODE_MODE_MAC // Deprecated alias
815#define UC_M_LN UNICODE_MODE_LNX 815#define UC_M_LN UNICODE_MODE_LNX
816#define UC_M_WI UNICODE_MODE_WIN 816#define UC_M_WI UNICODE_MODE_WIN
817#define UC_M_BS UNICODE_MODE_BSD 817#define UC_M_BS UNICODE_MODE_BSD
diff --git a/quantum/split_common/transactions.c b/quantum/split_common/transactions.c
index fd676f072..3ff87710e 100644
--- a/quantum/split_common/transactions.c
+++ b/quantum/split_common/transactions.c
@@ -42,8 +42,8 @@
42 { &dummy, 0, 0, sizeof_member(split_shared_memory_t, member), offsetof(split_shared_memory_t, member), cb } 42 { &dummy, 0, 0, sizeof_member(split_shared_memory_t, member), offsetof(split_shared_memory_t, member), cb }
43#define trans_target2initiator_initializer(member) trans_target2initiator_initializer_cb(member, NULL) 43#define trans_target2initiator_initializer(member) trans_target2initiator_initializer_cb(member, NULL)
44 44
45#define transport_write(id, data, length) transport_execute_transaction(id, data, length, NULL, 0) 45#define transport_write(id, data, length) transport_execute_transaction(id, data, length, NULL, 0)
46#define transport_read(id, data, length) transport_execute_transaction(id, NULL, 0, data, length) 46#define transport_read(id, data, length) transport_execute_transaction(id, NULL, 0, data, length)
47 47
48#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) 48#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
49// Forward-declare the RPC callback handlers 49// Forward-declare the RPC callback handlers
@@ -157,8 +157,8 @@ static void master_matrix_handlers_slave(matrix_row_t master_matrix[], matrix_ro
157 memcpy(master_matrix, split_shmem->mmatrix.matrix, sizeof(split_shmem->mmatrix.matrix)); 157 memcpy(master_matrix, split_shmem->mmatrix.matrix, sizeof(split_shmem->mmatrix.matrix));
158} 158}
159 159
160# define TRANSACTIONS_MASTER_MATRIX_MASTER() TRANSACTION_HANDLER_MASTER(master_matrix) 160# define TRANSACTIONS_MASTER_MATRIX_MASTER() TRANSACTION_HANDLER_MASTER(master_matrix)
161# define TRANSACTIONS_MASTER_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(master_matrix) 161# define TRANSACTIONS_MASTER_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(master_matrix)
162# define TRANSACTIONS_MASTER_MATRIX_REGISTRATIONS [PUT_MASTER_MATRIX] = trans_initiator2target_initializer(mmatrix.matrix), 162# define TRANSACTIONS_MASTER_MATRIX_REGISTRATIONS [PUT_MASTER_MATRIX] = trans_initiator2target_initializer(mmatrix.matrix),
163 163
164#else // SPLIT_TRANSPORT_MIRROR 164#else // SPLIT_TRANSPORT_MIRROR
@@ -235,8 +235,8 @@ static void sync_timer_handlers_slave(matrix_row_t master_matrix[], matrix_row_t
235 } 235 }
236} 236}
237 237
238# define TRANSACTIONS_SYNC_TIMER_MASTER() TRANSACTION_HANDLER_MASTER(sync_timer) 238# define TRANSACTIONS_SYNC_TIMER_MASTER() TRANSACTION_HANDLER_MASTER(sync_timer)
239# define TRANSACTIONS_SYNC_TIMER_SLAVE() TRANSACTION_HANDLER_SLAVE(sync_timer) 239# define TRANSACTIONS_SYNC_TIMER_SLAVE() TRANSACTION_HANDLER_SLAVE(sync_timer)
240# define TRANSACTIONS_SYNC_TIMER_REGISTRATIONS [PUT_SYNC_TIMER] = trans_initiator2target_initializer(sync_timer), 240# define TRANSACTIONS_SYNC_TIMER_REGISTRATIONS [PUT_SYNC_TIMER] = trans_initiator2target_initializer(sync_timer),
241 241
242#else // DISABLE_SYNC_TIMER 242#else // DISABLE_SYNC_TIMER
@@ -300,8 +300,8 @@ static void led_state_handlers_slave(matrix_row_t master_matrix[], matrix_row_t
300 set_split_host_keyboard_leds(split_shmem->led_state); 300 set_split_host_keyboard_leds(split_shmem->led_state);
301} 301}
302 302
303# define TRANSACTIONS_LED_STATE_MASTER() TRANSACTION_HANDLER_MASTER(led_state) 303# define TRANSACTIONS_LED_STATE_MASTER() TRANSACTION_HANDLER_MASTER(led_state)
304# define TRANSACTIONS_LED_STATE_SLAVE() TRANSACTION_HANDLER_SLAVE(led_state) 304# define TRANSACTIONS_LED_STATE_SLAVE() TRANSACTION_HANDLER_SLAVE(led_state)
305# define TRANSACTIONS_LED_STATE_REGISTRATIONS [PUT_LED_STATE] = trans_initiator2target_initializer(led_state), 305# define TRANSACTIONS_LED_STATE_REGISTRATIONS [PUT_LED_STATE] = trans_initiator2target_initializer(led_state),
306 306
307#else // SPLIT_LED_STATE_ENABLE 307#else // SPLIT_LED_STATE_ENABLE
@@ -357,8 +357,8 @@ static void mods_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave
357# endif 357# endif
358} 358}
359 359
360# define TRANSACTIONS_MODS_MASTER() TRANSACTION_HANDLER_MASTER(mods) 360# define TRANSACTIONS_MODS_MASTER() TRANSACTION_HANDLER_MASTER(mods)
361# define TRANSACTIONS_MODS_SLAVE() TRANSACTION_HANDLER_SLAVE(mods) 361# define TRANSACTIONS_MODS_SLAVE() TRANSACTION_HANDLER_SLAVE(mods)
362# define TRANSACTIONS_MODS_REGISTRATIONS [PUT_MODS] = trans_initiator2target_initializer(mods), 362# define TRANSACTIONS_MODS_REGISTRATIONS [PUT_MODS] = trans_initiator2target_initializer(mods),
363 363
364#else // SPLIT_MODS_ENABLE 364#else // SPLIT_MODS_ENABLE
@@ -382,8 +382,8 @@ static bool backlight_handlers_master(matrix_row_t master_matrix[], matrix_row_t
382 382
383static void backlight_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { backlight_set(split_shmem->backlight_level); } 383static void backlight_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { backlight_set(split_shmem->backlight_level); }
384 384
385# define TRANSACTIONS_BACKLIGHT_MASTER() TRANSACTION_HANDLER_MASTER(backlight) 385# define TRANSACTIONS_BACKLIGHT_MASTER() TRANSACTION_HANDLER_MASTER(backlight)
386# define TRANSACTIONS_BACKLIGHT_SLAVE() TRANSACTION_HANDLER_SLAVE(backlight) 386# define TRANSACTIONS_BACKLIGHT_SLAVE() TRANSACTION_HANDLER_SLAVE(backlight)
387# define TRANSACTIONS_BACKLIGHT_REGISTRATIONS [PUT_BACKLIGHT] = trans_initiator2target_initializer(backlight_level), 387# define TRANSACTIONS_BACKLIGHT_REGISTRATIONS [PUT_BACKLIGHT] = trans_initiator2target_initializer(backlight_level),
388 388
389#else // BACKLIGHT_ENABLE 389#else // BACKLIGHT_ENABLE
@@ -419,8 +419,8 @@ static void rgblight_handlers_slave(matrix_row_t master_matrix[], matrix_row_t s
419 } 419 }
420} 420}
421 421
422# define TRANSACTIONS_RGBLIGHT_MASTER() TRANSACTION_HANDLER_MASTER(rgblight) 422# define TRANSACTIONS_RGBLIGHT_MASTER() TRANSACTION_HANDLER_MASTER(rgblight)
423# define TRANSACTIONS_RGBLIGHT_SLAVE() TRANSACTION_HANDLER_SLAVE(rgblight) 423# define TRANSACTIONS_RGBLIGHT_SLAVE() TRANSACTION_HANDLER_SLAVE(rgblight)
424# define TRANSACTIONS_RGBLIGHT_REGISTRATIONS [PUT_RGBLIGHT] = trans_initiator2target_initializer(rgblight_sync), 424# define TRANSACTIONS_RGBLIGHT_REGISTRATIONS [PUT_RGBLIGHT] = trans_initiator2target_initializer(rgblight_sync),
425 425
426#else // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) 426#else // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
@@ -449,8 +449,8 @@ static void led_matrix_handlers_slave(matrix_row_t master_matrix[], matrix_row_t
449 led_matrix_set_suspend_state(split_shmem->led_matrix_sync.led_suspend_state); 449 led_matrix_set_suspend_state(split_shmem->led_matrix_sync.led_suspend_state);
450} 450}
451 451
452# define TRANSACTIONS_LED_MATRIX_MASTER() TRANSACTION_HANDLER_MASTER(led_matrix) 452# define TRANSACTIONS_LED_MATRIX_MASTER() TRANSACTION_HANDLER_MASTER(led_matrix)
453# define TRANSACTIONS_LED_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(led_matrix) 453# define TRANSACTIONS_LED_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(led_matrix)
454# define TRANSACTIONS_LED_MATRIX_REGISTRATIONS [PUT_LED_MATRIX] = trans_initiator2target_initializer(led_matrix_sync), 454# define TRANSACTIONS_LED_MATRIX_REGISTRATIONS [PUT_LED_MATRIX] = trans_initiator2target_initializer(led_matrix_sync),
455 455
456#else // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) 456#else // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
@@ -479,8 +479,8 @@ static void rgb_matrix_handlers_slave(matrix_row_t master_matrix[], matrix_row_t
479 rgb_matrix_set_suspend_state(split_shmem->rgb_matrix_sync.rgb_suspend_state); 479 rgb_matrix_set_suspend_state(split_shmem->rgb_matrix_sync.rgb_suspend_state);
480} 480}
481 481
482# define TRANSACTIONS_RGB_MATRIX_MASTER() TRANSACTION_HANDLER_MASTER(rgb_matrix) 482# define TRANSACTIONS_RGB_MATRIX_MASTER() TRANSACTION_HANDLER_MASTER(rgb_matrix)
483# define TRANSACTIONS_RGB_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(rgb_matrix) 483# define TRANSACTIONS_RGB_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(rgb_matrix)
484# define TRANSACTIONS_RGB_MATRIX_REGISTRATIONS [PUT_RGB_MATRIX] = trans_initiator2target_initializer(rgb_matrix_sync), 484# define TRANSACTIONS_RGB_MATRIX_REGISTRATIONS [PUT_RGB_MATRIX] = trans_initiator2target_initializer(rgb_matrix_sync),
485 485
486#else // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) 486#else // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
@@ -504,8 +504,8 @@ static bool wpm_handlers_master(matrix_row_t master_matrix[], matrix_row_t slave
504 504
505static void wpm_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { set_current_wpm(split_shmem->current_wpm); } 505static void wpm_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { set_current_wpm(split_shmem->current_wpm); }
506 506
507# define TRANSACTIONS_WPM_MASTER() TRANSACTION_HANDLER_MASTER(wpm) 507# define TRANSACTIONS_WPM_MASTER() TRANSACTION_HANDLER_MASTER(wpm)
508# define TRANSACTIONS_WPM_SLAVE() TRANSACTION_HANDLER_SLAVE(wpm) 508# define TRANSACTIONS_WPM_SLAVE() TRANSACTION_HANDLER_SLAVE(wpm)
509# define TRANSACTIONS_WPM_REGISTRATIONS [PUT_WPM] = trans_initiator2target_initializer(current_wpm), 509# define TRANSACTIONS_WPM_REGISTRATIONS [PUT_WPM] = trans_initiator2target_initializer(current_wpm),
510 510
511#else // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) 511#else // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE)
@@ -535,8 +535,8 @@ static void oled_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave
535 } 535 }
536} 536}
537 537
538# define TRANSACTIONS_OLED_MASTER() TRANSACTION_HANDLER_MASTER(oled) 538# define TRANSACTIONS_OLED_MASTER() TRANSACTION_HANDLER_MASTER(oled)
539# define TRANSACTIONS_OLED_SLAVE() TRANSACTION_HANDLER_SLAVE(oled) 539# define TRANSACTIONS_OLED_SLAVE() TRANSACTION_HANDLER_SLAVE(oled)
540# define TRANSACTIONS_OLED_REGISTRATIONS [PUT_OLED] = trans_initiator2target_initializer(current_oled_state), 540# define TRANSACTIONS_OLED_REGISTRATIONS [PUT_OLED] = trans_initiator2target_initializer(current_oled_state),
541 541
542#else // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) 542#else // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE)
@@ -566,8 +566,8 @@ static void st7565_handlers_slave(matrix_row_t master_matrix[], matrix_row_t sla
566 } 566 }
567} 567}
568 568
569# define TRANSACTIONS_ST7565_MASTER() TRANSACTION_HANDLER_MASTER(st7565) 569# define TRANSACTIONS_ST7565_MASTER() TRANSACTION_HANDLER_MASTER(st7565)
570# define TRANSACTIONS_ST7565_SLAVE() TRANSACTION_HANDLER_SLAVE(st7565) 570# define TRANSACTIONS_ST7565_SLAVE() TRANSACTION_HANDLER_SLAVE(st7565)
571# define TRANSACTIONS_ST7565_REGISTRATIONS [PUT_ST7565] = trans_initiator2target_initializer(current_st7565_state), 571# define TRANSACTIONS_ST7565_REGISTRATIONS [PUT_ST7565] = trans_initiator2target_initializer(current_st7565_state),
572 572
573#else // defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE) 573#else // defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE)
diff --git a/tmk_core/common/chibios/sleep_led.c b/tmk_core/common/chibios/sleep_led.c
index 1c65016a4..477056a45 100644
--- a/tmk_core/common/chibios/sleep_led.c
+++ b/tmk_core/common/chibios/sleep_led.c
@@ -65,7 +65,7 @@ void sleep_led_timer_callback(void) {
65 65
66/* LPTMR clock options */ 66/* LPTMR clock options */
67# define LPTMR_CLOCK_MCGIRCLK 0 /* 4MHz clock */ 67# define LPTMR_CLOCK_MCGIRCLK 0 /* 4MHz clock */
68# define LPTMR_CLOCK_LPO 1 /* 1kHz clock */ 68# define LPTMR_CLOCK_LPO 1 /* 1kHz clock */
69# define LPTMR_CLOCK_ERCLK32K 2 /* external 32kHz crystal */ 69# define LPTMR_CLOCK_ERCLK32K 2 /* external 32kHz crystal */
70# define LPTMR_CLOCK_OSCERCLK 3 /* output from OSC */ 70# define LPTMR_CLOCK_OSCERCLK 3 /* output from OSC */
71 71
@@ -121,7 +121,7 @@ void sleep_led_init(void) {
121 MCG->C2 |= MCG_C2_IRCS; // fast (4MHz) internal ref clock 121 MCG->C2 |= MCG_C2_IRCS; // fast (4MHz) internal ref clock
122# if defined(KL27) // divide the 8MHz IRC by 2, to have the same MCGIRCLK speed as others 122# if defined(KL27) // divide the 8MHz IRC by 2, to have the same MCGIRCLK speed as others
123 MCG->MC |= MCG_MC_LIRC_DIV2_DIV2; 123 MCG->MC |= MCG_MC_LIRC_DIV2_DIV2;
124# endif /* KL27 */ 124# endif /* KL27 */
125 MCG->C1 |= MCG_C1_IRCLKEN; // enable internal ref clock 125 MCG->C1 |= MCG_C1_IRCLKEN; // enable internal ref clock
126 // to work in stop mode, also MCG_C1_IREFSTEN 126 // to work in stop mode, also MCG_C1_IREFSTEN
127 // Divide 4MHz by 2^N (N=6) => 62500 irqs/sec => 127 // Divide 4MHz by 2^N (N=6) => 62500 irqs/sec =>
diff --git a/tmk_core/common/report.c b/tmk_core/common/report.c
index 2a7fc006c..854b59ae4 100644
--- a/tmk_core/common/report.c
+++ b/tmk_core/common/report.c
@@ -24,8 +24,8 @@
24#ifdef RING_BUFFERED_6KRO_REPORT_ENABLE 24#ifdef RING_BUFFERED_6KRO_REPORT_ENABLE
25# define RO_ADD(a, b) ((a + b) % KEYBOARD_REPORT_KEYS) 25# define RO_ADD(a, b) ((a + b) % KEYBOARD_REPORT_KEYS)
26# define RO_SUB(a, b) ((a - b + KEYBOARD_REPORT_KEYS) % KEYBOARD_REPORT_KEYS) 26# define RO_SUB(a, b) ((a - b + KEYBOARD_REPORT_KEYS) % KEYBOARD_REPORT_KEYS)
27# define RO_INC(a) RO_ADD(a, 1) 27# define RO_INC(a) RO_ADD(a, 1)
28# define RO_DEC(a) RO_SUB(a, 1) 28# define RO_DEC(a) RO_SUB(a, 1)
29static int8_t cb_head = 0; 29static int8_t cb_head = 0;
30static int8_t cb_tail = 0; 30static int8_t cb_tail = 0;
31static int8_t cb_count = 0; 31static int8_t cb_count = 0;
diff --git a/tmk_core/protocol/ps2_mouse.c b/tmk_core/protocol/ps2_mouse.c
index 39251a643..43c88084d 100644
--- a/tmk_core/protocol/ps2_mouse.c
+++ b/tmk_core/protocol/ps2_mouse.c
@@ -158,8 +158,8 @@ static inline void ps2_mouse_convert_report_to_hid(report_mouse_t *mouse_report)
158 158
159#ifdef PS2_MOUSE_INVERT_BUTTONS 159#ifdef PS2_MOUSE_INVERT_BUTTONS
160 // swap left & right buttons 160 // swap left & right buttons
161 uint8_t needs_left = mouse_report->buttons & PS2_MOUSE_BTN_RIGHT; 161 uint8_t needs_left = mouse_report->buttons & PS2_MOUSE_BTN_RIGHT;
162 uint8_t needs_right = mouse_report->buttons & PS2_MOUSE_BTN_LEFT; 162 uint8_t needs_right = mouse_report->buttons & PS2_MOUSE_BTN_LEFT;
163 mouse_report->buttons = (mouse_report->buttons & ~(PS2_MOUSE_BTN_MASK)) | (needs_left ? PS2_MOUSE_BTN_LEFT : 0) | (needs_right ? PS2_MOUSE_BTN_RIGHT : 0); 163 mouse_report->buttons = (mouse_report->buttons & ~(PS2_MOUSE_BTN_MASK)) | (needs_left ? PS2_MOUSE_BTN_LEFT : 0) | (needs_right ? PS2_MOUSE_BTN_RIGHT : 0);
164#else 164#else
165 // remove sign and overflow flags 165 // remove sign and overflow flags