summaryrefslogtreecommitdiff
path: root/src/input/include/lvgl_input_driver.hpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-04-10 16:56:10 +1000
committerjacqueline <me@jacqueline.id.au>2024-04-10 16:56:10 +1000
commited82063af5f83530afa5cfb5bf5bd516f3d05f2a (patch)
treef8beba0e107d57bc0324b930d5200fdc405c96c4 /src/input/include/lvgl_input_driver.hpp
parent2e59325c22605873bba62c078c196d99c1664590 (diff)
downloadtangara-fw-ed82063af5f83530afa5cfb5bf5bd516f3d05f2a.tar.gz
WIP decompose our giant LVGL driver into smaller classes
Diffstat (limited to 'src/input/include/lvgl_input_driver.hpp')
-rw-r--r--src/input/include/lvgl_input_driver.hpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/input/include/lvgl_input_driver.hpp b/src/input/include/lvgl_input_driver.hpp
new file mode 100644
index 00000000..be452368
--- /dev/null
+++ b/src/input/include/lvgl_input_driver.hpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2023 jacqueline <me@jacqueline.id.au>
+ *
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+#pragma once
+
+#include <stdint.h>
+#include <deque>
+#include <memory>
+#include <set>
+
+#include "core/lv_group.h"
+#include "feedback_device.hpp"
+#include "gpios.hpp"
+#include "hal/lv_hal_indev.h"
+
+#include "input_device.hpp"
+#include "nvs.hpp"
+#include "service_locator.hpp"
+#include "touchwheel.hpp"
+
+namespace input {
+
+/*
+ * Implementation of an LVGL input device. This class composes multiple
+ * IInputDevice and IFeedbackDevice instances together into a single LVGL
+ * device.
+ */
+class LvglInputDriver {
+ public:
+ LvglInputDriver(std::shared_ptr<system_fsm::ServiceLocator>);
+
+ auto read(lv_indev_data_t* data) -> void;
+ auto feedback(uint8_t) -> void;
+
+ auto registration() -> lv_indev_t* { return registration_; }
+ auto lock(bool l) -> void { is_locked_ = l; }
+
+ private:
+ std::shared_ptr<system_fsm::ServiceLocator> services_;
+
+ lv_indev_drv_t driver_;
+ lv_indev_t* registration_;
+
+ std::vector<std::unique_ptr<IInputDevice>> inputs_;
+ std::vector<std::unique_ptr<IFeedbackDevice>> feedbacks_;
+
+ bool is_locked_;
+};
+
+} // namespace input