Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Parallel Keyinput  (Read 2161 times)

0 Members and 1 Guest are viewing this topic.

nullGrind

  • Newbie
  • *
  • Posts: 23
    • View Profile
Parallel Keyinput
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Parallel Keyinput
« Reply #1 on: February 01, 2010, 06:46:49 pm »
Are you saying that when you press multiple keys at the same time, some of them are ignored?
Laurent Gomila - SFML developer

nullGrind

  • Newbie
  • *
  • Posts: 23
    • View Profile
Parallel Keyinput
« Reply #2 on: February 01, 2010, 06:52:48 pm »
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:
Code: [Select]

        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;

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Parallel Keyinput
« Reply #3 on: February 01, 2010, 07:21:11 pm »
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.
Laurent Gomila - SFML developer

nullGrind

  • Newbie
  • *
  • Posts: 23
    • View Profile
Parallel Keyinput
« Reply #4 on: February 02, 2010, 12:07:42 am »
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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Parallel Keyinput
« Reply #5 on: February 02, 2010, 08:55:57 am »
Quote
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).
Laurent Gomila - SFML developer

 

anything