Fixed jinput plugins

This commit is contained in:
Elias Naur 2006-04-05 12:42:17 +00:00
parent f16f0e26cc
commit 481ffb5f16
2 changed files with 31 additions and 8 deletions

View File

@ -23,6 +23,7 @@
*/ */
package org.lwjgl.util.jinput; package org.lwjgl.util.jinput;
import net.java.games.input.AbstractComponent;
import net.java.games.input.Keyboard; import net.java.games.input.Keyboard;
import net.java.games.input.Component; import net.java.games.input.Component;
import net.java.games.input.Controller; import net.java.games.input.Controller;
@ -90,12 +91,12 @@ final class LWJGLKeyboard extends Keyboard {
if (key == null) if (key == null)
return false; return false;
float value = org.lwjgl.input.Keyboard.getEventKeyState() ? 1 : 0; float value = org.lwjgl.input.Keyboard.getEventKeyState() ? 1 : 0;
event.set(key, value); event.set(key, value, System.currentTimeMillis()*1000000);
return true; return true;
} }
private final static class Key extends Keyboard.Key { private final static class Key extends AbstractComponent {
private final int lwjgl_key; private final int lwjgl_key;
private float value; private float value;
@ -111,5 +112,13 @@ final class LWJGLKeyboard extends Keyboard {
protected final float poll() { protected final float poll() {
return value; return value;
} }
public final boolean isRelative() {
return false;
}
public final boolean isAnalog() {
return false;
}
} }
} }

View File

@ -25,6 +25,7 @@
package org.lwjgl.util.jinput; package org.lwjgl.util.jinput;
import net.java.games.input.AbstractComponent;
import net.java.games.input.Mouse; import net.java.games.input.Mouse;
import net.java.games.input.Component; import net.java.games.input.Component;
import net.java.games.input.Controller; import net.java.games.input.Controller;
@ -90,13 +91,14 @@ final class LWJGLMouse extends Mouse {
protected final synchronized boolean getNextDeviceEvent(Event event) throws IOException { protected final synchronized boolean getNextDeviceEvent(Event event) throws IOException {
if (!org.lwjgl.input.Mouse.isCreated()) if (!org.lwjgl.input.Mouse.isCreated())
return false; return false;
long nanos = System.currentTimeMillis()*1000000;
while (true) { while (true) {
switch (event_state) { switch (event_state) {
case EVENT_X: case EVENT_X:
event_state = EVENT_Y; event_state = EVENT_Y;
int dx = org.lwjgl.input.Mouse.getEventDX(); int dx = org.lwjgl.input.Mouse.getEventDX();
if (dx != 0) { if (dx != 0) {
event.set(getX(), dx); event.set(getX(), dx, nanos);
return true; return true;
} }
break; break;
@ -107,7 +109,7 @@ final class LWJGLMouse extends Mouse {
*/ */
int dy = -org.lwjgl.input.Mouse.getEventDY(); int dy = -org.lwjgl.input.Mouse.getEventDY();
if (dy != 0) { if (dy != 0) {
event.set(getY(), dy); event.set(getY(), dy, nanos);
return true; return true;
} }
break; break;
@ -115,7 +117,7 @@ final class LWJGLMouse extends Mouse {
event_state = EVENT_BUTTON; event_state = EVENT_BUTTON;
int dwheel = org.lwjgl.input.Mouse.getEventDWheel(); int dwheel = org.lwjgl.input.Mouse.getEventDWheel();
if (dwheel != 0) { if (dwheel != 0) {
event.set(getWheel(), dwheel); event.set(getWheel(), dwheel, nanos);
return true; return true;
} }
break; break;
@ -125,7 +127,7 @@ final class LWJGLMouse extends Mouse {
if (lwjgl_button != -1) { if (lwjgl_button != -1) {
Button button = map(lwjgl_button); Button button = map(lwjgl_button);
if (button != null) { if (button != null) {
event.set(button, org.lwjgl.input.Mouse.getEventButtonState() ? 1f : 0f); event.set(button, org.lwjgl.input.Mouse.getEventButtonState() ? 1f : 0f, nanos);
return true; return true;
} }
} }
@ -141,7 +143,7 @@ final class LWJGLMouse extends Mouse {
} }
} }
final static class Axis extends Mouse.Axis { final static class Axis extends AbstractComponent {
public Axis(Component.Identifier.Axis axis_id) { public Axis(Component.Identifier.Axis axis_id) {
super(axis_id.getName(), axis_id); super(axis_id.getName(), axis_id);
} }
@ -153,9 +155,13 @@ final class LWJGLMouse extends Mouse {
protected final float poll() throws IOException { protected final float poll() throws IOException {
return 0; return 0;
} }
public final boolean isAnalog() {
return true;
}
} }
final static class Button extends Mouse.Button { final static class Button extends AbstractComponent {
private float value; private float value;
public Button(Component.Identifier.Button button_id) { public Button(Component.Identifier.Button button_id) {
@ -169,5 +175,13 @@ final class LWJGLMouse extends Mouse {
protected final float poll() throws IOException { protected final float poll() throws IOException {
return value; return value;
} }
public final boolean isRelative() {
return false;
}
public final boolean isAnalog() {
return false;
}
} }
} }