* Release holds when key is released.
* Fix a bug that would mark the key pressed instead of released when it's
  read.
This commit is contained in:
jean.chalard
2008-11-28 14:52:12 +00:00
parent 46669050ee
commit ec77debc62
+6 -1
View File
@@ -343,7 +343,7 @@ u32 JGE::ReadButton()
{ {
if (gKeyBuffer.empty()) return 0; if (gKeyBuffer.empty()) return 0;
u32 val = gKeyBuffer.front(); u32 val = gKeyBuffer.front();
gHolds &= val; gHolds &= ~val;
gKeyBuffer.pop(); gKeyBuffer.pop();
return val; return val;
} }
@@ -385,6 +385,7 @@ void JGE::Run()
sceCtrlPeekBufferPositive(&mCtrlPad, 1); sceCtrlPeekBufferPositive(&mCtrlPad, 1);
for (signed int i = sizeof(gKeyCodeList)/sizeof(gKeyCodeList[0]) - 1; i >= 0; --i) 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 (!(gKeyCodeList[i] & mOldButtons))
@@ -399,6 +400,10 @@ void JGE::Run()
} }
gHolds |= gKeyCodeList[i]; gHolds |= gKeyCodeList[i];
} }
if (!(gKeyCodeList[i] & mCtrlPad.Buttons))
if (!(gKeyCodeList[i] & mOldButtons))
gHolds &= ~gKeyCodeList[i];
}
mOldButtons = mCtrlPad.Buttons; mOldButtons = mCtrlPad.Buttons;
nextInput -= (curr - mLastTime); nextInput -= (curr - mLastTime);