Implement sig changes (GetAnyKey()), GetAnyKeyPress()
This commit is contained in:
parent
3280f71307
commit
d0a1d2e29c
@ -197,7 +197,7 @@
|
|||||||
|
|
||||||
Author
|
Author
|
||||||
~~~~~~
|
~~~~~~
|
||||||
David Barr, aka javidx9, ©OneLoneCoder 2018, 2019, 2020, 2021, 2022
|
David Barr, aka javidx9, <EFBFBD>OneLoneCoder 2018, 2019, 2020, 2021, 2022
|
||||||
*/
|
*/
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
@ -304,6 +304,11 @@
|
|||||||
+GetScreenSize()
|
+GetScreenSize()
|
||||||
+olc::Sprite::Size() - returns size of sprite in vector format
|
+olc::Sprite::Size() - returns size of sprite in vector format
|
||||||
|
|
||||||
|
SIG Updates:
|
||||||
|
The following additions are included in Sig's version of the PGE header (this is a sig version)
|
||||||
|
+GetAnyKey() - Returns when a key is activated
|
||||||
|
+GetAnyKeyPress() - Returns when a key is pressed down (and if a keyboard key, which key it was)
|
||||||
|
|
||||||
!! Apple Platforms will not see these updates immediately - Sorry, I dont have a mac to test... !!
|
!! Apple Platforms will not see these updates immediately - Sorry, I dont have a mac to test... !!
|
||||||
!! Volunteers willing to help appreciated, though PRs are manually integrated with credit !!
|
!! Volunteers willing to help appreciated, though PRs are manually integrated with credit !!
|
||||||
*/
|
*/
|
||||||
@ -933,6 +938,8 @@ namespace olc
|
|||||||
virtual bool OnUserUpdate(float fElapsedTime);
|
virtual bool OnUserUpdate(float fElapsedTime);
|
||||||
// Called once on application termination, so you can be one clean coder
|
// Called once on application termination, so you can be one clean coder
|
||||||
virtual bool OnUserDestroy();
|
virtual bool OnUserDestroy();
|
||||||
|
virtual void GetAnyKey();
|
||||||
|
virtual void GetAnyKeyPress(olc::Key pressedKey);
|
||||||
|
|
||||||
// Called when a text entry is confirmed with "enter" key
|
// Called when a text entry is confirmed with "enter" key
|
||||||
virtual void OnTextEntryComplete(const std::string& sText);
|
virtual void OnTextEntryComplete(const std::string& sText);
|
||||||
@ -3325,6 +3332,9 @@ namespace olc
|
|||||||
bool PixelGameEngine::OnUserDestroy()
|
bool PixelGameEngine::OnUserDestroy()
|
||||||
{ return true; }
|
{ return true; }
|
||||||
|
|
||||||
|
void PixelGameEngine::GetAnyKey(){};
|
||||||
|
void PixelGameEngine::GetAnyKeyPress(olc::Key pressedKey){};
|
||||||
|
|
||||||
void PixelGameEngine::OnTextEntryComplete(const std::string& sText) { UNUSED(sText); }
|
void PixelGameEngine::OnTextEntryComplete(const std::string& sText) { UNUSED(sText); }
|
||||||
bool PixelGameEngine::OnConsoleCommand(const std::string& sCommand) { UNUSED(sCommand); return false; }
|
bool PixelGameEngine::OnConsoleCommand(const std::string& sCommand) { UNUSED(sCommand); return false; }
|
||||||
|
|
||||||
@ -3472,6 +3482,8 @@ namespace olc
|
|||||||
// Compare hardware input states from previous frame
|
// Compare hardware input states from previous frame
|
||||||
auto ScanHardware = [&](HWButton* pKeys, bool* pStateOld, bool* pStateNew, uint32_t nKeyCount)
|
auto ScanHardware = [&](HWButton* pKeys, bool* pStateOld, bool* pStateNew, uint32_t nKeyCount)
|
||||||
{
|
{
|
||||||
|
bool pressed=false;
|
||||||
|
int key;
|
||||||
for (uint32_t i = 0; i < nKeyCount; i++)
|
for (uint32_t i = 0; i < nKeyCount; i++)
|
||||||
{
|
{
|
||||||
pKeys[i].bPressed = false;
|
pKeys[i].bPressed = false;
|
||||||
@ -3480,6 +3492,8 @@ namespace olc
|
|||||||
{
|
{
|
||||||
if (pStateNew[i])
|
if (pStateNew[i])
|
||||||
{
|
{
|
||||||
|
pressed=true;
|
||||||
|
key=i;
|
||||||
pKeys[i].bPressed = !pKeys[i].bHeld;
|
pKeys[i].bPressed = !pKeys[i].bHeld;
|
||||||
pKeys[i].bHeld = true;
|
pKeys[i].bHeld = true;
|
||||||
}
|
}
|
||||||
@ -3488,9 +3502,14 @@ namespace olc
|
|||||||
pKeys[i].bReleased = true;
|
pKeys[i].bReleased = true;
|
||||||
pKeys[i].bHeld = false;
|
pKeys[i].bHeld = false;
|
||||||
}
|
}
|
||||||
|
GetAnyKey();
|
||||||
}
|
}
|
||||||
pStateOld[i] = pStateNew[i];
|
pStateOld[i] = pStateNew[i];
|
||||||
}
|
}
|
||||||
|
if (pressed) {
|
||||||
|
if (keyboard) {GetAnyKeyPress((olc::Key)key);}
|
||||||
|
else {GetAnyKeyPress(olc::Key::NONE);}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ScanHardware(pKeyboardState, pKeyOldState, pKeyNewState, 256);
|
ScanHardware(pKeyboardState, pKeyOldState, pKeyNewState, 256);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user