diff options
| author | Fred Sundvik <fsundvik@gmail.com> | 2017-09-30 11:58:09 +0300 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2017-09-30 06:22:02 -1000 |
| commit | 25285a1c5a634c6bb2c1a7b4ef4dc5d44ac1aea2 (patch) | |
| tree | 1af6918578361f2e0e35857c0c35281d08585f9e /tmk_core/common/keyboard.c | |
| parent | f1451b4b04bad7d618bbc7fe3517ab736f819d86 (diff) | |
| download | qmk_firmware-25285a1c5a634c6bb2c1a7b4ef4dc5d44ac1aea2.tar.gz qmk_firmware-25285a1c5a634c6bb2c1a7b4ef4dc5d44ac1aea2.zip | |
Don't process keycodes on the slave
Diffstat (limited to 'tmk_core/common/keyboard.c')
| -rw-r--r-- | tmk_core/common/keyboard.c | 63 |
1 files changed, 35 insertions, 28 deletions
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 9466e10e2..1b7c8c1a2 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c | |||
| @@ -119,6 +119,11 @@ void keyboard_setup(void) { | |||
| 119 | matrix_setup(); | 119 | matrix_setup(); |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | __attribute__((weak)) | ||
| 123 | bool is_keyboard_master(void) { | ||
| 124 | return true; | ||
| 125 | } | ||
| 126 | |||
| 122 | void keyboard_init(void) { | 127 | void keyboard_init(void) { |
| 123 | timer_init(); | 128 | timer_init(); |
| 124 | matrix_init(); | 129 | matrix_init(); |
| @@ -168,36 +173,38 @@ void keyboard_task(void) | |||
| 168 | matrix_row_t matrix_change = 0; | 173 | matrix_row_t matrix_change = 0; |
| 169 | 174 | ||
| 170 | matrix_scan(); | 175 | matrix_scan(); |
| 171 | for (uint8_t r = 0; r < MATRIX_ROWS; r++) { | 176 | if (is_keyboard_master()) { |
| 172 | matrix_row = matrix_get_row(r); | 177 | for (uint8_t r = 0; r < MATRIX_ROWS; r++) { |
| 173 | matrix_change = matrix_row ^ matrix_prev[r]; | 178 | matrix_row = matrix_get_row(r); |
| 174 | if (matrix_change) { | 179 | matrix_change = matrix_row ^ matrix_prev[r]; |
| 180 | if (matrix_change) { | ||
| 175 | #ifdef MATRIX_HAS_GHOST | 181 | #ifdef MATRIX_HAS_GHOST |
| 176 | if (has_ghost_in_row(r, matrix_row)) { | 182 | if (has_ghost_in_row(r, matrix_row)) { |
| 177 | /* Keep track of whether ghosted status has changed for | 183 | /* Keep track of whether ghosted status has changed for |
| 178 | * debugging. But don't update matrix_prev until un-ghosted, or | 184 | * debugging. But don't update matrix_prev until un-ghosted, or |
| 179 | * the last key would be lost. | 185 | * the last key would be lost. |
| 180 | */ | 186 | */ |
| 181 | //if (debug_matrix && matrix_ghost[r] != matrix_row) { | 187 | //if (debug_matrix && matrix_ghost[r] != matrix_row) { |
| 182 | // matrix_print(); | 188 | // matrix_print(); |
| 183 | //} | 189 | //} |
| 190 | //matrix_ghost[r] = matrix_row; | ||
| 191 | continue; | ||
| 192 | } | ||
| 184 | //matrix_ghost[r] = matrix_row; | 193 | //matrix_ghost[r] = matrix_row; |
| 185 | continue; | 194 | #endif |
| 186 | } | 195 | if (debug_matrix) matrix_print(); |
| 187 | //matrix_ghost[r] = matrix_row; | 196 | for (uint8_t c = 0; c < MATRIX_COLS; c++) { |
| 188 | #endif | 197 | if (matrix_change & ((matrix_row_t)1<<c)) { |
| 189 | if (debug_matrix) matrix_print(); | 198 | action_exec((keyevent_t){ |
| 190 | for (uint8_t c = 0; c < MATRIX_COLS; c++) { | 199 | .key = (keypos_t){ .row = r, .col = c }, |
| 191 | if (matrix_change & ((matrix_row_t)1<<c)) { | 200 | .pressed = (matrix_row & ((matrix_row_t)1<<c)), |
| 192 | action_exec((keyevent_t){ | 201 | .time = (timer_read() | 1) /* time should not be 0 */ |
| 193 | .key = (keypos_t){ .row = r, .col = c }, | 202 | }); |
| 194 | .pressed = (matrix_row & ((matrix_row_t)1<<c)), | 203 | // record a processed key |
| 195 | .time = (timer_read() | 1) /* time should not be 0 */ | 204 | matrix_prev[r] ^= ((matrix_row_t)1<<c); |
| 196 | }); | 205 | // process a key per task call |
| 197 | // record a processed key | 206 | goto MATRIX_LOOP_END; |
| 198 | matrix_prev[r] ^= ((matrix_row_t)1<<c); | 207 | } |
| 199 | // process a key per task call | ||
| 200 | goto MATRIX_LOOP_END; | ||
| 201 | } | 208 | } |
| 202 | } | 209 | } |
| 203 | } | 210 | } |
