summaryrefslogtreecommitdiff
path: root/src/input/include/input_trigger.hpp
blob: 599b796b62a0fc3e29f5a851e5d9cea22157a63e (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
36
37
/*
 * Copyright 2024 jacqueline <me@jacqueline.id.au>
 *
 * SPDX-License-Identifier: GPL-3.0-only
 */

#pragma once

#include <cstdint>
#include <optional>

#include "hal/lv_hal_indev.h"

namespace input {

const uint16_t kLongPressDelayMs = LV_INDEV_DEF_LONG_PRESS_TIME;
const uint16_t kRepeatDelayMs = LV_INDEV_DEF_LONG_PRESS_REP_TIME;

class Trigger {
 public:
  enum class State {
    kNone,
    kClick,
    kLongPress,
    kRepeatPress,
  };

  Trigger();

  auto update(bool is_pressed) -> State;

 private:
  std::optional<uint64_t> touch_time_ms_;
  uint16_t times_fired_;
};

}  // namespace input