Keyboard weirdness

In JEmu2, the keyboard input sometimes behaves very weird; it seems as if keyboard events get lost, delayed or both. However, this only happens sometimes on my laptop, but never on my desktop PC. On my laptop, I can simply restart the emulator to make the problem go away.

I use LWJGL 0.98 and I simply do

if (Keyboard.isKeyDown(keyCode)) { ... } 

every frame for each key (setting flags etc, for keeping track of key states).

I also tried adding

while (Keyboard.next()) { ... }

around the Keyboard handling code, but this didn’t make a difference.

I never had this problem before (Cosmic Trip (which uses an old version of lwjgl) doesn’t have this problem, and old versions of JEmu2 (using older versions of lwjgl) don’t seem to have this problem as well).

Is there any gotcha in doing keyboard handling in recent versions of LWJGL I need to be aware about? Anyone recognizes this problem?

Thanks,
Erik

Nobody? :-\

I have the feeling my IBM laptop might be a part of the problem too. Sometimes when I’m working, the keyboard simply stops responding for a few seconds after which all keyboard commands get puked from the buffer again, very annoying. As if some other service or driver or something has the same problem as that high priority garbage collector jvm bug that has recently been solved. All those thinkpads at work have the same problem; they truly suck :frowning:
But still, I can imagine more people might have the same problem and other games seem to work okay on it.

I had this problem once when I set my rendering loop to Thread.MAX_PRIORITY using ATI drivers - turns out they grab a higher priority than the keyboard drivers so all my input never got read by DirectX :slight_smile: It sounds like you’ve really only got a problem with your particular laptop/driver combo.

Cas :slight_smile:

Hm yes. I don’t change the priority of any thread, but I could try to set it to low priority.

could be your game loop is taking up all the resources and not leaving anything for the input to use try maybe

try {
        Thread.sleep(1);
}
catch(Exception e) {};

in the main game loop

Good suggestion, but it isn’t taking up all resources; in some games disabling vsync triples the frame rate.

Vsync can be very poorly implemented in some drivers - on this laptop for example it actually seems to go into a busy loop polling for it :frowning:

Cas :slight_smile:

Hm, yes that is bad.
However, I also have the problem with vsync disabled and with throttling using Thread.sleep() enabled.