Change struct key_t
This commit is contained in:
parent
c044a0841b
commit
448da5d477
@ -859,7 +859,7 @@ bool is_tap_key(key_t key)
|
|||||||
*/
|
*/
|
||||||
static void debug_event(keyevent_t event)
|
static void debug_event(keyevent_t event)
|
||||||
{
|
{
|
||||||
debug_hex16(event.key.raw);
|
debug_hex16((event.key.row<<8) | event.key.col);
|
||||||
if (event.pressed) debug("d("); else debug("u(");
|
if (event.pressed) debug("d("); else debug("u(");
|
||||||
debug_dec(event.time); debug(")");
|
debug_dec(event.time); debug(")");
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ void keyboard_task(void)
|
|||||||
for (uint8_t c = 0; c < MATRIX_COLS; c++) {
|
for (uint8_t c = 0; c < MATRIX_COLS; c++) {
|
||||||
if (matrix_change & ((matrix_row_t)1<<c)) {
|
if (matrix_change & ((matrix_row_t)1<<c)) {
|
||||||
action_exec((keyevent_t){
|
action_exec((keyevent_t){
|
||||||
.key.pos = (keypos_t){ .row = r, .col = c },
|
.key = (key_t){ .row = r, .col = c },
|
||||||
.pressed = (matrix_row & (1<<c)),
|
.pressed = (matrix_row & (1<<c)),
|
||||||
.time = (timer_read() | 1) /* time should not be 0 */
|
.time = (timer_read() | 1) /* time should not be 0 */
|
||||||
});
|
});
|
||||||
|
@ -30,12 +30,6 @@ extern "C" {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t col;
|
uint8_t col;
|
||||||
uint8_t row;
|
uint8_t row;
|
||||||
} keypos_t;
|
|
||||||
|
|
||||||
// TODO: need raw? keypos_t -> key_t?
|
|
||||||
typedef union {
|
|
||||||
uint16_t raw;
|
|
||||||
keypos_t pos;
|
|
||||||
} key_t;
|
} key_t;
|
||||||
|
|
||||||
/* key event */
|
/* key event */
|
||||||
@ -46,20 +40,20 @@ typedef struct {
|
|||||||
} keyevent_t;
|
} keyevent_t;
|
||||||
|
|
||||||
/* equivalent test of key_t */
|
/* equivalent test of key_t */
|
||||||
#define KEYEQ(keya, keyb) ((keya).raw == (keyb).raw)
|
#define KEYEQ(keya, keyb) ((keya).row == (keyb).row && (keya).col == (keyb).col)
|
||||||
|
|
||||||
/* (time == 0) means no event and assumes matrix has no 255 line. */
|
/* (time == 0) means no event and assumes matrix has no 255 line. */
|
||||||
#define IS_NOEVENT(event) ((event).time == 0 || ((event).key.pos.row == 255 && (event).key.pos.col == 255))
|
#define IS_NOEVENT(event) ((event).time == 0 || ((event).key.row == 255 && (event).key.col == 255))
|
||||||
|
|
||||||
#define NOEVENT (keyevent_t){ \
|
#define NOEVENT (keyevent_t){ \
|
||||||
.key.pos = (keypos_t){ .row = 255, .col = 255 }, \
|
.key = (key_t){ .row = 255, .col = 255 }, \
|
||||||
.pressed = false, \
|
.pressed = false, \
|
||||||
.time = 0 \
|
.time = 0 \
|
||||||
}
|
}
|
||||||
|
|
||||||
/* tick event */
|
/* tick event */
|
||||||
#define TICK (keyevent_t){ \
|
#define TICK (keyevent_t){ \
|
||||||
.key.pos = (keypos_t){ .row = 255, .col = 255 }, \
|
.key = (key_t){ .row = 255, .col = 255 }, \
|
||||||
.pressed = false, \
|
.pressed = false, \
|
||||||
.time = (timer_read() | 1) \
|
.time = (timer_read() | 1) \
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ __attribute__ ((weak))
|
|||||||
action_t action_for_key(uint8_t layer, key_t key)
|
action_t action_for_key(uint8_t layer, key_t key)
|
||||||
{
|
{
|
||||||
/* convert from legacy keycode to action */
|
/* convert from legacy keycode to action */
|
||||||
uint8_t keycode = keymap_get_keycode(layer, key.pos.row, key.pos.col);
|
uint8_t keycode = keymap_get_keycode(layer, key.row, key.col);
|
||||||
action_t action;
|
action_t action;
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case KC_FN0 ... KC_FN31:
|
case KC_FN0 ... KC_FN31:
|
||||||
|
Reference in New Issue
Block a user