5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
27 #define EVT_KEY_MASK(e) ((e) & 0x1f)
30 #define _MSK_KEY_BREAK 0x0200
31 #define _MSK_KEY_REPT 0x0400
32 #define _MSK_KEY_FIRST 0x0600
33 #define _MSK_KEY_LONG 0x0800
34 #define _MSK_KEY_FLAGS 0x0e00
35 #define EVT_ENTRY 0x1000
36 #define EVT_ENTRY_UP 0x2000
38 #define _MSK_KEY_BREAK 0x20
39 #define _MSK_KEY_REPT 0x40
40 #define _MSK_KEY_FIRST 0x60
41 #define _MSK_KEY_LONG 0x80
42 #define _MSK_KEY_FLAGS 0xe0
43 #define EVT_ENTRY 0xbf
44 #define EVT_ENTRY_UP 0xbe
47 // normal order of events is: FIRST, LONG, REPEAT, REPEAT, ..., BREAK
48 #define EVT_KEY_FIRST(key) ((key)|_MSK_KEY_FIRST) // fired when key is pressed
49 #define EVT_KEY_LONG(key) ((key)|_MSK_KEY_LONG) // fired when key is held pressed for a while
50 #define EVT_KEY_REPT(key) ((key)|_MSK_KEY_REPT) // fired when key is held pressed long enough, fires multiple times with increasing speed
51 #define EVT_KEY_BREAK(key) ((key)|_MSK_KEY_BREAK) // fired when key is released (short or long), but only if the event was not killed
53 #define IS_KEY_FIRST(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_FIRST)
54 #define IS_KEY_LONG(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_LONG)
55 #define IS_KEY_REPT(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_REPT)
56 #define IS_KEY_BREAK(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_BREAK)
59 #define EVT_ROTARY_BREAK EVT_KEY_BREAK(KEY_ENTER)
60 #define EVT_ROTARY_LONG EVT_KEY_LONG(KEY_ENTER)
61 #define EVT_ROTARY_LEFT 0xDF00
62 #define EVT_ROTARY_RIGHT 0xDE00
63 #define IS_NEXT_EVENT(event) (event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_REPT(KEY_DOWN))
64 #define IS_PREVIOUS_EVENT(event) (event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_UP))
65 #elif (defined(PCBHORUS) || defined(PCBTARANIS)) && defined(ROTARY_ENCODER_NAVIGATION)
66 #define EVT_ROTARY_BREAK EVT_KEY_BREAK(KEY_ENTER)
67 #define EVT_ROTARY_LONG EVT_KEY_LONG(KEY_ENTER)
68 #define EVT_ROTARY_LEFT 0xDF00
69 #define EVT_ROTARY_RIGHT 0xDE00
70 #define IS_NEXT_EVENT(event) (event==EVT_ROTARY_RIGHT)
71 #define IS_PREVIOUS_EVENT(event) (event==EVT_ROTARY_LEFT)
72 #elif defined(ROTARY_ENCODER_NAVIGATION)
73 #define EVT_ROTARY_BREAK 0xcf
74 #define EVT_ROTARY_LONG 0xce
75 #define EVT_ROTARY_LEFT 0xdf
76 #define EVT_ROTARY_RIGHT 0xde
77 #define IS_NEXT_EVENT(event) (event==EVT_ROTARY_RIGHT || event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_REPT(KEY_DOWN))
78 #define IS_PREVIOUS_EVENT(event) (event==EVT_ROTARY_LEFT || event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_UP))
80 #define IS_NEXT_EVENT(event) (event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_REPT(KEY_DOWN))
81 #define IS_PREVIOUS_EVENT(event) (event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_UP))
85 #define EVT_REFRESH 0xDD00
96 bool state() const { return m_vals
> 0; }
102 extern Key keys
[NUM_KEYS
];
103 extern event_t s_evt
;
105 inline void putEvent(event_t evt
)
110 void pauseEvents(event_t event
);
111 void killEvents(event_t event
);
112 void killAllEvents();
113 bool waitKeysReleased();
114 event_t
getEvent(bool trim
=false);