Getting the keyboard input without using events

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Raven
Posts: 1
Joined: Mon Jan 19, 2004 8:32 pm

Getting the keyboard input without using events

Post by Raven »

hello, heres a newbie question,
can I get the Keyboard input from within a loop instead of using the event class... Something like this:

Code: Select all

while(...) {
if (/*currently pressed key, say... "KeyInput::Key"*/ == KEY_W)  // thats a guess
{ /* code for the pressed key */ }
}
that would be very usefull to port my old app to Irrlicht
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

what I do for 'currently pressed' keys, is to store a bool keys[] array,

when a key event happens, i set the key in keys[] to true or false

then in my update function, simply refer to the keys[] array.

a code example of this is listed in the howto forum
a screen cap is worth 0x100000 DWORDS
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

The example Keless pointed out is perfect for key polling via Irrlicht. Though, you can craft your own input handler external from Irrlicht. Since Irrlicht is a graphics engine only, a true purist would say that even the Event handler shouldn't be part of the core. But it is nice that it is.

Now that I think of it, there are libraries for networking, sound, physics, AI, etc... out there, but I can't think of a single Input library. Time to do some googlin'.

Anyone know of a LGPL, MIT, or similiarly licensed Input handling library? One that handles key, mouse, and controller input like Microsoft's DirectInput?
Crud, how do I do this again?
stodge
Posts: 216
Joined: Fri Dec 05, 2003 5:57 pm

Post by stodge »

saigumi wrote:The example Keless pointed out is perfect for key polling via Irrlicht. Though, you can craft your own input handler external from Irrlicht. Since Irrlicht is a graphics engine only, a true purist would say that even the Event handler shouldn't be part of the core. But it is nice that it is.

Now that I think of it, there are libraries for networking, sound, physics, AI, etc... out there, but I can't think of a single Input library. Time to do some googlin'.

Anyone know of a LGPL, MIT, or similiarly licensed Input handling library? One that handles key, mouse, and controller input like Microsoft's DirectInput?
SDL?
carb

Post by carb »

The thing though is, if SDL didn't create the windowing context, how does it know where in the window (controlled by Irrlicht) the mouse is?

- Ben
Post Reply