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

Author Topic: Unable to process specific inputs simultaneously  (Read 3611 times)

0 Members and 1 Guest are viewing this topic.

TechRogue

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
Unable to process specific inputs simultaneously
« on: July 26, 2013, 10:34:49 pm »
I'm having some trouble with getting input from some specific keys, and I can't think why. Using C#, but I don't think that part matters.

This works as expected (Up arrow, Spacebar, Right arrow):
Console.WriteLine(Keyboard.IsKeyPressed(Keyboard.Key.Up));
Console.WriteLine(Keyboard.IsKeyPressed(Keyboard.Key.Space));
Console.WriteLine(Keyboard.IsKeyPressed(Keyboard.Key.Right));
Console.WriteLine("---------------");
 

The output when all three keys are held is:
True
True
True
---------------
 

However, if I change the test to use the left arrow instead of right:

Console.WriteLine(Keyboard.IsKeyPressed(Keyboard.Key.Up));
Console.WriteLine(Keyboard.IsKeyPressed(Keyboard.Key.Space));
Console.WriteLine(Keyboard.IsKeyPressed(Keyboard.Key.Left));
Console.WriteLine("---------------");
 

The output when all three keys are held is:
False
True
True
---------------
 

It's as though the spacebar isn't registered at all. Is this just a limitation of my keyboard or the way input is handled by the OS?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Unable to process specific inputs simultaneously
« Reply #1 on: July 26, 2013, 10:43:17 pm »
It's a known limitation of keyboards. Just try any other game, the result will be the same.
Laurent Gomila - SFML developer

TechRogue

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
Re: Unable to process specific inputs simultaneously
« Reply #2 on: July 26, 2013, 10:52:05 pm »
Bummer. Looks like a redesign of my game's controls is in order. Thanks for the fast reply!

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Unable to process specific inputs simultaneously
« Reply #3 on: July 26, 2013, 11:52:10 pm »
Just to provide some more information, what you are experiencing is known as "keyboard ghosting". In simple terms the hardware of your keyboard is unable to read multiple sets of key presses at the same time. If you want a more detailed explanation you should check out this link.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

TechRogue

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
Re: Unable to process specific inputs simultaneously
« Reply #4 on: July 26, 2013, 11:56:08 pm »
Very interesting! It's a good thing to be able to look out for in the future.

 

anything