Remove AWTInputAdapter.update() and let users poll() Mouse and Keyboard directly

This commit is contained in:
Elias Naur 2006-11-10 13:52:18 +00:00
parent 216044ffa4
commit 3a12b4bdd2
6 changed files with 11 additions and 28 deletions

View File

@ -41,7 +41,6 @@ import org.lwjgl.LWJGLException;
*/
interface AWTCanvasInputImplementation extends InputImplementation {
void processInput(PeerInfo peer_info);
void update();
void init();
void destroy();
}

View File

@ -94,11 +94,4 @@ public final class AWTInputAdapter {
awt_input = null;
}
}
public static synchronized void update() {
if (awt_input == null)
throw new IllegalStateException("You need to create() the adapter.");
awt_input.update();
Display.pollDevices();
}
}

View File

@ -132,6 +132,7 @@ final class LinuxAWTInput extends AbstractAWTInput {
checkFocus();
if (!input_grabbed && shouldGrab())
grabInput(new_window);
update();
} finally {
LinuxDisplay.unlockAWT();
}
@ -150,20 +151,15 @@ final class LinuxAWTInput extends AbstractAWTInput {
return !input_released && isGrabbed();
}
public synchronized void update() {
LinuxDisplay.lockAWT();
try {
while (LinuxEvent.getPending(display) > 0) {
event.nextEvent(display);
if (shouldGrab()) {
long event_window = event.getWindow();
boolean processed = event.filterEvent(event_window) ||
cached_mouse.filterEvent(isGrabbed(), shouldGrab(), event)/* ||
cached_keyboard.filterEvent(event)*/;
}
private void update() {
while (LinuxEvent.getPending(display) > 0) {
event.nextEvent(display);
if (shouldGrab()) {
long event_window = event.getWindow();
boolean processed = event.filterEvent(event_window) ||
cached_mouse.filterEvent(isGrabbed(), shouldGrab(), event);/* ||
cached_keyboard.filterEvent(event) */
}
} finally {
LinuxDisplay.unlockAWT();
}
}

View File

@ -63,7 +63,4 @@ final class MacOSXAWTInput extends AbstractAWTInput {
public void destroy() {
}
public void update() {
}
}

View File

@ -129,9 +129,6 @@ final class WindowsAWTInput extends AbstractAWTInput {
}
}
public void update() {
}
public synchronized void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) {
if (isGrabbed()) {
if (cached_mouse != null)

View File

@ -140,11 +140,12 @@ public class AWTInputAdapterTest extends Frame {
+ (fps / (timeUsed / 1000f)));
fps = 0;
}
AWTInputAdapter.update();
Mouse.poll();
while (Mouse.next()) {
view_roty += Mouse.getEventDX()*.1;
view_rotx -= Mouse.getEventDY()*.1;
}
Keyboard.poll();
while (Keyboard.next()) {
if (Keyboard.getEventKeyState()) {
switch (Keyboard.getEventKey()) {