Hello everybody. I have a problem with keys in Irrlicht. When I want to close my program with the ESC key, it doesn't respond to it. Actually, every action I want to do doesn't work. I've tried it witch several keys and codes, but it doesn't seem to work. This is my code for shutting down the program:
...
IrrlichtDevice *device = NULL;
SEvent event;
scene::ICameraSceneNode* camera = 0;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (camera)
return camera->OnEvent(event);
if (event.EventType == EET_KEY_INPUT_EVENT &&
event.KeyInput.Key == KEY_ESCAPE &&
event.KeyInput.PressedDown == false)
{
// user wants to quit.
device->closeDevice();
}
return false;
}
};
...
I put this code before all the other code (except for namespaces and headers).
Does somebody know what's wrong with it?
Thanks.
Key input doesn't work
-
MedievalMagic13
This is my code at the moment (if I did it the right way):
SEvent event;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == EET_KEY_INPUT_EVENT &&
event.KeyInput.Key == KEY_ESCAPE &&
event.KeyInput.PressedDown == false)
{
// user wants to quit.
device->closeDevice();
}
if (camera)
return camera->OnEvent(event);
return false;
}
};
Did I do something wrong (I hope so)? If so, could somebody please show me his/her code about how to close the programs?
-
MedievalMagic13