diff --git a/src/lua/include/lua_thread.hpp b/src/lua/include/lua_thread.hpp index 4c5198aa..b10fdadf 100644 --- a/src/lua/include/lua_thread.hpp +++ b/src/lua/include/lua_thread.hpp @@ -30,6 +30,7 @@ class LuaThread { auto RunScript(const std::string& path) -> bool; auto bridge() -> Bridge& { return *bridge_; } + auto state() -> lua_State* { return state_; } private: LuaThread(std::unique_ptr&, std::unique_ptr&, lua_State*); diff --git a/src/ui/encoder_input.cpp b/src/ui/encoder_input.cpp index b27c2862..39aacc0c 100644 --- a/src/ui/encoder_input.cpp +++ b/src/ui/encoder_input.cpp @@ -264,6 +264,26 @@ auto EncoderInput::Read(lv_indev_data_t* data) -> void { break; } + // Only trigger the directional long-press gestures if they trigger at the + // same time as a trigger on the overall touchwheel. This means the + // gestures only trigger if it's your only interaction with the wheel this + // press; scrolling and then resting on a direction should not trigger + // them. + trigger = TriggerKey(Keys::kTouchWheel, KeyStyle::kLongPress, now_ms); + if (trigger == Trigger::kLongPress) { + trigger = + TriggerKey(Keys::kDirectionalLeft, KeyStyle::kLongPress, now_ms); + switch (trigger) { + case Trigger::kNone: + break; + case Trigger::kClick: + break; + case Trigger::kLongPress: + events::Ui().Dispatch(internal::BackPressed{}); + break; + } + } + break; } } diff --git a/src/ui/include/ui_fsm.hpp b/src/ui/include/ui_fsm.hpp index a8291a46..671cbf84 100644 --- a/src/ui/include/ui_fsm.hpp +++ b/src/ui/include/ui_fsm.hpp @@ -130,6 +130,7 @@ class Lua : public UiState { void react(const audio::PlaybackStarted&) override; void react(const audio::PlaybackUpdate&) override; void react(const audio::PlaybackFinished&) override; + void react(const internal::BackPressed&) override; using UiState::react; diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp index 539cbc9b..48eca3ff 100644 --- a/src/ui/ui_fsm.cpp +++ b/src/ui/ui_fsm.cpp @@ -245,7 +245,7 @@ auto Lua::PushLuaScreen(lua_State* s) -> int { return 0; } -auto Lua::PopLuaScreen(lua_State* s) -> int { +auto Lua::PopLuaScreen(lua_State *s) -> int { PopScreen(); luavgl_set_root(s, sCurrentScreen->content()); lv_group_set_default(sCurrentScreen->group()); @@ -301,6 +301,10 @@ void Lua::react(const audio::PlaybackFinished&) { playback_playing_->Update(false); } +void Lua::react(const internal::BackPressed& ev) { + PopLuaScreen(sLua->state()); +} + void Browse::entry() {} void Browse::react(const internal::ShowSettingsPage& ev) {