diff options
| author | ailurux <ailuruxx@gmail.com> | 2024-02-12 17:44:55 +1100 |
|---|---|---|
| committer | ailurux <ailuruxx@gmail.com> | 2024-02-12 17:44:55 +1100 |
| commit | 0426d245c8d863f18babdfbaf21c8673b0746feb (patch) | |
| tree | 32c78617d954ca6546b0225de68e0acc299e7bca /src/ui/ui_fsm.cpp | |
| parent | 527374c72e1ec52e1d5814dbee3587ae100631dd (diff) | |
| download | tangara-fw-0426d245c8d863f18babdfbaf21c8673b0746feb.tar.gz | |
Scroll sensitivity configurable, but inverted
Diffstat (limited to 'src/ui/ui_fsm.cpp')
| -rw-r--r-- | src/ui/ui_fsm.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp index 6e4bbe6f..da8d8999 100644 --- a/src/ui/ui_fsm.cpp +++ b/src/ui/ui_fsm.cpp @@ -242,6 +242,25 @@ lua::Property UiState::sControlsScheme{ return true; }}; +lua::Property UiState::sScrollSensitivity{ + 0, [](const lua::LuaValue& val) { + std::optional<int> sensitivity = 0; + std::visit( + [&](auto&& v) { + using T = std::decay_t<decltype(v)>; + if constexpr (std::is_same_v<T, int>) { + sensitivity = v; + } + }, + val); + if (!sensitivity) { + return false; + } + sInput->scroll_sensitivity(*sensitivity); + sServices->nvs().ScrollSensitivity(*sensitivity); + return true; + }}; + lua::Property UiState::sDatabaseUpdating{false}; auto UiState::InitBootSplash(drivers::IGpios& gpios) -> bool { @@ -397,6 +416,10 @@ void Splash::react(const system_fsm::BootComplete& ev) { sInput->mode(mode); sControlsScheme.Update(static_cast<int>(mode)); + auto sensitivity = sServices->nvs().ScrollSensitivity(); + sInput->scroll_sensitivity(sensitivity); + sScrollSensitivity.Update(static_cast<int>(sensitivity)); + sTask->input(sInput); } else { ESP_LOGE(kTag, "no input devices initialised!"); @@ -460,6 +483,7 @@ void Lua::entry() { sLua->bridge().AddPropertyModule("controls", { {"scheme", &sControlsScheme}, + {"scroll_sensitivity", &sScrollSensitivity}, }); sLua->bridge().AddPropertyModule( |
