Yo, a nooby problem/question here. Is it possible to make a single key press/key release action in event receiver? Bcz now I have a key press/release which tend to spam my key.. a lot... If yes, any suggestions?
Thanks in advance!
Single KeyPress
Sorry no. You have to handle that currently yourself. You might be able to disable key-repeat with OS system-functions. I think we had a thread about that recently and I think we should offer either some way to disable that in Irrlicht or add another flag to the key-event so people find out if it's a repeat key or not (but not sure right now if that info is easy to get on all systems - I think we can get it on Windows, not sure on X11 right now).
So if you add a feature request for that into the feature-request tracker you can help us not to forget that.
So if you add a feature request for that into the feature-request tracker you can help us not to forget that.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
and until then you could do something similar to this:
so it triggers onRelease
Code: Select all
bool CStateMenu::OnKeyInputEvent(const irr::SEvent &e)
{
if (!e.KeyInput.PressedDown)
{
switch (e.KeyInput.Key)
{
case KEY_ESCAPE :
{
// something
} break;
}
}
keys[e.KeyInput.Key] = e.KeyInput.PressedDown;
return false;
}
Never take advice from someone who likes to give advice, so take my advice and don't take it.
just had another idea which is pretty much exactly what you want:
you just need a bool var in your eventreceiver (set false on startup in the constructor)
you just need a bool var in your eventreceiver (set false on startup in the constructor)
Code: Select all
// member var of eventreceiver
bool OnceDone = false;
Code: Select all
// key input function
bool OnKeyInputEvent(const irr::SEvent &e)
{
if (!e.KeyInput.PressedDown) OnceDone = false;
if (e.KeyInput.PressedDown && !OnceDone)
{
switch (e.KeyInput.Key)
{
case KEY_ESCAPE :
{
// do something here
OnceDone = true;
} break;
}
}
return false;
}
Never take advice from someone who likes to give advice, so take my advice and don't take it.