diff options
| author | tmk <nobody@nowhere> | 2013-01-17 15:00:41 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2013-01-17 15:02:34 +0900 |
| commit | ee7ce433357a1c1bbcaba54525fc5b5b5404aa82 (patch) | |
| tree | 287fd6ef79a45680bcdb5ebf98524d9d1428e087 /common/keyboard.h | |
| parent | 567b2ae5259634a5293afbc6a710a19d7c45dcda (diff) | |
| download | qmk_firmware-ee7ce433357a1c1bbcaba54525fc5b5b5404aa82.tar.gz qmk_firmware-ee7ce433357a1c1bbcaba54525fc5b5b5404aa82.zip | |
Refactor struct keyevent_t.
Diffstat (limited to 'common/keyboard.h')
| -rw-r--r-- | common/keyboard.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/common/keyboard.h b/common/keyboard.h index 907ee1f97..4518cdddc 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/>. | |||
| 26 | extern "C" { | 26 | extern "C" { |
| 27 | #endif | 27 | #endif |
| 28 | 28 | ||
| 29 | // TODO: union {raw = row:col} | ||
| 30 | typedef struct { | 29 | typedef struct { |
| 31 | uint8_t row; | ||
| 32 | uint8_t col; | 30 | uint8_t col; |
| 31 | uint8_t row; | ||
| 33 | } keypos_t; | 32 | } keypos_t; |
| 34 | 33 | ||
| 34 | typedef union { | ||
| 35 | uint16_t raw; | ||
| 36 | keypos_t pos; | ||
| 37 | } key_t; | ||
| 38 | |||
| 35 | typedef struct { | 39 | typedef struct { |
| 36 | keypos_t key; | 40 | key_t key; |
| 37 | bool pressed; | 41 | bool pressed; |
| 38 | uint16_t time; | 42 | uint16_t time; |
| 39 | } keyevent_t; | 43 | } keyevent_t; |
| 40 | 44 | ||
| 41 | #define KEYEQ(keya, keyb) (keya.row == keyb.row && keya.col == keyb.col) | 45 | #define KEYEQ(keya, keyb) (keya.raw == keyb.raw) |
| 42 | #define IS_NOEVENT(event) (event.time == 0) | 46 | #define IS_NOEVENT(event) (event.time == 0) |
| 43 | #define NOEVENT (keyevent_t) { \ | 47 | #define NOEVENT (keyevent_t) { \ |
| 44 | .key = (keypos_t){ .row = 255, .col = 255 }, \ | 48 | .key = (keypos_t){ .row = 255, .col = 255 }, \ |
