summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorailurux <ailurux@noreply.codeberg.org>2025-03-19 04:25:20 +0000
committercooljqln <cooljqln@noreply.codeberg.org>2025-03-19 04:25:20 +0000
commitc9ce88a457c9ed7124709a667d202a666f72bffa (patch)
tree681cba582d4e18c743029cb72ea542eee23e9907 /lua
parent95dd0ddec52a25a57e367e5568ac97f8e3f0d312 (diff)
downloadtangara-fw-c9ce88a457c9ed7124709a667d202a666f72bffa.tar.gz
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 <ailurux@noreply.codeberg.org> Co-committed-by: ailurux <ailurux@noreply.codeberg.org>
Diffstat (limited to 'lua')
-rw-r--r--lua/main.lua2
-rw-r--r--lua/settings.lua29
-rw-r--r--lua/widgets.lua26
3 files changed, 52 insertions, 5 deletions
diff --git a/lua/main.lua b/lua/main.lua
index 12705c00..5be79c9a 100644
--- a/lua/main.lua
+++ b/lua/main.lua
@@ -74,7 +74,7 @@ local function init_ui()
end
end
end),
- controls.scheme:bind(function()
+ controls.wheel_scheme:bind(function()
-- Set up a shortcut for jumping straight to the 'now playing' screen.
-- Implemented as a binding so that the shortcut is still applied even if
-- the control scheme is changed at runtime.
diff --git a/lua/settings.lua b/lua/settings.lua
index 5ed93521..d60ecfda 100644
--- a/lua/settings.lua
+++ b/lua/settings.lua
@@ -471,20 +471,33 @@ settings.InputSettings = SettingsScreen:new {
controls_chooser:onevent(lvgl.EVENT.VALUE_CHANGED, function()
local option = controls_chooser:get('selected')
local scheme = option_to_scheme[option]
- control_scheme:set(scheme)
+ local prev_scheme = control_scheme:get()
+ -- Check the new scheme is valid
+ if not control_scheme:set(scheme) then
+ widgets.PopUp("Controls not valid")
+ control_scheme:set(prev_scheme)
+ end
end)
return controls_chooser
end
theme.set_subject(self.content:Label {
- text = "Control scheme",
+ text = "Wheel Controls",
}, "settings_title")
- local controls_chooser = make_scheme_control(self, controls.schemes(), controls.scheme)
+ local controls_chooser = make_scheme_control(self, controls.wheel_schemes(), controls.wheel_scheme)
local controls_chooser_desc = widgets.Description(controls_chooser, "Control scheme")
theme.set_subject(self.content:Label {
- text = "Control scheme when locked",
+ text = "Side Button Controls",
+ }, "settings_title")
+ make_scheme_control(self, controls.button_schemes(), controls.button_scheme)
+
+ theme.set_subject(self.content:Label {
+ text = "Side Button Controls When Locked",
+ w = lvgl.PCT(80),
+ h = lvgl.SIZE_CONTENT,
+ long_mode = lvgl.LABEL.LONG_WRAP,
}, "settings_title")
local controls_locked = make_scheme_control(self, controls.locked_schemes(), controls.locked_scheme)
local controls_locked_desc = widgets.Description(controls_locked, "Control scheme when locked")
@@ -510,6 +523,14 @@ settings.InputSettings = SettingsScreen:new {
controls.scroll_sensitivity:set(sensitivity:value() * slider_scale)
end)
local sensitivity_desc = widgets.Description(sensitivity, "Scroll Sensitivity")
+
+ local spacer = self.content:Object {
+ w = lvgl.PCT(90),
+ h = 10,
+ }
+ sensitivity:onevent(lvgl.EVENT.FOCUSED, function()
+ spacer:scroll_to_view(true)
+ end)
end
}
diff --git a/lua/widgets.lua b/lua/widgets.lua
index de2aa43d..5e2ed858 100644
--- a/lua/widgets.lua
+++ b/lua/widgets.lua
@@ -372,4 +372,30 @@ function widgets.InfiniteList(parent, iterator, opts)
return infinite_list
end
+function widgets.PopUp(text)
+ require("alerts").show(function()
+ local container = lvgl.Object(nil, {
+ w = lvgl.PCT(80),
+ h = lvgl.SIZE_CONTENT,
+ flex = {
+ flex_direction = "column",
+ justify_content = "center",
+ align_items = "center",
+ align_content = "center",
+ },
+ radius = 8,
+ pad_all = 5,
+ })
+ theme.set_subject(container, "pop_up")
+ container:Label {
+ text = text,
+ text_font = font.fusion_10,
+ w = lvgl.PCT(100),
+ h = lvgl.SIZE_CONTENT,
+ long_mode = lvgl.LABEL.LONG_WRAP,
+ }
+ container:center()
+ end)
+end
+
return widgets