summaryrefslogtreecommitdiff
path: root/src/ui/encoder_input.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/encoder_input.cpp')
-rw-r--r--src/ui/encoder_input.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/ui/encoder_input.cpp b/src/ui/encoder_input.cpp
index 0345665b..f6a981a7 100644
--- a/src/ui/encoder_input.cpp
+++ b/src/ui/encoder_input.cpp
@@ -9,7 +9,10 @@
#include <sys/_stdint.h>
#include <memory>
+#include "lvgl.h"
+
#include "audio_events.hpp"
+#include "core/lv_event.h"
#include "core/lv_group.h"
#include "esp_timer.h"
#include "event_queue.hpp"
@@ -20,6 +23,8 @@
#include "touchwheel.hpp"
#include "ui_events.hpp"
+static constexpr char kTag[] = "input";
+
constexpr int kDPadAngleThreshold = 20;
constexpr int kLongPressDelayMs = 500;
constexpr int kRepeatDelayMs = 250;
@@ -58,6 +63,11 @@ auto EncoderInput::Read(lv_indev_data_t* data) -> void {
return;
}
+ lv_obj_t* active_object = nullptr;
+ if (registration_ && registration_->group) {
+ active_object = lv_group_get_focused(registration_->group);
+ }
+
raw_wheel_.Update();
relative_wheel_->Update();
// GPIOs updating is handled by system_fsm.
@@ -226,8 +236,9 @@ auto EncoderInput::Read(lv_indev_data_t* data) -> void {
data->state = LV_INDEV_STATE_PRESSED;
break;
case Trigger::kLongPress:
- // TODO: ???
- data->state = LV_INDEV_STATE_PRESSED;
+ if (active_object) {
+ lv_event_send(active_object, LV_EVENT_LONG_PRESSED, NULL);
+ }
break;
}