refactor: key handling (#4849)
This commit is contained in:
@@ -1657,11 +1657,11 @@ Stops key state machine. See [Key Events](../key_events.md) for the detailed des
|
||||
*/
|
||||
static int luaKillEvents(lua_State * L)
|
||||
{
|
||||
#if defined(KEYS_GPIO_REG_PAGE)
|
||||
#if defined(KEYS_GPIO_REG_MENU)
|
||||
#define IS_MASKABLE(key) \
|
||||
((key) != KEY_EXIT && (key) != KEY_ENTER && \
|
||||
((scriptInternalData[0].reference == SCRIPT_STANDALONE) || \
|
||||
(key) != KEY_PAGE))
|
||||
(key) != KEY_PAGEDN))
|
||||
#else
|
||||
#define IS_MASKABLE(key) ((key) != KEY_EXIT && (key) != KEY_ENTER)
|
||||
#endif
|
||||
|
||||
@@ -1191,7 +1191,6 @@ static bool resumeLua(bool init, bool allowLcdUsage)
|
||||
|
||||
if (scriptResult != 0) {
|
||||
TRACE("Script finished with status %d", scriptResult);
|
||||
killAllEvents();
|
||||
luaState = INTERPRETER_RELOAD_PERMANENT_SCRIPTS;
|
||||
}
|
||||
else if (luaDisplayStatistics) {
|
||||
@@ -1221,14 +1220,12 @@ static bool resumeLua(bool init, bool allowLcdUsage)
|
||||
|
||||
if (evt.event == EVT_KEY_LONG(KEY_EXIT)) {
|
||||
TRACE("Script force exit");
|
||||
// killEvents(evt);
|
||||
luaEmptyEventBuffer();
|
||||
luaState = INTERPRETER_RELOAD_PERMANENT_SCRIPTS;
|
||||
}
|
||||
#if defined(KEYS_GPIO_REG_MENU)
|
||||
// TODO find another key and add a #define
|
||||
else if (evt.event == EVT_KEY_LONG(KEY_MENU)) {
|
||||
killEvents(evt.event);
|
||||
luaEmptyEventBuffer();
|
||||
luaDisplayStatistics = !luaDisplayStatistics;
|
||||
}
|
||||
|
||||
@@ -166,14 +166,6 @@ void LuaEventHandler::onCancel() { luaPushEvent(EVT_KEY_BREAK(KEY_EXIT)); }
|
||||
|
||||
void LuaEventHandler::onEvent(event_t event)
|
||||
{
|
||||
if (event == EVT_KEY_LONG(KEY_EXIT)) {
|
||||
killEvents(KEY_EXIT);
|
||||
}
|
||||
#if !defined(KEYS_GPIO_REG_PAGEUP) && !defined(USE_HATS_AS_KEYS)
|
||||
else if (event == EVT_KEY_LONG(KEY_PAGEDN)) {
|
||||
killEvents(KEY_PAGEDN);
|
||||
}
|
||||
#endif
|
||||
luaPushEvent(event);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user