diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-04-10 16:56:10 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-04-10 16:56:10 +1000 |
| commit | ed82063af5f83530afa5cfb5bf5bd516f3d05f2a (patch) | |
| tree | f8beba0e107d57bc0324b930d5200fdc405c96c4 /src/input/input_touch_dpad.cpp | |
| parent | 2e59325c22605873bba62c078c196d99c1664590 (diff) | |
| download | tangara-fw-ed82063af5f83530afa5cfb5bf5bd516f3d05f2a.tar.gz | |
WIP decompose our giant LVGL driver into smaller classes
Diffstat (limited to 'src/input/input_touch_dpad.cpp')
| -rw-r--r-- | src/input/input_touch_dpad.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/input/input_touch_dpad.cpp b/src/input/input_touch_dpad.cpp new file mode 100644 index 00000000..a5774ef6 --- /dev/null +++ b/src/input/input_touch_dpad.cpp @@ -0,0 +1,35 @@ +/* + * Copyright 2024 jacqueline <me@jacqueline.id.au> + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#include "input_touch_dpad.hpp" + +#include <cstdint> + +#include "hal/lv_hal_indev.h" + +#include "haptics.hpp" +#include "input_device.hpp" +#include "input_touch_dpad.hpp" +#include "touchwheel.hpp" + +namespace input { + +static inline auto IsAngleWithin(int16_t wheel_angle, + int16_t target_angle, + int threshold) -> bool { + int16_t difference = (wheel_angle - target_angle + 127 + 255) % 255 - 127; + return difference <= threshold && difference >= -threshold; +} + +TouchDPad::TouchDPad(drivers::TouchWheel& wheel) : wheel_(wheel) {} + +auto TouchDPad::read(lv_indev_data_t* data) -> void { + wheel_.Update(); + + // TODO: reimplement +} + +} // namespace input |
