summaryrefslogtreecommitdiff
path: root/common/keyboard.h
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-01-17 15:00:41 +0900
committertmk <nobody@nowhere>2013-01-17 15:02:34 +0900
commitee7ce433357a1c1bbcaba54525fc5b5b5404aa82 (patch)
tree287fd6ef79a45680bcdb5ebf98524d9d1428e087 /common/keyboard.h
parent567b2ae5259634a5293afbc6a710a19d7c45dcda (diff)
Refactor struct keyevent_t.
Diffstat (limited to 'common/keyboard.h')
-rw-r--r--common/keyboard.h12
1 files changed, 8 insertions, 4 deletions
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 <http://www.gnu.org/licenses/>.
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 }, \