Remove AWTInputAdapter.update() and let users poll() Mouse and Keyboard directly
This commit is contained in:
parent
216044ffa4
commit
3a12b4bdd2
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,21 +151,16 @@ final class LinuxAWTInput extends AbstractAWTInput {
|
||||||
return !input_released && isGrabbed();
|
return !input_released && isGrabbed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void update() {
|
private void update() {
|
||||||
LinuxDisplay.lockAWT();
|
|
||||||
try {
|
|
||||||
while (LinuxEvent.getPending(display) > 0) {
|
while (LinuxEvent.getPending(display) > 0) {
|
||||||
event.nextEvent(display);
|
event.nextEvent(display);
|
||||||
if (shouldGrab()) {
|
if (shouldGrab()) {
|
||||||
long event_window = event.getWindow();
|
long event_window = event.getWindow();
|
||||||
boolean processed = event.filterEvent(event_window) ||
|
boolean processed = event.filterEvent(event_window) ||
|
||||||
cached_mouse.filterEvent(isGrabbed(), shouldGrab(), event)/* ||
|
cached_mouse.filterEvent(isGrabbed(), shouldGrab(), event);/* ||
|
||||||
cached_keyboard.filterEvent(event)*/;
|
cached_keyboard.filterEvent(event) */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
LinuxDisplay.unlockAWT();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void grabMouse(boolean grab) {
|
public synchronized void grabMouse(boolean grab) {
|
||||||
|
|
|
@ -63,7 +63,4 @@ final class MacOSXAWTInput extends AbstractAWTInput {
|
||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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()) {
|
||||||
|
|
Loading…
Reference in New Issue