From dc5676229d19f317b97df6a3d3582bbb02df33df Mon Sep 17 00:00:00 2001 From: Tab_theFox Date: Sun, 23 Mar 2025 17:45:19 +0100 Subject: add single touch shourtcuts for touch wheel This allows you to use the touch wheel for quick playback control: - bottom quadrant for play/pause - left and right quadrant for track skip back / forward - top quadrant to seek back 25 seconds (handy when listening to a podcast) --- src/tangara/ui/ui_fsm.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/tangara/ui/ui_fsm.cpp') diff --git a/src/tangara/ui/ui_fsm.cpp b/src/tangara/ui/ui_fsm.cpp index aaf35d13..1b8c0984 100644 --- a/src/tangara/ui/ui_fsm.cpp +++ b/src/tangara/ui/ui_fsm.cpp @@ -403,6 +403,31 @@ void UiState::react(const Screenshot& ev) { SaveScreenshot(sCurrentScreen->root(), ev.filename); } +void UiState::react(const SeekBack& ev) { + const auto playback_position = sPlaybackPosition.get(); + if (!std::holds_alternative(playback_position)) { + // I don't think this ever happens, but check anyway. + return; + } + + const auto track = sPlaybackTrack.get(); + if (!std::holds_alternative(track)) { + // Nothing is playing + return; + } + + const auto current_position = std::get(playback_position); + int32_t seek_position = current_position - ev.seconds; + if (seek_position < 1) { + seek_position = 0; + } + + events::Audio().Dispatch(audio::SetTrack{ + .new_track = std::get(track).uri, + .seek_to_second = seek_position, + }); +} + void UiState::react(const system_fsm::KeyLockChanged& ev) { sDisplay->SetDisplayOn(!ev.locking); sInput->lock(ev.locking); -- cgit v1.2.3