diff --git a/Core/Dialog/PSPDialog.cpp b/Core/Dialog/PSPDialog.cpp index daa80be1d..a8ac026d4 100644 --- a/Core/Dialog/PSPDialog.cpp +++ b/Core/Dialog/PSPDialog.cpp @@ -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++; } diff --git a/Core/Dialog/PSPDialog.h b/Core/Dialog/PSPDialog.h index 02a8bfbea..df3039532 100644 --- a/Core/Dialog/PSPDialog.h +++ b/Core/Dialog/PSPDialog.h @@ -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. diff --git a/Core/Dialog/PSPMsgDialog.cpp b/Core/Dialog/PSPMsgDialog.cpp index 9bdb8c5b0..962fff854 100755 --- a/Core/Dialog/PSPMsgDialog.cpp +++ b/Core/Dialog/PSPMsgDialog.cpp @@ -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; } diff --git a/Core/Dialog/PSPNetconfDialog.cpp b/Core/Dialog/PSPNetconfDialog.cpp index 4c6de7e98..cd2fb0aaa 100644 --- a/Core/Dialog/PSPNetconfDialog.cpp +++ b/Core/Dialog/PSPNetconfDialog.cpp @@ -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; diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index 3405a5337..46aa30e5f 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -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; } diff --git a/Core/Dialog/PSPSaveDialog.cpp b/Core/Dialog/PSPSaveDialog.cpp index 13e11435d..ede49fd7a 100755 --- a/Core/Dialog/PSPSaveDialog.cpp +++ b/Core/Dialog/PSPSaveDialog.cpp @@ -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);