summaryrefslogtreecommitdiff
path: root/src/input/input_touch_dpad.cpp
blob: a5774ef66d706ce1d7e06e90a6d2e3499fa121bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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