fix(color): allow long press of RTN key to also exit setup pages (#6036)
This commit is contained in:
@@ -117,6 +117,10 @@ void Page::enableRefresh()
|
|||||||
lv_obj_refresh_style(lvobj, LV_PART_ANY, LV_STYLE_PROP_ANY);
|
lv_obj_refresh_style(lvobj, LV_PART_ANY, LV_STYLE_PROP_ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(HARDWARE_KEYS)
|
||||||
|
void Page::onLongPressRTN() { onCancel(); }
|
||||||
|
#endif
|
||||||
|
|
||||||
SubPage::SubPage(EdgeTxIcon icon, const char* title, const char* subtitle, bool pauseRefresh) :
|
SubPage::SubPage(EdgeTxIcon icon, const char* title, const char* subtitle, bool pauseRefresh) :
|
||||||
Page(icon, PAD_SMALL, pauseRefresh)
|
Page(icon, PAD_SMALL, pauseRefresh)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -66,6 +66,10 @@ class Page : public NavWindow
|
|||||||
|
|
||||||
void checkEvents() override;
|
void checkEvents() override;
|
||||||
bool bubbleEvents() override { return false; }
|
bool bubbleEvents() override { return false; }
|
||||||
|
|
||||||
|
#if defined(HARDWARE_KEYS)
|
||||||
|
void onLongPressRTN() override;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
class SubPage : public Page
|
class SubPage : public Page
|
||||||
|
|||||||
@@ -363,6 +363,7 @@ void TabsGroup::checkEvents()
|
|||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void TabsGroup::onPressPGUP() { header->prevTab(); }
|
void TabsGroup::onPressPGUP() { header->prevTab(); }
|
||||||
void TabsGroup::onPressPGDN() { header->nextTab(); }
|
void TabsGroup::onPressPGDN() { header->nextTab(); }
|
||||||
|
void TabsGroup::onLongPressRTN() { onCancel(); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void TabsGroup::onClicked() { Keyboard::hide(false); }
|
void TabsGroup::onClicked() { Keyboard::hide(false); }
|
||||||
|
|||||||
@@ -100,5 +100,6 @@ class TabsGroup : public NavWindow
|
|||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void onPressPGUP() override;
|
void onPressPGUP() override;
|
||||||
void onPressPGDN() override;
|
void onPressPGDN() override;
|
||||||
|
void onLongPressRTN() override;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -445,6 +445,10 @@ void NavWindow::onEvent(event_t event)
|
|||||||
case EVT_KEY_BREAK(KEY_PAGEUP):
|
case EVT_KEY_BREAK(KEY_PAGEUP):
|
||||||
onPressPGUP();
|
onPressPGUP();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case EVT_KEY_LONG(KEY_EXIT):
|
||||||
|
onLongPressRTN();
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -228,6 +228,7 @@ class NavWindow : public Window
|
|||||||
virtual void onPressPGDN() {}
|
virtual void onPressPGDN() {}
|
||||||
virtual void onLongPressPGUP() {}
|
virtual void onLongPressPGUP() {}
|
||||||
virtual void onLongPressPGDN() {}
|
virtual void onLongPressPGDN() {}
|
||||||
|
virtual void onLongPressRTN() {}
|
||||||
#endif
|
#endif
|
||||||
virtual bool bubbleEvents() { return true; }
|
virtual bool bubbleEvents() { return true; }
|
||||||
void onEvent(event_t event) override;
|
void onEvent(event_t event) override;
|
||||||
|
|||||||
@@ -80,17 +80,6 @@ void TemplatePage::updateInfo()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
|
||||||
void TemplatePage::onEvent(event_t event)
|
|
||||||
{
|
|
||||||
if (event == EVT_KEY_LONG(KEY_EXIT) || event == EVT_KEY_BREAK(KEY_EXIT)) {
|
|
||||||
deleteLater();
|
|
||||||
} else {
|
|
||||||
Page::onEvent(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class SelectTemplate : public TemplatePage
|
class SelectTemplate : public TemplatePage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -33,10 +33,6 @@ class TemplatePage : public Page
|
|||||||
|
|
||||||
void updateInfo();
|
void updateInfo();
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
|
||||||
void onEvent(event_t event) override;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(DEBUG_WINDOWS)
|
#if defined(DEBUG_WINDOWS)
|
||||||
std::string getName() const override { return "TemplatePage"; }
|
std::string getName() const override { return "TemplatePage"; }
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -124,15 +124,6 @@ static void ghostmoduleconfig_cb(lv_event_t* e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS) && !defined(PCBPL18)
|
|
||||||
void RadioGhostModuleConfig::onCancel()
|
|
||||||
{
|
|
||||||
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_JOYLEFT;
|
|
||||||
reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_NONE;
|
|
||||||
moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
RadioGhostModuleConfig::RadioGhostModuleConfig(uint8_t moduleIdx) :
|
RadioGhostModuleConfig::RadioGhostModuleConfig(uint8_t moduleIdx) :
|
||||||
Page(ICON_RADIO_TOOLS), moduleIdx(moduleIdx)
|
Page(ICON_RADIO_TOOLS), moduleIdx(moduleIdx)
|
||||||
{
|
{
|
||||||
@@ -162,21 +153,23 @@ void RadioGhostModuleConfig::buildBody(Window* window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS) && !defined(PCBPL18)
|
#if defined(HARDWARE_KEYS) && !defined(PCBPL18)
|
||||||
void RadioGhostModuleConfig::onEvent(event_t event)
|
void RadioGhostModuleConfig::onCancel()
|
||||||
{
|
{
|
||||||
switch (event) {
|
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_JOYLEFT;
|
||||||
case EVT_KEY_LONG(KEY_EXIT):
|
reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_NONE;
|
||||||
memclear(&reusableBuffer.ghostMenu, sizeof(reusableBuffer.ghostMenu));
|
moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL;
|
||||||
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_NONE;
|
}
|
||||||
reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_CLOSE;
|
|
||||||
moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL;
|
void RadioGhostModuleConfig::onLongPressRTN()
|
||||||
RTOS_WAIT_MS(10);
|
{
|
||||||
Page::onEvent(event);
|
memclear(&reusableBuffer.ghostMenu, sizeof(reusableBuffer.ghostMenu));
|
||||||
|
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_NONE;
|
||||||
|
reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_CLOSE;
|
||||||
|
moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL;
|
||||||
|
RTOS_WAIT_MS(10);
|
||||||
#if defined(TRIMS_EMULATE_BUTTONS)
|
#if defined(TRIMS_EMULATE_BUTTONS)
|
||||||
setHatsAsKeys(false); // switch trims back to normal
|
setHatsAsKeys(false); // switch trims back to normal
|
||||||
#endif
|
#endif
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RadioGhostModuleConfig::checkEvents()
|
void RadioGhostModuleConfig::checkEvents()
|
||||||
|
|||||||
@@ -25,20 +25,19 @@
|
|||||||
|
|
||||||
class RadioGhostModuleConfig: public Page
|
class RadioGhostModuleConfig: public Page
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit RadioGhostModuleConfig(uint8_t moduleIdx);
|
explicit RadioGhostModuleConfig(uint8_t moduleIdx);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
uint8_t moduleIdx;
|
||||||
|
|
||||||
|
void buildHeader(Window * window);
|
||||||
|
void buildBody(Window * window);
|
||||||
|
void init();
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS) && !defined(PCBPL18)
|
#if defined(HARDWARE_KEYS) && !defined(PCBPL18)
|
||||||
void onEvent(event_t event) override;
|
void checkEvents() override;
|
||||||
void checkEvents() override;
|
void onCancel() override;
|
||||||
void onCancel() override;
|
void onLongPressRTN() override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
|
||||||
uint8_t moduleIdx;
|
|
||||||
|
|
||||||
void buildHeader(Window * window);
|
|
||||||
void buildBody(Window * window);
|
|
||||||
void init();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user