Page 2 of 2

Posted: Sat Mar 12, 2005 3:29 pm
by Beam
Salutes

Ok I do this right after main starts:

CIrrLichtEvent * keyHandler;
keyHandler->Init();

If I just create it (CIrrLichtEvent keyHandler; = no pointer) i get unresolved external symbol.

I use pointer for now, and it compiles, but it doesnt work. Do I need to run something each frame? Simply typing this in the loop do not work:

if(keyHandler->IsKeyDown(KEY_KEY_W))
players[0]->gold+=50;

I must have missed something... Plz help any1. It also warns me about keyHandler not being initialized. But it is right?
Beam

Re: to use multi-key and mouse-button

Posted: Tue Mar 22, 2005 7:19 am
by Guest
lifetree wrote: GOOD LUCK!
That is probably all nice and working code, but how do I use it the loop? Tried checking for IsKeyDown but that didn't work.

Posted: Fri Mar 25, 2005 6:38 pm
by dopamine
Try to implement a method like below
//-------------------------------------
void CIrrLichtEvent::ProcessInput()
{
if (IsKeyDown(KEY_KEY_W))
{
actions...
}

if (IsKeyDown(KEY_KEY_A))
{
actions...
}
...
}
//-------------------------------------
Then in the Irrlicht main loop call it
to handle your events. For example:
...
while(device->run())
if (device->isWindowActive())
{
irrEventRec.ProcessInput();
...

i found something useful

Posted: Sun Mar 27, 2005 8:40 am
by mike (not a member)
ok oddly enough i had a problem where i'd press right and the thing would perform as expected.. btw im using the first method mentioned in this post. when i pressed left or up it did nothing. i loaded up my debugger and put a watch on event.KeyInput.Key and lo and behold it turns out that the event handler in the engine reads my keyboard's left arrow key as KEY_KEY_A. if you're having problems like this i suggest you use a debugger to watch te event.KeyInput.Key variable to see what your keys on your keyboard are actuall y doing in the engine.

hope this helps someone. see ya

Posted: Sun Mar 27, 2005 9:41 am
by bal
Do you have another kind of keyboard than QWERTY/AZERTY ?

Posted: Thu May 24, 2007 12:42 am
by GameDude
This is a good start to learning the key input of the Irrlicht

Posted: Mon Jun 18, 2007 5:05 pm
by dudMaN
Thanks, kaless!!

awesome tutorial thing, and finally my key input works :D but now, its always returning true, which means i cant send input to the camera :(

does this mean i need to do

//OnEvent
if(event.EventType == irr::EET_KEY_INPUT_EVENT
&& event.KeyInput.Key != KEY_UP && event.KeyInput.Key != KEY_DOWN && event.KeyInput.Key != KEY_LEFT && event.KeyInput.Key != KEY_RIGHT){
keys[event.KeyInput.Key] = event.KeyInput.PressedDown;
return true;
}

?

Thanks!

EDIT: i can probably just do "return false;" instead of "return true;" so the camera cares too.

-dudMan

Posted: Sun Jul 29, 2007 1:40 pm
by BlindSide
Boogle wrote:Hehe, not in C++! It happily references as far outside of your array as you want.
Wtf thats certainly not true... Accessing outside of the array bounds would yeild a memory access error.

Posted: Sun Jul 29, 2007 10:33 pm
by hybrid
That is true. The only problems that may arise are due to your OS. If C++ would restrict the access when out-of-bounds you'd raise an exception, not a segfault.

Posted: Mon Jul 30, 2007 5:11 am
by BlindSide
Goodpoint

Posted: Wed Mar 17, 2010 2:56 am
by sosssego
When i used it with OpenGL and GLut, dont using Irrlicht i used 2 functions to "receive" the event.
one for KeyDown, and another to KeyUp, so i dont need to run false for all keys all the time.
And glutIgnoreKeyRepeat(true); so i dont run the event when nothing was changed, if you press a key and dont release it, the KeyUp will be called 1 time, all that you need is check for your key, if it is set up or down in your bool key[] array.

There is an way to do that in Irrlicht?
There is keyup(), keydown(), and glutIgnoreKeyRepeat(true) like functions?

Ty

sosssego