fix: Audio/haptic feedback for all hard keys except trim switches (#2201)

* Added audio/haptic feedback for all hard keys excpet trim switches.

Changed logic from application decides if feedback has to be given (was inconsistent and inefficient) to key driver detects button down and triggers immediate feedback if radio settings allowed for acoustic and/or haptic feedback (radio settings, radio setup, sound set to All)

With this change all instances of the application calling for feedback were removed in favor of the centralized approach.

This first commit also introduces a dummy function for providing feedback on key presses in boot.cpp because keys.cpp is also used as the bootloader key driver but with no logic to determine if feedback is allowed. Using a define that indicates keys.cpp is compiled for use in the bootloader would make a much nicer and backwards compatible solution.

* don't want to change libopenui so silence onKeyPress (application requests feedback) in audio.cpp

* made generation of acoustic/haptic feedback conditional on BOOT define, i.e. no feedback if keys.cpp is compiled for the bootloader

* removed onKeyPress()

* fixed crash on acoustic/haptic feedback on hard keys by restoring keys.cpp and moving logic to LvglWrapper.cpp/keyboardDriverRead().

Removed call to getWindowEvent() which would just call getEvent(false) by directly calling getEvent(false). This allowed to remove getWindowEvent() entirely as it was only used by keyboardDriverRead().

* fix: Audio header include no longer needed
This commit is contained in:
Michael
2022-08-19 15:00:50 +10:00
committed by GitHub
parent 8c228bc50f
commit 34dadf7b65
8 changed files with 16 additions and 21 deletions
-5
View File
@@ -1267,11 +1267,6 @@ void pushPrompt(uint16_t prompt, uint8_t id)
#endif
}
void onKeyPress()
{
audioKeyPress();
}
void onKeyError()
{
audioKeyError();
+15 -5
View File
@@ -121,8 +121,18 @@ static void keyboardDriverRead(lv_indev_drv_t *drv, lv_indev_data_t *data)
{
data->key = 0;
if (isEvent()) {
event_t evt = getWindowEvent();
if (isEvent()) { // event waiting
event_t evt = getEvent(false); // get keyEvent for hard keys other than trim switches
if(evt == EVT_KEY_FIRST(KEY_PGUP) || // generate acoustic/haptic feedback if radio settings allow
evt == EVT_KEY_FIRST(KEY_PGDN) ||
evt == EVT_KEY_FIRST(KEY_ENTER) ||
evt == EVT_KEY_FIRST(KEY_MODEL) ||
evt == EVT_KEY_FIRST(KEY_EXIT) ||
evt == EVT_KEY_FIRST(KEY_TELEM) ||
evt == EVT_KEY_FIRST(KEY_RADIO)) {
audioKeyPress();
}
// no focused item ?
auto obj = get_focus_obj(keyboardDevice);
@@ -209,9 +219,9 @@ extern "C" void touchDriverRead(lv_indev_drv_t *drv, lv_indev_data_t *data)
copy_ts_to_indev_data(st, data);
}
if (st.event == TE_UP) { // on Touch Up
reset_inactivity(); // reset activity counter
onKeyPress(); // provide acoustic and/or haptic feedback if requested in settings
if (st.event == TE_DOWN) { // on first touch (same logic as key down)
reset_inactivity(); // reset activity counter
audioKeyPress(); // provide acoustic and/or haptic feedback if requested in settings
}
backup_touch_data(data);
@@ -117,7 +117,6 @@ bool BindRxChoiceMenu::onTouchEnd(coord_t x, coord_t y)
// by clicking outside the menu window and the onCancel
// handler is not accessible from here
moduleState[moduleIdx].mode = MODULE_MODE_NORMAL;
onKeyPress();
deleteLater();
return true;
}
@@ -220,7 +220,6 @@ bool ColorEditorPopup::onTouchEnd(coord_t x, coord_t y)
{
TRACE("ColorEditorPopup::onTouchEnd");
if (!Window::onTouchEnd(x, y) && closeWhenClickOutside) {
onKeyPress();
deleteLater();
}
return true;
-6
View File
@@ -258,9 +258,3 @@ void lcdFlushed()
if (refr_disp != nullptr)
lv_disp_flush_ready(refr_disp);
}
//TODO: move this somewhere else
event_t getWindowEvent()
{
return getEvent(false);
}
-1
View File
@@ -182,7 +182,6 @@ public:
for (auto i = 0; i < (int) _tabs.size(); i++)
_tabs[i]->check(i == _activeTab);
_colorEditor->setColorEditorType(_activeTab == 1 ? HSV_COLOR_EDITOR : RGB_COLOR_EDITOR);
onKeyPress();
}
}
-1
View File
@@ -36,7 +36,6 @@ class ViewMainMenu : public Window
bool onTouchStart(coord_t /*x*/, coord_t /*y*/) override { return true; }
bool onTouchEnd(coord_t x, coord_t y) override
{
onKeyPress();
deleteLater();
return true;
}