J :
* 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:
@@ -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,20 +385,25 @@ 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 (!(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 (!(gKeyCodeList[i] & mOldButtons))
|
||||||
{
|
gHolds &= ~gKeyCodeList[i];
|
||||||
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];
|
|
||||||
}
|
|
||||||
mOldButtons = mCtrlPad.Buttons;
|
mOldButtons = mCtrlPad.Buttons;
|
||||||
|
|
||||||
nextInput -= (curr - mLastTime);
|
nextInput -= (curr - mLastTime);
|
||||||
|
|||||||
Reference in New Issue
Block a user