From ec77debc626f714a5745bef9b8f94c83541de105 Mon Sep 17 00:00:00 2001 From: "jean.chalard" Date: Fri, 28 Nov 2008 14:52:12 +0000 Subject: [PATCH] J : * Release holds when key is released. * Fix a bug that would mark the key pressed instead of released when it's read. --- JGE/src/JGE.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/JGE/src/JGE.cpp b/JGE/src/JGE.cpp index d68cb8490..bc3a660de 100644 --- a/JGE/src/JGE.cpp +++ b/JGE/src/JGE.cpp @@ -343,7 +343,7 @@ u32 JGE::ReadButton() { if (gKeyBuffer.empty()) return 0; u32 val = gKeyBuffer.front(); - gHolds &= val; + gHolds &= ~val; gKeyBuffer.pop(); return val; } @@ -385,20 +385,25 @@ void JGE::Run() sceCtrlPeekBufferPositive(&mCtrlPad, 1); for (signed int i = sizeof(gKeyCodeList)/sizeof(gKeyCodeList[0]) - 1; i >= 0; --i) - if (gKeyCodeList[i] & mCtrlPad.Buttons) - { + { + if (gKeyCodeList[i] & mCtrlPad.Buttons) + { + if (!(gKeyCodeList[i] & mOldButtons)) + { + if (!(gHolds & gKeyCodeList[i])) gKeyBuffer.push(gKeyCodeList[i]); + nextInput = repeatDelay; + } + else if (nextInput < 0) + { + if (!(gHolds & gKeyCodeList[i])) gKeyBuffer.push(gKeyCodeList[i]); + nextInput = repeatPeriod; + } + gHolds |= gKeyCodeList[i]; + } + if (!(gKeyCodeList[i] & mCtrlPad.Buttons)) if (!(gKeyCodeList[i] & mOldButtons)) - { - if (!(gHolds & gKeyCodeList[i])) gKeyBuffer.push(gKeyCodeList[i]); - nextInput = repeatDelay; - } - else if (nextInput < 0) - { - if (!(gHolds & gKeyCodeList[i])) gKeyBuffer.push(gKeyCodeList[i]); - nextInput = repeatPeriod; - } - gHolds |= gKeyCodeList[i]; - } + gHolds &= ~gKeyCodeList[i]; + } mOldButtons = mCtrlPad.Buttons; nextInput -= (curr - mLastTime);