From 7d5536e2abca61f503ed68521603bd30700a7e5e Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 3 Oct 2023 10:37:29 +1100 Subject: Generalise the lvgl input driver in preparation for more input methods --- src/ui/lvgl_task.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/ui/lvgl_task.cpp') diff --git a/src/ui/lvgl_task.cpp b/src/ui/lvgl_task.cpp index 74f68cf5..ff85a055 100644 --- a/src/ui/lvgl_task.cpp +++ b/src/ui/lvgl_task.cpp @@ -40,7 +40,6 @@ #include "tasks.hpp" #include "touchwheel.hpp" #include "ui_fsm.hpp" -#include "wheel_encoder.hpp" #include "widgets/lv_label.h" #include "display.hpp" @@ -67,15 +66,15 @@ auto UiTask::Main() -> void { std::shared_ptr screen = UiState::current_screen(); if (screen != current_screen_ && screen != nullptr) { lv_scr_load(screen->root()); - if (input_device_) { - lv_indev_set_group(input_device_->registration(), screen->group()); + if (input_) { + lv_indev_set_group(input_->registration(), screen->group()); } current_screen_ = screen; } - if (input_device_ && current_screen_->group() != current_group) { + if (input_ && current_screen_->group() != current_group) { current_group = current_screen_->group(); - lv_indev_set_group(input_device_->registration(), current_group); + lv_indev_set_group(input_->registration(), current_group); } if (current_screen_) { @@ -87,11 +86,10 @@ auto UiTask::Main() -> void { } } -auto UiTask::SetInputDevice(std::shared_ptr dev) -> void { - input_device_ = std::move(dev); - if (current_screen_ && input_device_) { - lv_indev_set_group(input_device_->registration(), current_screen_->group()); - } +auto UiTask::input(std::shared_ptr input) -> void { + assert(current_screen_); + input_ = input; + lv_indev_set_group(input_->registration(), current_screen_->group()); } auto UiTask::Start() -> UiTask* { -- cgit v1.2.3