diff options
| author | cooljqln <cooljqln@noreply.codeberg.org> | 2024-05-03 04:48:17 +0000 |
|---|---|---|
| committer | cooljqln <cooljqln@noreply.codeberg.org> | 2024-05-03 04:48:17 +0000 |
| commit | 3ceb8025ee4330c177101ed30ec17dfb0002f41e (patch) | |
| tree | 58350210f15df7d00d967cac6f30eeceeb031a3c /src/tangara/input/input_trigger.hpp | |
| parent | 964da15a0b84f8e5f00e8abac2f7dfda0bf60488 (diff) | |
| parent | 9fafd797a5504f458b5fcae4a1d28a68da936315 (diff) | |
| download | tangara-fw-3ceb8025ee4330c177101ed30ec17dfb0002f41e.tar.gz | |
Merge pull request 'Break dependency cycles with our components by merging co-dependent components together' (#68) from jqln/component-merge into main
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/68
Diffstat (limited to 'src/tangara/input/input_trigger.hpp')
| -rw-r--r-- | src/tangara/input/input_trigger.hpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/tangara/input/input_trigger.hpp b/src/tangara/input/input_trigger.hpp new file mode 100644 index 00000000..bcafa8ad --- /dev/null +++ b/src/tangara/input/input_trigger.hpp @@ -0,0 +1,42 @@ +/* + * 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 kDoubleClickDelayMs = 500; +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, + kDoubleClick, + kLongPress, + kRepeatPress, + }; + + Trigger(); + + auto update(bool is_pressed) -> State; + + private: + std::optional<uint64_t> touch_time_ms_; + bool was_pressed_; + + bool was_double_click_; + uint16_t times_long_pressed_; +}; + +} // namespace input |
