Fork of Tangara with customizations
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
tangara-fw/src/input/include/input_trigger.hpp

42 lines
722 B

/*
* 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