SFML community forums
Help => General => Topic started by: nullGrind on February 01, 2010, 06:37:33 pm
-
Hello Guys its me again.
I wonder if it is possible to have more then 2 parallel Keyboard-Inputs at once.
I tried Eventlistener triggering bool variables and i also tried the (Game.GetInput().IsKeyDown(sf::Key::M)) option. But somehow SFML is only reading two pressed keys at once.
For example when im accelerating and steering i cant shoot at the same time or when im shooting and accelerating im not able to steer anylonger.
-
Are you saying that when you press multiple keys at the same time, some of them are ignored?
-
Yes exactly. And it always depends on the order im pressing the keys. When i first press accelerate (and keep it pressed) then steer i cannot shot. When i first hold steer, then shoot i cannot accelerate.
here is some code:
if (Game.GetInput().IsKeyDown(sf::Key::Right))
direction -= rotateSpeed;
if (Game.GetInput().IsKeyDown(sf::Key::Left))
direction += rotateSpeed;
if (Game.GetInput().IsKeyDown(sf::Key::M)) {
inertiaX += -speedRocket * sin(direction * radian);
inertiaY += -speedRocket * cos(direction * radian);
}
if (Game.GetInput().IsKeyDown(sf::Key::N) && shotTimer > 10)
shot = true;
-
This is not related to SFML, this is a limitation of your keyboard. Usual keyboards are limited to 3 or 4 keys, this is due to how they are wired inside.
-
Thanks Laurent. You have been right.
I changed the Keys i have to press on the keyboard and now everything works just fine. Weird problem.
-
Weird problem.
Well, you can find interesting readings about how keyboards work internally. Most of them are wired more or less like a matrix, so you can guess which combinations will work (ie. keys that are not on the same physical row or column).