From e69e8446237f31b1518838456460fe98000cfe7b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 28 May 2018 17:08:55 -0700 Subject: [PATCH] Ctrl: Always mark non-user buttons released. This matches behavior on real firmware and fixes a test failure. --- Core/HLE/sceCtrl.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Core/HLE/sceCtrl.cpp b/Core/HLE/sceCtrl.cpp index 1ef00dbdaf87..1b552a419189 100644 --- a/Core/HLE/sceCtrl.cpp +++ b/Core/HLE/sceCtrl.cpp @@ -503,18 +503,20 @@ static int sceCtrlPeekBufferNegative(u32 ctrlDataPtr, u32 nBufs) return done; } -void __CtrlWriteUserLatch(CtrlLatch *userLatch) { +static void __CtrlWriteUserLatch(CtrlLatch *userLatch, int bufs) { *userLatch = latch; userLatch->btnBreak &= CTRL_MASK_USER; userLatch->btnMake &= CTRL_MASK_USER; userLatch->btnPress &= CTRL_MASK_USER; - userLatch->btnRelease &= CTRL_MASK_USER; + if (bufs > 0) { + userLatch->btnRelease |= CTRL_MASK_USER; + } } static u32 sceCtrlPeekLatch(u32 latchDataPtr) { auto userLatch = PSPPointer::Create(latchDataPtr); if (userLatch.IsValid()) { - __CtrlWriteUserLatch(userLatch); + __CtrlWriteUserLatch(userLatch, ctrlLatchBufs); } return hleLogSuccessI(SCECTRL, ctrlLatchBufs); } @@ -522,7 +524,7 @@ static u32 sceCtrlPeekLatch(u32 latchDataPtr) { static u32 sceCtrlReadLatch(u32 latchDataPtr) { auto userLatch = PSPPointer::Create(latchDataPtr); if (userLatch.IsValid()) { - __CtrlWriteUserLatch(userLatch); + __CtrlWriteUserLatch(userLatch, ctrlLatchBufs); } return hleLogSuccessI(SCECTRL, __CtrlResetLatch()); }