From ee7ce433357a1c1bbcaba54525fc5b5b5404aa82 Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 17 Jan 2013 15:00:41 +0900 Subject: Refactor struct keyevent_t. --- common/keyboard.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'common/keyboard.h') diff --git a/common/keyboard.h b/common/keyboard.h index 907ee1f97e..4518cdddc3 100644 --- a/common/keyboard.h +++ b/common/keyboard.h @@ -26,19 +26,23 @@ along with this program. If not, see . extern "C" { #endif -// TODO: union {raw = row:col} typedef struct { - uint8_t row; uint8_t col; + uint8_t row; } keypos_t; +typedef union { + uint16_t raw; + keypos_t pos; +} key_t; + typedef struct { - keypos_t key; + key_t key; bool pressed; uint16_t time; } keyevent_t; -#define KEYEQ(keya, keyb) (keya.row == keyb.row && keya.col == keyb.col) +#define KEYEQ(keya, keyb) (keya.raw == keyb.raw) #define IS_NOEVENT(event) (event.time == 0) #define NOEVENT (keyevent_t) { \ .key = (keypos_t){ .row = 255, .col = 255 }, \ -- cgit v1.2.3