summaryrefslogtreecommitdiff
path: root/src/tangara/input
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-06-14 13:34:41 +1000
committerjacqueline <me@jacqueline.id.au>2024-06-14 13:34:41 +1000
commit5086ab96ea648cd842addb02b188f29bff7bbadd (patch)
tree7a3579d655c906ace9e76c394c33eb164d7ce7aa /src/tangara/input
parent194f0e6b59259986b36448c376788c227d490f06 (diff)
parent37ed3996017e43b343e4880981d70c4a6d4a5636 (diff)
downloadtangara-fw-5086ab96ea648cd842addb02b188f29bff7bbadd.tar.gz
Merge branch 'jqln/lvgl-bump'
Diffstat (limited to 'src/tangara/input')
-rw-r--r--src/tangara/input/feedback_haptics.cpp4
-rw-r--r--src/tangara/input/feedback_tts.cpp10
-rw-r--r--src/tangara/input/input_device.hpp2
-rw-r--r--src/tangara/input/input_hook.cpp2
-rw-r--r--src/tangara/input/input_hook.hpp2
-rw-r--r--src/tangara/input/input_hook_actions.cpp2
-rw-r--r--src/tangara/input/input_hook_actions.hpp1
-rw-r--r--src/tangara/input/input_nav_buttons.cpp3
-rw-r--r--src/tangara/input/input_nav_buttons.hpp6
-rw-r--r--src/tangara/input/input_touch_dpad.cpp3
-rw-r--r--src/tangara/input/input_touch_dpad.hpp2
-rw-r--r--src/tangara/input/input_touch_wheel.cpp2
-rw-r--r--src/tangara/input/input_touch_wheel.hpp2
-rw-r--r--src/tangara/input/input_trigger.hpp6
-rw-r--r--src/tangara/input/input_volume_buttons.hpp6
-rw-r--r--src/tangara/input/lvgl_input_driver.cpp53
-rw-r--r--src/tangara/input/lvgl_input_driver.hpp11
17 files changed, 60 insertions, 57 deletions
diff --git a/src/tangara/input/feedback_haptics.cpp b/src/tangara/input/feedback_haptics.cpp
index c834ca54..a447a69d 100644
--- a/src/tangara/input/feedback_haptics.cpp
+++ b/src/tangara/input/feedback_haptics.cpp
@@ -9,10 +9,8 @@
#include <cstdint>
#include "core/lv_group.h"
-#include "lvgl/lvgl.h"
-
-#include "core/lv_event.h"
#include "esp_log.h"
+#include "lvgl/lvgl.h"
#include "drivers/haptics.hpp"
diff --git a/src/tangara/input/feedback_tts.cpp b/src/tangara/input/feedback_tts.cpp
index a9267aa8..e7e167c6 100644
--- a/src/tangara/input/feedback_tts.cpp
+++ b/src/tangara/input/feedback_tts.cpp
@@ -11,14 +11,14 @@
#include "lvgl/lvgl.h"
-#include "core/lv_event.h"
#include "core/lv_group.h"
#include "core/lv_obj.h"
#include "core/lv_obj_class.h"
#include "core/lv_obj_tree.h"
-#include "extra/widgets/list/lv_list.h"
#include "tts/events.hpp"
-#include "widgets/lv_label.h"
+#include "widgets/button/lv_button.h"
+#include "widgets/label/lv_label.h"
+#include "widgets/list/lv_list.h"
#include "tts/events.hpp"
#include "tts/provider.hpp"
@@ -51,8 +51,8 @@ auto TextToSpeech::feedback(lv_group_t* group, uint8_t event_type) -> void {
}
auto TextToSpeech::describe(lv_obj_t& obj) -> void {
- if (lv_obj_check_type(&obj, &lv_btn_class) ||
- lv_obj_check_type(&obj, &lv_list_btn_class)) {
+ if (lv_obj_check_type(&obj, &lv_button_class) ||
+ lv_obj_check_type(&obj, &lv_list_button_class)) {
auto desc = findDescription(obj);
tts_.feed(tts::SelectionChanged{
.new_selection =
diff --git a/src/tangara/input/input_device.hpp b/src/tangara/input/input_device.hpp
index e3d17c6c..da2b31cd 100644
--- a/src/tangara/input/input_device.hpp
+++ b/src/tangara/input/input_device.hpp
@@ -10,7 +10,7 @@
#include <string>
#include <vector>
-#include "hal/lv_hal_indev.h"
+#include "indev/lv_indev.h"
#include "input/input_hook.hpp"
#include "lua/property.hpp"
diff --git a/src/tangara/input/input_hook.cpp b/src/tangara/input/input_hook.cpp
index 95ff8f2c..0867bb39 100644
--- a/src/tangara/input/input_hook.cpp
+++ b/src/tangara/input/input_hook.cpp
@@ -9,7 +9,7 @@
#include <functional>
#include <optional>
-#include "hal/lv_hal_indev.h"
+#include "indev/lv_indev.h"
#include "lua.hpp"
#include "input/input_trigger.hpp"
diff --git a/src/tangara/input/input_hook.hpp b/src/tangara/input/input_hook.hpp
index 06fcb037..94a35850 100644
--- a/src/tangara/input/input_hook.hpp
+++ b/src/tangara/input/input_hook.hpp
@@ -10,7 +10,7 @@
#include <optional>
#include <string>
-#include "hal/lv_hal_indev.h"
+#include "indev/lv_indev.h"
#include "lua.hpp"
#include "input/input_trigger.hpp"
diff --git a/src/tangara/input/input_hook_actions.cpp b/src/tangara/input/input_hook_actions.cpp
index 656f8cdb..fb6a677c 100644
--- a/src/tangara/input/input_hook_actions.cpp
+++ b/src/tangara/input/input_hook_actions.cpp
@@ -8,7 +8,7 @@
#include <cstdint>
-#include "hal/lv_hal_indev.h"
+#include "indev/lv_indev.h"
#include "events/event_queue.hpp"
#include "ui/ui_events.hpp"
diff --git a/src/tangara/input/input_hook_actions.hpp b/src/tangara/input/input_hook_actions.hpp
index 71a560bc..bca82af6 100644
--- a/src/tangara/input/input_hook_actions.hpp
+++ b/src/tangara/input/input_hook_actions.hpp
@@ -6,7 +6,6 @@
#pragma once
-#include "hal/lv_hal_indev.h"
#include "input/input_hook.hpp"
namespace input {
diff --git a/src/tangara/input/input_nav_buttons.cpp b/src/tangara/input/input_nav_buttons.cpp
index ba1f4b74..0c904a84 100644
--- a/src/tangara/input/input_nav_buttons.cpp
+++ b/src/tangara/input/input_nav_buttons.cpp
@@ -6,9 +6,10 @@
#include "input/input_nav_buttons.hpp"
+#include "indev/lv_indev.h"
+
#include "drivers/gpios.hpp"
#include "events/event_queue.hpp"
-#include "hal/lv_hal_indev.h"
#include "input/input_hook_actions.hpp"
namespace input {
diff --git a/src/tangara/input/input_nav_buttons.hpp b/src/tangara/input/input_nav_buttons.hpp
index ce2312a0..64b547e6 100644
--- a/src/tangara/input/input_nav_buttons.hpp
+++ b/src/tangara/input/input_nav_buttons.hpp
@@ -8,14 +8,14 @@
#include <cstdint>
-#include "drivers/gpios.hpp"
-#include "hal/lv_hal_indev.h"
+#include "indev/lv_indev.h"
+#include "drivers/gpios.hpp"
#include "drivers/haptics.hpp"
+#include "drivers/touchwheel.hpp"
#include "input/input_device.hpp"
#include "input/input_hook.hpp"
#include "input/input_trigger.hpp"
-#include "drivers/touchwheel.hpp"
namespace input {
diff --git a/src/tangara/input/input_touch_dpad.cpp b/src/tangara/input/input_touch_dpad.cpp
index 5d8e2dab..7dc9f04f 100644
--- a/src/tangara/input/input_touch_dpad.cpp
+++ b/src/tangara/input/input_touch_dpad.cpp
@@ -8,11 +8,10 @@
#include <cstdint>
-#include "hal/lv_hal_indev.h"
+#include "indev/lv_indev.h"
#include "drivers/haptics.hpp"
#include "drivers/touchwheel.hpp"
-
#include "events/event_queue.hpp"
#include "input/input_device.hpp"
#include "input/input_hook_actions.hpp"
diff --git a/src/tangara/input/input_touch_dpad.hpp b/src/tangara/input/input_touch_dpad.hpp
index 8fb14832..4e50819a 100644
--- a/src/tangara/input/input_touch_dpad.hpp
+++ b/src/tangara/input/input_touch_dpad.hpp
@@ -8,7 +8,7 @@
#include <cstdint>
-#include "hal/lv_hal_indev.h"
+#include "indev/lv_indev.h"
#include "drivers/haptics.hpp"
#include "input/input_device.hpp"
diff --git a/src/tangara/input/input_touch_wheel.cpp b/src/tangara/input/input_touch_wheel.cpp
index ed60dd9b..b961bb02 100644
--- a/src/tangara/input/input_touch_wheel.cpp
+++ b/src/tangara/input/input_touch_wheel.cpp
@@ -9,7 +9,7 @@
#include <cstdint>
#include <variant>
-#include "hal/lv_hal_indev.h"
+#include "indev/lv_indev.h"
#include "drivers/haptics.hpp"
#include "drivers/nvs.hpp"
diff --git a/src/tangara/input/input_touch_wheel.hpp b/src/tangara/input/input_touch_wheel.hpp
index d023873a..cf86eced 100644
--- a/src/tangara/input/input_touch_wheel.hpp
+++ b/src/tangara/input/input_touch_wheel.hpp
@@ -9,7 +9,7 @@
#include <sys/_stdint.h>
#include <cstdint>
-#include "hal/lv_hal_indev.h"
+#include "indev/lv_indev.h"
#include "drivers/haptics.hpp"
#include "input/input_device.hpp"
diff --git a/src/tangara/input/input_trigger.hpp b/src/tangara/input/input_trigger.hpp
index 1b0e681d..9f0b7e19 100644
--- a/src/tangara/input/input_trigger.hpp
+++ b/src/tangara/input/input_trigger.hpp
@@ -9,13 +9,11 @@
#include <cstdint>
#include <optional>
-#include "hal/lv_hal_indev.h"
-
namespace input {
const uint16_t kDoubleClickDelayMs = 500;
-const uint16_t kLongPressDelayMs = LV_INDEV_DEF_LONG_PRESS_TIME;
-const uint16_t kRepeatDelayMs = LV_INDEV_DEF_LONG_PRESS_REP_TIME;
+const uint16_t kLongPressDelayMs = 400;
+const uint16_t kRepeatDelayMs = 100;
class Trigger {
public:
diff --git a/src/tangara/input/input_volume_buttons.hpp b/src/tangara/input/input_volume_buttons.hpp
index 22a8acf2..4af14344 100644
--- a/src/tangara/input/input_volume_buttons.hpp
+++ b/src/tangara/input/input_volume_buttons.hpp
@@ -8,13 +8,13 @@
#include <cstdint>
-#include "drivers/gpios.hpp"
-#include "hal/lv_hal_indev.h"
+#include "indev/lv_indev.h"
+#include "drivers/gpios.hpp"
#include "drivers/haptics.hpp"
+#include "drivers/touchwheel.hpp"
#include "input/input_device.hpp"
#include "input/input_hook.hpp"
-#include "drivers/touchwheel.hpp"
namespace input {
diff --git a/src/tangara/input/lvgl_input_driver.cpp b/src/tangara/input/lvgl_input_driver.cpp
index 9c1ccff9..86f9b279 100644
--- a/src/tangara/input/lvgl_input_driver.cpp
+++ b/src/tangara/input/lvgl_input_driver.cpp
@@ -10,8 +10,8 @@
#include <memory>
#include <variant>
-#include "core/lv_event.h"
-#include "core/lv_indev.h"
+#include "core/lv_group.h"
+#include "indev/lv_indev.h"
#include "lua.hpp"
#include "lvgl.h"
@@ -25,6 +25,7 @@
#include "input/input_volume_buttons.hpp"
#include "lua/lua_thread.hpp"
#include "lua/property.hpp"
+#include "misc/lv_event.h"
[[maybe_unused]] static constexpr char kTag[] = "input";
@@ -33,16 +34,22 @@ static constexpr char kLuaOverrideText[] = "lua_callback";
namespace input {
-static void read_cb(lv_indev_drv_t* drv, lv_indev_data_t* data) {
+static void read_cb(lv_indev_t* dev, lv_indev_data_t* data) {
LvglInputDriver* instance =
- reinterpret_cast<LvglInputDriver*>(drv->user_data);
+ reinterpret_cast<LvglInputDriver*>(lv_indev_get_user_data(dev));
instance->read(data);
}
-static void feedback_cb(lv_indev_drv_t* drv, uint8_t event) {
+static void feedback_cb(lv_event_t* ev) {
LvglInputDriver* instance =
- reinterpret_cast<LvglInputDriver*>(drv->user_data);
- instance->feedback(event);
+ reinterpret_cast<LvglInputDriver*>(lv_event_get_user_data(ev));
+ instance->feedback(lv_event_get_code(ev));
+}
+
+static void focus_cb(lv_group_t* group) {
+ LvglInputDriver* instance =
+ reinterpret_cast<LvglInputDriver*>(group->user_data);
+ instance->feedback(LV_EVENT_FOCUSED);
}
auto intToMode(int raw) -> std::optional<drivers::NvsStorage::InputModes> {
@@ -77,29 +84,31 @@ LvglInputDriver::LvglInputDriver(drivers::NvsStorage& nvs,
inputs_ = factory.createInputs(*mode);
return true;
}),
- driver_(),
- registration_(nullptr),
inputs_(factory.createInputs(nvs.PrimaryInput())),
feedbacks_(factory.createFeedbacks()),
is_locked_(false) {
- lv_indev_drv_init(&driver_);
- driver_.type = LV_INDEV_TYPE_ENCODER;
- driver_.read_cb = read_cb;
- driver_.feedback_cb = feedback_cb;
- driver_.user_data = this;
- driver_.long_press_time = kLongPressDelayMs;
- driver_.long_press_repeat_time = kRepeatDelayMs;
-
- registration_ = lv_indev_drv_register(&driver_);
+ device_ = lv_indev_create();
+ lv_indev_set_type(device_, LV_INDEV_TYPE_ENCODER);
+ lv_indev_set_user_data(device_, this);
+ lv_indev_set_read_cb(device_, read_cb);
+ lv_indev_add_event_cb(device_, feedback_cb, LV_EVENT_ALL, this);
}
auto LvglInputDriver::setGroup(lv_group_t* g) -> void {
+ lv_group_t* prev = lv_indev_get_group(device_);
+ if (prev && prev != g) {
+ lv_group_set_focus_cb(prev, NULL);
+ }
if (!g) {
return;
}
- lv_indev_set_group(registration_, g);
- // Emit a synthetic 'focus' event for the current selection, since otherwise
- // our feedback devices won't know that the selection changed.
+ lv_indev_set_group(device_, g);
+
+ g->user_data = this;
+ lv_group_set_focus_cb(g, focus_cb);
+
+ // Emit a synthetic 'focus' event for the current selection, since
+ // otherwise our feedback devices won't know that the selection changed.
feedback(LV_EVENT_FOCUSED);
}
@@ -119,7 +128,7 @@ auto LvglInputDriver::feedback(uint8_t event) -> void {
return;
}
for (auto&& device : feedbacks_) {
- device->feedback(registration_->group, event);
+ device->feedback(lv_indev_get_group(device_), event);
}
}
diff --git a/src/tangara/input/lvgl_input_driver.hpp b/src/tangara/input/lvgl_input_driver.hpp
index 0b6a7e76..ddbdee55 100644
--- a/src/tangara/input/lvgl_input_driver.hpp
+++ b/src/tangara/input/lvgl_input_driver.hpp
@@ -12,13 +12,13 @@
#include <set>
#include "core/lv_group.h"
-#include "drivers/gpios.hpp"
-#include "hal/lv_hal_indev.h"
-#include "input/device_factory.hpp"
-#include "input/feedback_device.hpp"
+#include "indev/lv_indev.h"
+#include "drivers/gpios.hpp"
#include "drivers/nvs.hpp"
#include "drivers/touchwheel.hpp"
+#include "input/device_factory.hpp"
+#include "input/feedback_device.hpp"
#include "input/input_device.hpp"
#include "input/input_hook.hpp"
#include "lua/lua_thread.hpp"
@@ -50,8 +50,7 @@ class LvglInputDriver {
DeviceFactory& factory_;
lua::Property mode_;
- lv_indev_drv_t driver_;
- lv_indev_t* registration_;
+ lv_indev_t* device_;
std::vector<std::shared_ptr<IInputDevice>> inputs_;
std::vector<std::shared_ptr<IFeedbackDevice>> feedbacks_;