mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-01-08 18:47:49 +00:00
Merge pull request #429 from heurist1/add_2_button_press_back_aka_topleft
Added a quick way of moving the cursor to the top left (back) location
This commit is contained in:
commit
535f671284
@ -298,6 +298,12 @@ void EventDispatcher::handle_switches() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( in_key_event ) {
|
if( in_key_event ) {
|
||||||
|
if (switches_state[(size_t)ui::KeyEvent::Left] && switches_state[(size_t)ui::KeyEvent::Up])
|
||||||
|
{
|
||||||
|
const auto event = static_cast<ui::KeyEvent>(ui::KeyEvent::Back);
|
||||||
|
context.focus_manager().update(top_widget, event);
|
||||||
|
}
|
||||||
|
|
||||||
// If we're in a key event, return. We will ignore all additional key
|
// If we're in a key event, return. We will ignore all additional key
|
||||||
// presses until the first key is released. We also want to ignore events
|
// presses until the first key is released. We also want to ignore events
|
||||||
// where the last key held generates a key event when other pressed keys
|
// where the last key held generates a key event when other pressed keys
|
||||||
|
@ -325,6 +325,7 @@ enum class KeyEvent {
|
|||||||
Down = 2,
|
Down = 2,
|
||||||
Up = 3,
|
Up = 3,
|
||||||
Select = 4,
|
Select = 4,
|
||||||
|
Back = 5, /* Left and Up together */
|
||||||
};
|
};
|
||||||
|
|
||||||
using EncoderEvent = int32_t;
|
using EncoderEvent = int32_t;
|
||||||
|
@ -179,7 +179,14 @@ void FocusManager::update(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const auto nearest = std::min_element(collection.cbegin(), collection.cend(), compare_fn);
|
const auto nearest = std::min_element(collection.cbegin(), collection.cend(), compare_fn);
|
||||||
if( nearest != collection.cend() ) {
|
// Up and left to indicate back
|
||||||
|
if (event == KeyEvent::Back) {
|
||||||
|
collection.clear();
|
||||||
|
widget_collect_visible(top_widget, find_back_fn, collection);
|
||||||
|
if (!collection.empty())
|
||||||
|
set_focus_widget(collection[0].first);
|
||||||
|
}
|
||||||
|
else if( nearest != collection.cend() ) {
|
||||||
//focus->blur();
|
//focus->blur();
|
||||||
const auto new_focus = (*nearest).first;
|
const auto new_focus = (*nearest).first;
|
||||||
set_focus_widget(new_focus);
|
set_focus_widget(new_focus);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user