diff options
| author | cooljqln <cooljqln@noreply.codeberg.org> | 2024-04-11 07:02:53 +0000 |
|---|---|---|
| committer | cooljqln <cooljqln@noreply.codeberg.org> | 2024-04-11 07:02:53 +0000 |
| commit | dd1ea595a7753706d4fa5f19b66f3dc1cbd56a02 (patch) | |
| tree | 60bfa4569af0f9506ccffe85f19e89bbe2a83332 /src/input/include/input_trigger.hpp | |
| parent | f580928cbab797e4e8a3eae5ae1c0b18b8066066 (diff) | |
| parent | 33919e9e3f419e13318fa6b8217d8c8dcd86c1eb (diff) | |
| download | tangara-fw-dd1ea595a7753706d4fa5f19b66f3dc1cbd56a02.tar.gz | |
Merge pull request 'jqln/input-devices' (#62) from jqln/input-devices into main
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/62
Reviewed-by: ailurux <ailurux@noreply.codeberg.org>
Diffstat (limited to 'src/input/include/input_trigger.hpp')
| -rw-r--r-- | src/input/include/input_trigger.hpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/input/include/input_trigger.hpp b/src/input/include/input_trigger.hpp new file mode 100644 index 00000000..599b796b --- /dev/null +++ b/src/input/include/input_trigger.hpp @@ -0,0 +1,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 |
