Code: Select all
class MyEventReceiver : public irr::IEventReceiver
{
// To store if a key is down, I use this private array
bool isDown[irr::KEY_KEY_CODES_COUNT];
public:
// To make sure the keys are initialized to false I do
MyEventReceiver()
{
memset(isDown, 0, sizeof(isDown));
}
virtual bool OnEvent(SEvent event)
{
if (event.EventType == EET_KEY_INPUT_EVENT)
isDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
/* the rest of input parsing ... */
return false;
}
/* One last thing is to take care of is that some key codes
mean multiple key codes (i think): e.g. KEY_CONTROL means
KEY_LCONTROL and KEY_RCONTROL (the code for this buttons is always the same for me, tho).
This would mean that another method with some logic is needed.
Something like :
*/
bool keyIsDown(enum irr::EKEY_CODE notbb_code) {
switch (notbb_code) {
case KEY_CONTROL:
return (isDown[KEY_CONTROL] || isDown[KEY_LCONTROL] || isDown[KEY_RCONTROL]);
/* here would go shifts, alts ... */
default:
return isDown[notbb_code];
}
}
};