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 { interface AWTCanvasInputImplementation extends InputImplementation {
void processInput(PeerInfo peer_info); void processInput(PeerInfo peer_info);
void update();
void init(); void init();
void destroy(); void destroy();
} }

View File

@ -94,11 +94,4 @@ public final class AWTInputAdapter {
awt_input = null; 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(); checkFocus();
if (!input_grabbed && shouldGrab()) if (!input_grabbed && shouldGrab())
grabInput(new_window); grabInput(new_window);
update();
} finally { } finally {
LinuxDisplay.unlockAWT(); LinuxDisplay.unlockAWT();
} }
@ -150,20 +151,15 @@ final class LinuxAWTInput extends AbstractAWTInput {
return !input_released && isGrabbed(); return !input_released && isGrabbed();
} }
public synchronized void update() { private void update() {
LinuxDisplay.lockAWT(); while (LinuxEvent.getPending(display) > 0) {
try { event.nextEvent(display);
while (LinuxEvent.getPending(display) > 0) { if (shouldGrab()) {
event.nextEvent(display); long event_window = event.getWindow();
if (shouldGrab()) { boolean processed = event.filterEvent(event_window) ||
long event_window = event.getWindow(); cached_mouse.filterEvent(isGrabbed(), shouldGrab(), event);/* ||
boolean processed = event.filterEvent(event_window) || cached_keyboard.filterEvent(event) */
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 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) { public synchronized void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) {
if (isGrabbed()) { if (isGrabbed()) {
if (cached_mouse != null) if (cached_mouse != null)

View File

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