Hi guys
sorry for my english, because I'm italian.
I've a problem with the input from keyboard, I set that when S is pressed to
write in the console a string, but when I press it, it compares a lot of times, How can I solve this type of issue? Thank you!
Problem with the input from keyboard
-
- Posts: 363
- Joined: Thu Dec 16, 2010 8:50 pm
- Location: Somewhere in the clouds.. drinking pink lemonade and sunshine..
well it is creating a positive result since you are holding it down. I'm guessing what you want is a single pulse?
ent1ty wrote: success is a matter of concentration and desire
at a cost measure in computer resourcesButler Lampson wrote: all problems in Computer Science can be solved by another level of indirection
Not so easy, no.
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 363
- Joined: Thu Dec 16, 2010 8:50 pm
- Location: Somewhere in the clouds.. drinking pink lemonade and sunshine..
I do not have access to my code atm but what you need is just another kind of input manager that re-dispatches events but uses bool locks to see if that event was already continuously sent. it locks up once it is sent and only unlocks when the event is not being received.
ent1ty wrote: success is a matter of concentration and desire
at a cost measure in computer resourcesButler Lampson wrote: all problems in Computer Science can be solved by another level of indirection
modified from tutorial 4: movement
something like this should work
EDIT: previous message wich I did post half deleted. Really somethimes I am in need of an update myself.
Code: Select all
class MyEventReceiver : public IEventReceiver
{
public:
// This is the one method that we have to implement
virtual bool OnEvent(const SEvent& event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT)
{
// There is one known bug. It will work but when you press
// first the else{...} is executed and then the next time passing
// this if statement the {...}else us run
if( KeyIsDown[ KEY_KEY_S ] )
{
// print the str
KeyIsDown[ KEY_KEY_S ] = false;
} else
{
KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
};
};
return false;
}
MyEventReceiver()
{
for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
KeyIsDown[i] = false;
}
private:
bool KeyIsDown[KEY_KEY_CODES_COUNT];
};
EDIT: previous message wich I did post half deleted. Really somethimes I am in need of an update myself.
Code: Select all
// if you think real code is always interresting, read this line again