aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/keyboard.c16
-rw-r--r--common/keyboard.h8
2 files changed, 10 insertions, 14 deletions
diff --git a/common/keyboard.c b/common/keyboard.c
index 6677e8011..1aff81f54 100644
--- a/common/keyboard.c
+++ b/common/keyboard.c
@@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
26#include "command.h" 26#include "command.h"
27#include "util.h" 27#include "util.h"
28#include "sendchar.h" 28#include "sendchar.h"
29#include "bootloader.h"
29#ifdef MOUSEKEY_ENABLE 30#ifdef MOUSEKEY_ENABLE
30#include "mousekey.h" 31#include "mousekey.h"
31#endif 32#endif
@@ -68,21 +69,21 @@ void keyboard_task(void)
68 matrix_row_t matrix_change = 0; 69 matrix_row_t matrix_change = 0;
69 70
70 matrix_scan(); 71 matrix_scan();
71 for (int r = 0; r < MATRIX_ROWS; r++) { 72 for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
72 matrix_row = matrix_get_row(r); 73 matrix_row = matrix_get_row(r);
73 matrix_change = matrix_row ^ matrix_prev[r]; 74 matrix_change = matrix_row ^ matrix_prev[r];
74 if (matrix_change) { 75 if (matrix_change) {
75 if (debug_matrix) matrix_print(); 76 if (debug_matrix) matrix_print();
76 77
77 for (int c = 0; c < MATRIX_COLS; c++) { 78 for (uint8_t c = 0; c < MATRIX_COLS; c++) {
78 if (matrix_change & (1<<c)) { 79 if (matrix_change & ((matrix_row_t)1<<c)) {
79 action_exec((keyevent_t){ 80 action_exec((keyevent_t){
80 .key.pos = (keypos_t){ .row = r, .col = c }, 81 .key.pos = (keypos_t){ .row = r, .col = c },
81 .pressed = (matrix_row & (1<<c)), 82 .pressed = (matrix_row & (1<<c)),
82 .time = (timer_read() | 1) /* NOTE: 0 means no event */ 83 .time = (timer_read() | 1) /* NOTE: 0 means no event */
83 }); 84 });
84 // record a processed key 85 // record a processed key
85 matrix_prev[r] ^= (1<<c); 86 matrix_prev[r] ^= ((matrix_row_t)1<<c);
86 // process a key per task call 87 // process a key per task call
87 goto MATRIX_LOOP_END; 88 goto MATRIX_LOOP_END;
88 } 89 }
@@ -90,12 +91,7 @@ void keyboard_task(void)
90 } 91 }
91 } 92 }
92 // call with not real event to update state of aciton 93 // call with not real event to update state of aciton
93 // TODO: use NOEVENT macro 94 action_exec(NOEVENT);
94 action_exec((keyevent_t) {
95 .key.pos = (keypos_t){ .row = 255, .col = 255 }, // assume this key doesn't exist
96 .pressed = false,
97 .time = 0,
98 });
99 95
100MATRIX_LOOP_END: 96MATRIX_LOOP_END:
101 97
diff --git a/common/keyboard.h b/common/keyboard.h
index 6d06c95bb..84f03c9a6 100644
--- a/common/keyboard.h
+++ b/common/keyboard.h
@@ -44,10 +44,10 @@ typedef struct {
44 44
45#define KEYEQ(keya, keyb) (keya.raw == keyb.raw) 45#define KEYEQ(keya, keyb) (keya.raw == keyb.raw)
46#define IS_NOEVENT(event) (event.time == 0) 46#define IS_NOEVENT(event) (event.time == 0)
47#define NOEVENT (keyevent_t){ \ 47#define NOEVENT (keyevent_t){ \
48 .key = (keypos_t){ .row = 255, .col = 255 }, \ 48 .key.pos = (keypos_t){ .row = 255, .col = 255 }, \
49 .pressed = false, \ 49 .pressed = false, \
50 .time = 0 \ 50 .time = 0 \
51} 51}
52 52
53 53