summaryrefslogtreecommitdiff
path: root/src/input/include/lvgl_input_driver.hpp
diff options
context:
space:
mode:
authorcooljqln <cooljqln@noreply.codeberg.org>2024-04-11 07:02:53 +0000
committercooljqln <cooljqln@noreply.codeberg.org>2024-04-11 07:02:53 +0000
commitdd1ea595a7753706d4fa5f19b66f3dc1cbd56a02 (patch)
tree60bfa4569af0f9506ccffe85f19e89bbe2a83332 /src/input/include/lvgl_input_driver.hpp
parentf580928cbab797e4e8a3eae5ae1c0b18b8066066 (diff)
parent33919e9e3f419e13318fa6b8217d8c8dcd86c1eb (diff)
downloadtangara-fw-dd1ea595a7753706d4fa5f19b66f3dc1cbd56a02.tar.gz
Merge pull request 'jqln/input-devices' (#62) from jqln/input-devices into main
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/62 Reviewed-by: ailurux <ailurux@noreply.codeberg.org>
Diffstat (limited to 'src/input/include/lvgl_input_driver.hpp')
-rw-r--r--src/input/include/lvgl_input_driver.hpp58
1 files changed, 58 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..257ccb28
--- /dev/null
+++ b/src/input/include/lvgl_input_driver.hpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2023 jacqueline <me@jacqueline.id.au>
+ *
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+#pragma once
+
+#include <cstdint>
+#include <deque>
+#include <memory>
+#include <set>
+
+#include "core/lv_group.h"
+#include "device_factory.hpp"
+#include "feedback_device.hpp"
+#include "gpios.hpp"
+#include "hal/lv_hal_indev.h"
+
+#include "input_device.hpp"
+#include "nvs.hpp"
+#include "property.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(drivers::NvsStorage& nvs, DeviceFactory&);
+
+ auto mode() -> lua::Property& { return mode_; }
+
+ 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:
+ drivers::NvsStorage& nvs_;
+ DeviceFactory& factory_;
+
+ lua::Property mode_;
+ lv_indev_drv_t driver_;
+ lv_indev_t* registration_;
+
+ std::vector<std::shared_ptr<IInputDevice>> inputs_;
+ std::vector<std::shared_ptr<IFeedbackDevice>> feedbacks_;
+
+ bool is_locked_;
+};
+
+} // namespace input