[SOLVED]multiple input

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
tank202
Competition winner
Posts: 40
Joined: Mon Jan 21, 2013 8:34 pm
Location: Lithuania, Kaunas

[SOLVED]multiple input

Post by tank202 »

Hi,
I've come across many topics on this problem but I couldn't get decent solution on how to handle multiple inputs.
The problem is that I need my fps character to be able to sprint and when I write such condition :

Code: Select all

if(event.KeyInput.Key == KEY_KEY_W || event.KeyInput.Key == KEY_LSHIFT)
it wont work :(

In the past I've managed to accomplish similar thing but if shift was pressed earlier that the movement key it wouldn't work also.

I think you get what I mean :D - HELP!!! :D
Last edited by tank202 on Thu Mar 07, 2013 8:32 pm, edited 1 time in total.
CuteAlien
Admin
Posts: 9944
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: multiple input

Post by CuteAlien »

There is event.KeyInput.Shift which gives you the information if shift was pressed the moment when that key-event has been generated.
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
tank202
Competition winner
Posts: 40
Joined: Mon Jan 21, 2013 8:34 pm
Location: Lithuania, Kaunas

Re: multiple input

Post by tank202 »

Its no good. If I press 'w' first and the shift, sprint function wont work :(
etreum79
Posts: 42
Joined: Sun Feb 24, 2013 3:56 pm

Re: multiple input

Post by etreum79 »

tank202
Competition winner
Posts: 40
Joined: Mon Jan 21, 2013 8:34 pm
Location: Lithuania, Kaunas

Re: multiple input

Post by tank202 »

Nop, I couldn't understand what the hell they were doing in that forum so I've managed to find a solution:
As the event receiver loops several times before every rendering, I've decided to exclude movement key handling condition when the shift event was processed, so I've implemented such code:

Code: Select all

if(event.KeyInput.Key == KEY_KEY_W && event.KeyInput.PressedDown == true) Keyboard.ForwardKey = true;
else if(event.KeyInput.Key != KEY_LSHIFT) Keyboard.ForwardKey = false;
And from then my sprint was working perfectly. And they lived happily ever after :D
Post Reply