Hi!
I have a problem with my keyboard event code with lwjgl 0.6 under linux. The code in question worked perfectly under win32 using lwjgl 0.5 so I’m not sure what I’m doing wrong here.
Here is how I handle the keyboard events:
How I create the keyboard:
public GameHandler() {
// Create a new gl window
glWin = new GLWindow(Preferences.width, Preferences.height, Preferences.bpp, true);
this.gl = GLWindow.gl;
Renderer.init(GLWindow.gl);
// Get time timer resolution (ie ticks/sec)
timerRes = Sys.getTimerResolution();
// Create native keyboard binding and create an event buffer
try {
Keyboard.create();
Mouse.create();
System.out.println("Keyboard buffer size:" + Keyboard.enableBuffer());
} catch(Exception e) {
System.err.println("Could not create keyboard for the rendering window" + e);
}
And here is the keyboard processing method called from my main loop:
public void processKeyboard() {
Keyboard.read();
for(int i = 0; i < Keyboard.getNumKeyboardEvents(); i++) {
Keyboard.next();
keys[Keyboard.key] = !keys[Keyboard.key];
}
if(keys[Keyboard.KEY_ESCAPE]) {
finished = true;
}
}
My problem is that I never recieve any keyboard events, getNumKeyboarEvents always retun 0 (or less I don’t know). I haven’t tested it throughly, but Mouse events doesn’t seem to make their way either…
Suggestions?
/Kalle