1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-26 01:35:21 +03:00

Rotary encoder emulates PLUS and MINUS keys

This commit is contained in:
Damjan Adamic 2014-11-30 18:22:35 +01:00
parent b64d200c94
commit 9980d11740
10 changed files with 75 additions and 20 deletions

View file

@ -66,7 +66,7 @@ uint8_t getEvent()
#define KEY_LONG_DELAY 32
Key keys[NUM_KEYS];
void Key::input(bool val, EnumKeys enuk)
void Key::input(bool val)
{
uint8_t t_vals = m_vals ;
t_vals <<= 1 ;
@ -77,7 +77,7 @@ void Key::input(bool val, EnumKeys enuk)
if (m_state && m_vals==0) { //gerade eben sprung auf 0
if (m_state != KSTATE_KILLED) {
putEvent(EVT_KEY_BREAK(enuk));
putEvent(EVT_KEY_BREAK(key()));
}
m_cnt = 0;
m_state = KSTATE_OFF;
@ -91,7 +91,7 @@ void Key::input(bool val, EnumKeys enuk)
break;
//fallthrough
case KSTATE_START:
putEvent(EVT_KEY_FIRST(enuk));
putEvent(EVT_KEY_FIRST(key()));
inactivity.counter = 0;
m_state = KSTATE_RPTDELAY;
m_cnt = 0;
@ -99,7 +99,7 @@ void Key::input(bool val, EnumKeys enuk)
case KSTATE_RPTDELAY: // gruvin: delay state before first key repeat
if (m_cnt == KEY_LONG_DELAY) {
putEvent(EVT_KEY_LONG(enuk));
putEvent(EVT_KEY_LONG(key()));
}
if (m_cnt == 40) {
m_state = 16;
@ -118,7 +118,7 @@ void Key::input(bool val, EnumKeys enuk)
// no break
case 1:
if ((m_cnt & (m_state-1)) == 0) {
putEvent(EVT_KEY_REPT(enuk));
putEvent(EVT_KEY_REPT(key()));
}
break;
@ -134,6 +134,11 @@ void Key::input(bool val, EnumKeys enuk)
}
}
EnumKeys Key::key() const
{
return static_cast<EnumKeys>(this - keys);
}
void pauseEvents(uint8_t event)
{
event = EVT_KEY_MASK(event);