Multiple Keyboard Keys Problem

Started by FyberOptic, June 29, 2012, 19:27:49

Previous topic - Next topic

FyberOptic

Got stumped on a little problem in LWJGL, then ended up with another problem just trying to sign up to ask about it!  It kept telling me the captcha was wrong, until I finally just turned the images the opposite way it was telling me until it finally worked.

Anyway, I decided to experiment with Java/LWJGL for a possible future project, due to how easily one can make a project run standalone or as an applet simply depending on which class you start from.  I have prior Java experience, as well as OpenGL experience, just not together.  So getting it up and running has been relatively easy, which is nice.

My problem though is with keyboard input.  I made WASD move my camera and space to jump.  Problem is, space bar doesn't work when I'm holding A and S or S and D at the same time.  No events at all come through the event queue, and polling manually doesn't indicate space is pressed.

I found similar (though not exact) issues from people on Google, to which there was either no response, or they were told it was unsolvable due to how the hardware key matrix works (which I haven't really had to deal with since the DOS days).  And the fact remains that I can use these same key combinations in various other programming languages just fine (Plain 'ol C with OpenGL, for example), not to mention countless games and applications which use it just fine, so I refuse to believe that this is an unsolvable problem.

So I'm mostly wondering if anyone else has experienced this, how they dealt with it, and if there's no solution through LWJGL, would I be better off to just go back to generic Java input handling?


EDIT:  Well crap.  I decided to try using a KeyListener class like I've done with things in the past.  But I came to realize that the same thing happens with it!  So maybe it's not an LWJGL-specific problem.  And I'm no closer to figuring it out.

princec

As you already discovered - it's the keyboard matrix. It's hardware design. Nothing you can do about it. A different keyboard might help.

Cas :)

Klemss

I'm bumping this thread because I'm running into the same issue: a combination doesn't work in LWJGL while it work on another game.
Quote from: FyberOptic on June 29, 2012, 19:27:49And the fact remains that I can use these same key combinations in various other programming languages just fine (Plain 'ol C with OpenGL, for example), not to mention countless games and applications which use it just fine, so I refuse to believe that this is an unsolvable problem.
It may be because the polling is done in a different way, so it SEEMS to be unresponsive. Instead of checking for events you could check whether or not the keys are down directly. A custom JInput-based class could solve those problems. Maybe the LWJGL polling is based on the Java KeyListener.
Checking for events may be different than checking directly if a key is pressed: if you did a complex combination while pressing/releasing a key, the "up" events for that key could not get called. Resulting in a key considered pressed while it's not.
I'm not sure if that's make sense :P



Also that's not the only issue I'm having with the Keyboard class: for some reason, on my netbook, the polling lack reactivity and isn't polling "fast enough". Display.update() is called at a decent rate. Yet, Keyboard.isKeyDown(...) doesn't yield the accurate result on time. I'm not sure about the delay but it's about 0.5 seconds. Enough to make the game almost unplayable.
Does anyone have any idea ?