mirror of
https://github.com/LNH-team/pico-launcher.git
synced 2026-06-02 00:56:55 +02:00
Initial commit
This commit is contained in:
58
arm9/source/gui/input/InputRepeater.cpp
Normal file
58
arm9/source/gui/input/InputRepeater.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#include "common.h"
|
||||
#include "InputRepeater.h"
|
||||
|
||||
void InputRepeater::Update()
|
||||
{
|
||||
_inputProvider->Update();
|
||||
InputKey curKeys = _inputProvider->GetCurrentKeys();
|
||||
InputKey repKeys = InputKey::None;
|
||||
if (_state == State::Idle)
|
||||
{
|
||||
if (static_cast<bool>(curKeys & _repeatMask))
|
||||
{
|
||||
_state = State::FirstRepeat;
|
||||
_frameCounter = 0;
|
||||
repKeys = curKeys & _repeatMask;
|
||||
}
|
||||
}
|
||||
else if (_state == State::FirstRepeat)
|
||||
{
|
||||
if (static_cast<bool>(curKeys & _repeatMask))
|
||||
{
|
||||
if (++_frameCounter >= _firstRepeatDelayFrames)
|
||||
{
|
||||
_state = State::NextRepeat;
|
||||
_frameCounter = 0;
|
||||
repKeys = curKeys & _repeatMask;
|
||||
}
|
||||
}
|
||||
else
|
||||
_state = State::Idle;
|
||||
}
|
||||
else if (_state == State::NextRepeat)
|
||||
{
|
||||
if (static_cast<bool>(curKeys & _repeatMask))
|
||||
{
|
||||
if (++_frameCounter >= _nextRepeatDelayFrames)
|
||||
{
|
||||
_frameCounter = 0;
|
||||
repKeys = curKeys & _repeatMask;
|
||||
}
|
||||
}
|
||||
else
|
||||
_state = State::Idle;
|
||||
}
|
||||
|
||||
InputKey lastRepKeys = _currentKeys & _repeatMask;
|
||||
_currentKeys = curKeys | repKeys;
|
||||
_triggeredKeys = _inputProvider->GetTriggeredKeys() | repKeys;
|
||||
_releasedKeys = _inputProvider->GetReleasedKeys() | (lastRepKeys & (lastRepKeys ^ repKeys));
|
||||
}
|
||||
|
||||
void InputRepeater::Reset()
|
||||
{
|
||||
InputProvider::Reset();
|
||||
_inputProvider->Reset();
|
||||
_state = State::Idle;
|
||||
_frameCounter = 0;
|
||||
}
|
||||
Reference in New Issue
Block a user