i'm trying to handle some keyboard inputs but it seems irrlicht just doesn't want to listen to my keyboard!
Everything runs fine but it's not recognizing any keypresses at all no matter what i try. here is my code:
Code: Select all
class MyEventReceiver : public IEventReceiver
{
u8 keys[KEY_KEY_CODES_COUNT];
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT)
if (event.KeyInput.PressedDown && keys[event.KeyInput.Key]==0 ) {
keys[event.KeyInput.Key]=1;
}
if (!event.KeyInput.PressedDown && keys[event.KeyInput.Key]!=0) {
keys[event.KeyInput.Key]=0;
}
return true;
}
bool isKeyDown(u8 keycode) {
if (keys[keycode]!=0)
return true;
return false;
}
bool isKeyPressed(u8 keycode) {
if (keys[keycode]==1) {
keys[keycode]=2;
return true;
}
return false;
}
void resetKeyboard(void) {
int i;
// set initial keystates to false
for (i=0; i<KEY_KEY_CODES_COUNT; i++)
keys[i]=0;
}
};
Code: Select all
int main()
{
MyEventReceiver receiver;
IrrlichtDevice *device = createDevice(video::EDT_DIRECTX8,
core::dimension2d<s32>(640, 480), 16, false, false, &receiver);
device->setWindowCaption(L"Irrlicht Engine - 2D Graphics Demo");
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
Code: Select all
receiver.resetKeyboard();
if (receiver.isKeyDown(KEY_LCONTROL))
repelState = REPEL_GO;
thanks!