Allow held directional buttons to scroll up and down the list repeatedly.

This commit is contained in:
The Dax 2013-12-08 20:15:35 -05:00
parent bd1d4e2d92
commit 814a81b692
3 changed files with 26 additions and 2 deletions

View File

@ -128,6 +128,25 @@ bool PSPDialog::IsButtonPressed(int checkButton)
return !isFading && !(lastButtons & checkButton) && (buttons & checkButton);
}
bool PSPDialog::IsButtonHeld(int checkButton, int &framesHeld)
{
bool btnWasHeldLastFrame = (lastButtons & checkButton) && (buttons & checkButton);
if (!isFading && btnWasHeldLastFrame) {
framesHeld++;
}
else {
framesHeld = 0;
return false;
}
// It's considered held for dialog purposes after 30 frames (~0.5 seconds).
// Seems to give the best responsiveness. Maybe this should be configurable?
if (framesHeld >= 30 && ((framesHeld % 10) == 0))
return true;
return false;
}
void PSPDialog::DisplayButtons(int flags)
{
I18NCategory *d = GetI18NCategory("Dialog");

View File

@ -79,6 +79,7 @@ public:
void EndDraw();
protected:
bool IsButtonPressed(int checkButton);
bool IsButtonHeld(int checkButton, int &framesHeld);
void DisplayButtons(int flags);
void StartFade(bool fadeIn_);

View File

@ -269,6 +269,9 @@ void PSPSaveDialog::DisplayBanner(int which)
void PSPSaveDialog::DisplaySaveList(bool canMove)
{
int displayCount = 0;
static int upFramesHeld = 0;
static int downFramesHeld = 0;
for (int i = 0; i < param.GetFilenameCount(); i++)
{
int textureColor = 0xFFFFFFFF;
@ -312,9 +315,10 @@ void PSPSaveDialog::DisplaySaveList(bool canMove)
}
if (canMove) {
if (IsButtonPressed(CTRL_UP) && currentSelectedSave > 0)
if ( (IsButtonPressed(CTRL_UP) || IsButtonHeld(CTRL_UP, upFramesHeld)) && currentSelectedSave > 0)
currentSelectedSave--;
else if (IsButtonPressed(CTRL_DOWN) && currentSelectedSave < (param.GetFilenameCount()-1))
else if ( (IsButtonPressed(CTRL_DOWN) || IsButtonHeld(CTRL_DOWN, downFramesHeld)) && currentSelectedSave < (param.GetFilenameCount() - 1))
currentSelectedSave++;
}
}