summaryrefslogtreecommitdiff
path: root/src/tangara/ui/ui_fsm.cpp
diff options
context:
space:
mode:
authorTab_theFox <tab_thefox@noreply.codeberg.org>2025-03-23 17:45:19 +0100
committerTab_theFox <tab_thefox@noreply.codeberg.org>2025-04-22 22:23:47 +0200
commitdc5676229d19f317b97df6a3d3582bbb02df33df (patch)
tree2036ecb5b6fdefaabc6beb9ac7cab21dcadcad56 /src/tangara/ui/ui_fsm.cpp
parent79c9f0b6ccfec97f23563010f134d842c4240582 (diff)
downloadtangara-fw-dc5676229d19f317b97df6a3d3582bbb02df33df.tar.gz
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)
Diffstat (limited to 'src/tangara/ui/ui_fsm.cpp')
-rw-r--r--src/tangara/ui/ui_fsm.cpp25
1 files changed, 25 insertions, 0 deletions
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<int>(playback_position)) {
+ // I don't think this ever happens, but check anyway.
+ return;
+ }
+
+ const auto track = sPlaybackTrack.get();
+ if (!std::holds_alternative<audio::TrackInfo>(track)) {
+ // Nothing is playing
+ return;
+ }
+
+ const auto current_position = std::get<int>(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<audio::TrackInfo>(track).uri,
+ .seek_to_second = seek_position,
+ });
+}
+
void UiState::react(const system_fsm::KeyLockChanged& ev) {
sDisplay->SetDisplayOn(!ev.locking);
sInput->lock(ev.locking);