From 33919e9e3f419e13318fa6b8217d8c8dcd86c1eb Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 11 Apr 2024 15:16:35 +1000 Subject: Migrate all existing control schemes to the cool new world --- src/input/include/input_trigger.hpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/input/include/input_trigger.hpp (limited to 'src/input/include/input_trigger.hpp') 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 + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#pragma once + +#include +#include + +#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 touch_time_ms_; + uint16_t times_fired_; +}; + +} // namespace input -- cgit v1.2.3