summaryrefslogtreecommitdiff
path: root/src/input/input_touch_dpad.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-04-11 15:16:35 +1000
committerjacqueline <me@jacqueline.id.au>2024-04-11 15:16:35 +1000
commit33919e9e3f419e13318fa6b8217d8c8dcd86c1eb (patch)
tree9e3a1209c8f17f9a6d57249fae7067cbb81e0227 /src/input/input_touch_dpad.cpp
parented82063af5f83530afa5cfb5bf5bd516f3d05f2a (diff)
downloadtangara-fw-33919e9e3f419e13318fa6b8217d8c8dcd86c1eb.tar.gz
Migrate all existing control schemes to the cool new world
Diffstat (limited to 'src/input/input_touch_dpad.cpp')
-rw-r--r--src/input/input_touch_dpad.cpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/input/input_touch_dpad.cpp b/src/input/input_touch_dpad.cpp
index a5774ef6..828d6b59 100644
--- a/src/input/input_touch_dpad.cpp
+++ b/src/input/input_touch_dpad.cpp
@@ -10,6 +10,7 @@
#include "hal/lv_hal_indev.h"
+#include "event_queue.hpp"
#include "haptics.hpp"
#include "input_device.hpp"
#include "input_touch_dpad.hpp"
@@ -28,8 +29,47 @@ TouchDPad::TouchDPad(drivers::TouchWheel& wheel) : wheel_(wheel) {}
auto TouchDPad::read(lv_indev_data_t* data) -> void {
wheel_.Update();
+ auto wheel_data = wheel_.GetTouchWheelData();
- // TODO: reimplement
+ if (wheel_data.is_button_touched) {
+ data->state = LV_INDEV_STATE_PRESSED;
+ } else {
+ data->state = LV_INDEV_STATE_RELEASED;
+ }
+
+ switch (up_.update(
+ wheel_data.is_wheel_touched &&
+ drivers::TouchWheel::isAngleWithin(wheel_data.wheel_position, 0, 32))) {
+ case Trigger::State::kNone:
+ break;
+ default:
+ data->enc_diff = -1;
+ break;
+ }
+ switch (right_.update(
+ wheel_data.is_wheel_touched &&
+ drivers::TouchWheel::isAngleWithin(wheel_data.wheel_position, 192, 32))) {
+ default:
+ break;
+ }
+ switch (down_.update(
+ wheel_data.is_wheel_touched &&
+ drivers::TouchWheel::isAngleWithin(wheel_data.wheel_position, 128, 32))) {
+ case Trigger::State::kNone:
+ break;
+ default:
+ data->enc_diff = 1;
+ break;
+ }
+ switch (left_.update(
+ wheel_data.is_wheel_touched &&
+ drivers::TouchWheel::isAngleWithin(wheel_data.wheel_position, 64, 32))) {
+ case Trigger::State::kLongPress:
+ events::Ui().Dispatch(ui::internal::BackPressed{});
+ break;
+ default:
+ break;
+ }
}
} // namespace input