From c9ce88a457c9ed7124709a667d202a666f72bffa Mon Sep 17 00:00:00 2001 From: ailurux Date: Wed, 19 Mar 2025 04:25:20 +0000 Subject: ailurux/button-media-controls (#264) Splits the control scheme into separate schemes for the side buttons and touchwheel, allowing them to be configured independently of each other. At least one input must be used for navigation, and there are guards to prevent locking oneself out of any input. If the input scheme is invalid, a pop up will show alerting the user. Different behaviours can be bound to the side buttons for when the device is locked or unlocked. This PR also adds a mode for these buttons that controls media playback (prev/next on up/down, pressing both buttons toggles play/pause). There are some changes to the way inputs handle locking. Rather than the input devices tracking the current locked mode, different input devices are created on lock depending on the mode that is configured. Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/264 Co-authored-by: ailurux Co-committed-by: ailurux --- src/tangara/input/input_hook_actions.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/tangara/input/input_hook_actions.cpp') diff --git a/src/tangara/input/input_hook_actions.cpp b/src/tangara/input/input_hook_actions.cpp index fb6a677c..001d3fb0 100644 --- a/src/tangara/input/input_hook_actions.cpp +++ b/src/tangara/input/input_hook_actions.cpp @@ -62,11 +62,22 @@ auto volumeDown() -> HookCallback { }}; } -auto allActions() -> std::vector { - return { - select(), scrollUp(), scrollDown(), scrollToTop(), - scrollToBottom(), goBack(), volumeUp(), volumeDown(), - }; +auto nextTrack(audio::TrackQueue& queue) -> HookCallback { + return HookCallback{.name = "next_track", .fn = [&](lv_indev_data_t* d) { + queue.next(); + }}; +} + +auto prevTrack(audio::TrackQueue& queue) -> HookCallback { + return HookCallback{.name = "prev_track", .fn = [&](lv_indev_data_t* d) { + queue.previous(); + }}; +} + +auto togglePlayPause() -> HookCallback { + return HookCallback{.name = "toggle_play_pause", .fn = [&](lv_indev_data_t* d) { + events::Audio().Dispatch(audio::TogglePlayPause{}); + }}; } } // namespace actions -- cgit v1.2.3