AWTInputAdapter.destroy() now destroys the Keyboard and Mouse to mimic the behaviour of Display.destroy() more closely.
This commit is contained in:
parent
2502496b2d
commit
0e10718b16
|
@ -92,6 +92,8 @@ public final class AWTInputAdapter {
|
||||||
if (awt_input != null) {
|
if (awt_input != null) {
|
||||||
awt_input.destroy();
|
awt_input.destroy();
|
||||||
awt_input = null;
|
awt_input = null;
|
||||||
|
Mouse.destroy();
|
||||||
|
Keyboard.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,18 +140,25 @@ public class AWTInputAdapterTest extends Frame {
|
||||||
+ (fps / (timeUsed / 1000f)));
|
+ (fps / (timeUsed / 1000f)));
|
||||||
fps = 0;
|
fps = 0;
|
||||||
}
|
}
|
||||||
|
if (Mouse.isCreated()) {
|
||||||
Mouse.poll();
|
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;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (Keyboard.isCreated()) {
|
||||||
Keyboard.poll();
|
Keyboard.poll();
|
||||||
while (Keyboard.next()) {
|
}
|
||||||
|
while (Keyboard.isCreated() && Keyboard.next()) {
|
||||||
if (Keyboard.getEventKeyState()) {
|
if (Keyboard.getEventKeyState()) {
|
||||||
switch (Keyboard.getEventKey()) {
|
switch (Keyboard.getEventKey()) {
|
||||||
case Keyboard.KEY_ESCAPE:
|
case Keyboard.KEY_ESCAPE:
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
break;
|
break;
|
||||||
|
case Keyboard.KEY_H:
|
||||||
|
AWTInputAdapter.destroy();
|
||||||
|
break;
|
||||||
case Keyboard.KEY_G:
|
case Keyboard.KEY_G:
|
||||||
Mouse.setGrabbed(!Mouse.isGrabbed());
|
Mouse.setGrabbed(!Mouse.isGrabbed());
|
||||||
break;
|
break;
|
||||||
|
@ -162,6 +169,7 @@ public class AWTInputAdapterTest extends Frame {
|
||||||
if (Keyboard.getEventCharacter() != Keyboard.CHAR_NONE)
|
if (Keyboard.getEventCharacter() != Keyboard.CHAR_NONE)
|
||||||
System.out.println("Typed: " + Keyboard.getEventCharacter());
|
System.out.println("Typed: " + Keyboard.getEventCharacter());
|
||||||
}
|
}
|
||||||
|
if (Keyboard.isCreated()) {
|
||||||
if (Keyboard.isKeyDown(Keyboard.KEY_UP))
|
if (Keyboard.isKeyDown(Keyboard.KEY_UP))
|
||||||
view_rotx -= .1;
|
view_rotx -= .1;
|
||||||
else if (Keyboard.isKeyDown(Keyboard.KEY_DOWN))
|
else if (Keyboard.isKeyDown(Keyboard.KEY_DOWN))
|
||||||
|
@ -171,6 +179,7 @@ public class AWTInputAdapterTest extends Frame {
|
||||||
else if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT))
|
else if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT))
|
||||||
view_roty += .1;
|
view_roty += .1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
addWindowListener(new WindowAdapter() {
|
addWindowListener(new WindowAdapter() {
|
||||||
public void windowClosing(WindowEvent e) {
|
public void windowClosing(WindowEvent e) {
|
||||||
|
@ -225,7 +234,7 @@ public class AWTInputAdapterTest extends Frame {
|
||||||
|
|
||||||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||||
|
|
||||||
System.err.println("Use the arrow keys and the mouse to rotate the gears. Press 'G' to toggle mouse grabbing.");
|
System.err.println("Use the arrow keys and the mouse to rotate the gears. Press 'G' to toggle mouse grabbing. Press 'H' to destroy the AWTInputAdapter.");
|
||||||
System.err.println("GL_VENDOR: " + GL11.glGetString(GL11.GL_VENDOR));
|
System.err.println("GL_VENDOR: " + GL11.glGetString(GL11.GL_VENDOR));
|
||||||
System.err.println("GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER));
|
System.err.println("GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER));
|
||||||
System.err.println("GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION));
|
System.err.println("GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION));
|
||||||
|
|
Loading…
Reference in New Issue