Files
pico-launcher/arm9/source/gui/input/InputRepeater.h
2025-11-25 17:41:31 +01:00

32 lines
848 B
C++

#pragma once
#include "InputProvider.h"
/// @brief Input provider that wraps another input provider and adds key repetition on top of it.
class InputRepeater : public InputProvider
{
public:
InputRepeater(InputProvider* inputProvider, InputKey repeatMask, u16 firstRepeatDelay, u16 nextRepeatDelay)
: _inputProvider(inputProvider), _state(State::Idle)
, _frameCounter(0), _repeatMask(repeatMask)
, _firstRepeatDelayFrames(firstRepeatDelay)
, _nextRepeatDelayFrames(nextRepeatDelay) { }
void Update() override;
void Reset() override;
private:
enum class State
{
Idle,
FirstRepeat,
NextRepeat
};
InputProvider* _inputProvider;
State _state;
u16 _frameCounter;
InputKey _repeatMask;
u16 _firstRepeatDelayFrames;
u16 _nextRepeatDelayFrames;
};