Ghost Keyboard events?

Started by ThorPrime, June 26, 2006, 21:11:04

Previous topic - Next topic

ThorPrime

I've been calling the following lines every tenth of a second in my game:
while(Keyboard.next())

   notifyKeyListeners();

and for some reason, if one holds down a key or sometimes just not pressing the button very fast, random keyboard events occur.

Keyboard.next() should only return true when a key has been pushed down or let up correct?

This occurs on all OSes.
(but is worst under linux, bad under windows, and occasional under mac)

ThorPrime

Fixed it.
It looks like the problem was that one thread was calling keyboard.next while another was calling Dispaly.update().

Synchronizing the two threads fixed it.

Matzon

Generally, lwjgl isn't thread safe. So if you choose to use multiple threads anyway - you will have to synchronize yourself, like you already did.

darkprophet

I believe 1.0b1 added a few functions in Display to help in such cases..

Mainly Display.swapBuffers(); (i think) to only update the window and not poll the keyboard/mouse...

DP