diff options
| author | ailurux <ailuruxx@gmail.com> | 2024-08-29 15:20:22 +1000 |
|---|---|---|
| committer | ailurux <ailuruxx@gmail.com> | 2024-08-29 15:20:22 +1000 |
| commit | 96a224c0df4f647b3e5dbbcbbedad3a1d38470ba (patch) | |
| tree | 8960865293dde6f9844b7b1a42d5775d5dceceb2 /src/tangara/ui/ui_fsm.cpp | |
| parent | 3421bd652c39b253872e43d3b6e43664bd0b66e2 (diff) | |
| download | tangara-fw-96a224c0df4f647b3e5dbbcbbedad3a1d38470ba.tar.gz | |
Lua API improvements and fixes
Co-authored-by: jacqueline <me@jacqueline.id.au>
Diffstat (limited to 'src/tangara/ui/ui_fsm.cpp')
| -rw-r--r-- | src/tangara/ui/ui_fsm.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/tangara/ui/ui_fsm.cpp b/src/tangara/ui/ui_fsm.cpp index 94d1caf8..669b3298 100644 --- a/src/tangara/ui/ui_fsm.cpp +++ b/src/tangara/ui/ui_fsm.cpp @@ -201,7 +201,14 @@ lua::Property UiState::sPlaybackPosition{ return true; }}; -lua::Property UiState::sQueuePosition{0}; +lua::Property UiState::sQueuePosition{0, [](const lua::LuaValue& val){ + if (!std::holds_alternative<int>(val)) { + return false; + } + int new_val = std::get<int>(val); + // val-1 because Lua uses 1-based indexing + return sServices->track_queue().currentPosition(new_val-1); + }}; lua::Property UiState::sQueueSize{0}; lua::Property UiState::sQueueRepeat{false, [](const lua::LuaValue& val) { if (!std::holds_alternative<bool>(val)) { @@ -610,6 +617,16 @@ void Lua::entry() { {"paired_device", &sBluetoothPairedDevice}, {"discovered_devices", &sBluetoothDiscoveredDevices}, {"known_devices", &sBluetoothKnownDevices}, + {"enable", + [&](lua_State* s) { + sBluetoothEnabled.set(true); + return 0; + }}, + {"disable", + [&](lua_State* s) { + sBluetoothEnabled.set(false); + return 0; + }}, }); registry.AddPropertyModule( "playback", |
