Use the latch in dialogs throughout.

This makes it so that rapid fire works for them as well.
This commit is contained in:
Unknown W. Brackets 2014-02-02 15:47:25 -08:00
parent c9c179d233
commit 77acd0729f
6 changed files with 18 additions and 15 deletions

View File

@ -18,6 +18,7 @@
#include "i18n/i18n.h"
#include "Common/ChunkFile.h"
#include "Core/HLE/sceCtrl.h"
#include "Core/Util/PPGeDraw.h"
#include "Core/Dialog/PSPDialog.h"
@ -124,14 +125,20 @@ pspUtilityDialogCommon *PSPDialog::GetCommonParam()
return 0;
}
void PSPDialog::UpdateButtons()
{
lastButtons = __CtrlPeekButtons();
buttons = __CtrlReadLatch();
}
bool PSPDialog::IsButtonPressed(int checkButton)
{
return !isFading && !(lastButtons & checkButton) && (buttons & checkButton);
return !isFading && (buttons & checkButton);
}
bool PSPDialog::IsButtonHeld(int checkButton, int &framesHeld, int framesHeldThreshold, int framesHeldRepeatRate)
{
bool btnWasHeldLastFrame = (lastButtons & checkButton) && (buttons & checkButton);
bool btnWasHeldLastFrame = (lastButtons & checkButton) && (__CtrlPeekButtons() & checkButton);
if (!isFading && btnWasHeldLastFrame) {
framesHeld++;
}

View File

@ -78,6 +78,7 @@ public:
void StartDraw();
void EndDraw();
protected:
void UpdateButtons();
bool IsButtonPressed(int checkButton);
bool IsButtonHeld(int checkButton, int &framesHeld, int framesHeldThreshold = 30, int framesHeldRepeatRate = 10);
// The caption override is assumed to have a size of 64 bytes.

View File

@ -131,7 +131,7 @@ int PSPMsgDialog::Init(unsigned int paramAddr)
status = SCE_UTILITY_STATUS_INITIALIZE;
lastButtons = __CtrlPeekButtons();
UpdateButtons();
StartFade(true);
return 0;
}
@ -222,10 +222,9 @@ int PSPMsgDialog::Update(int animSpeed)
}
else
{
UpdateButtons();
UpdateFade(animSpeed);
buttons = __CtrlPeekButtons();
okButtonImg = I_CIRCLE;
cancelButtonImg = I_CROSS;
okButtonFlag = CTRL_CIRCLE;
@ -280,7 +279,6 @@ int PSPMsgDialog::Update(int animSpeed)
EndDraw();
lastButtons = buttons;
messageDialog.result = 0;
}

View File

@ -49,7 +49,7 @@ int PSPNetconfDialog::Init(u32 paramAddr) {
status = SCE_UTILITY_STATUS_INITIALIZE;
// Eat any keys pressed before the dialog inited.
__CtrlReadLatch();
UpdateButtons();
StartFade(true);
return 0;
@ -66,7 +66,7 @@ void PSPNetconfDialog::DrawBanner() {
}
int PSPNetconfDialog::Update(int animSpeed) {
buttons = __CtrlPeekButtons();
UpdateButtons();
I18NCategory *d = GetI18NCategory("Dialog");
I18NCategory *err = GetI18NCategory("Error");
const float WRAP_WIDTH = 254.0f;

View File

@ -279,7 +279,7 @@ int PSPOskDialog::Init(u32 oskPtr)
languageMapping = GetLangValuesMapping();
// Eat any keys pressed before the dialog inited.
__CtrlReadLatch();
UpdateButtons();
StartFade(true);
return 0;
@ -860,7 +860,7 @@ int PSPOskDialog::Update(int animSpeed)
const int framesHeldThreshold = 10;
const int framesHeldRepeatRate = 5;
buttons = __CtrlPeekButtons();
UpdateButtons();
int selectedRow = selectedChar / numKeyCols[currentKeyboard];
int selectedExtra = selectedChar % numKeyCols[currentKeyboard];
@ -1062,7 +1062,6 @@ int PSPOskDialog::Update(int animSpeed)
oskParams->base.result = 0;
oskParams->fields[0].result = PSP_UTILITY_OSK_RESULT_CHANGED;
lastButtons = buttons;
return 0;
}

View File

@ -176,7 +176,7 @@ int PSPSaveDialog::Init(int paramAddr)
status = (int)retval < 0 ? SCE_UTILITY_STATUS_SHUTDOWN : SCE_UTILITY_STATUS_INITIALIZE;
lastButtons = __CtrlPeekButtons();
UpdateButtons();
StartFade(true);
/*INFO_LOG(SCEUTILITY,"Dump Param :");
@ -553,7 +553,7 @@ int PSPSaveDialog::Update(int animSpeed)
param.SetPspParam(&request);
}
buttons = __CtrlPeekButtons();
UpdateButtons();
UpdateFade(animSpeed);
okButtonImg = I_CIRCLE;
@ -977,8 +977,6 @@ int PSPSaveDialog::Update(int animSpeed)
break;
}
lastButtons = buttons;
if (status == SCE_UTILITY_STATUS_FINISHED)
Memory::Memcpy(requestAddr, &request, request.common.size);