Permalink
Browse files

Give java real event flags

It makes sense to use noop for java, but it's just way easier to test the moving parts in java.
  • Loading branch information...
1 parent 4aa56ee commit 4012a48eebd38d47b78e5dd3d077ee20071f2117 @jamie-threerings jamie-threerings committed Aug 17, 2012
@@ -21,6 +21,7 @@
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Keyboard;
+import playn.core.Events;
import playn.core.Key;
import playn.core.util.Callback;
@@ -63,16 +64,16 @@ void update() {
Key key = translateKey(keyCode);
if (key != null)
listener.onKeyDown(new playn.core.Keyboard.Event.Impl(
- JavaPlatform.NOOP_EVENT_FLAGS, time, key));
+ new Events.Flags.Impl(), time, key));
char keyChar = Keyboard.getEventCharacter();
if (!Character.isISOControl(keyChar))
listener.onKeyTyped(new playn.core.Keyboard.TypedEvent.Impl(
- JavaPlatform.NOOP_EVENT_FLAGS, time, keyChar));
+ new Events.Flags.Impl(), time, keyChar));
} else {
Key key = translateKey(keyCode);
if (key != null)
listener.onKeyUp(new playn.core.Keyboard.Event.Impl(
- JavaPlatform.NOOP_EVENT_FLAGS, time, key));
+ new Events.Flags.Impl(), time, key));
}
}
}
@@ -21,6 +21,7 @@
import pythagoras.f.Point;
+import playn.core.Events;
import playn.core.MouseImpl;
import playn.core.PlayN;
@@ -68,17 +69,17 @@ void update() {
int dx = Mouse.getEventDX(), dy = -Mouse.getEventDY();
if (btn != -1) {
if (Mouse.getEventButtonState()) {
- onMouseDown(new ButtonEvent.Impl(JavaPlatform.NOOP_EVENT_FLAGS, time, m.x, m.y, btn));
+ onMouseDown(new ButtonEvent.Impl(new Events.Flags.Impl(), time, m.x, m.y, btn));
pointer.onMouseDown(time, m.x, m.y);
} else {
- onMouseUp(new ButtonEvent.Impl(JavaPlatform.NOOP_EVENT_FLAGS, time, m.x, m.y, btn));
+ onMouseUp(new ButtonEvent.Impl(new Events.Flags.Impl(), time, m.x, m.y, btn));
pointer.onMouseUp(time, m.x, m.y);
}
} else if (Mouse.getEventDWheel() != 0) {
onMouseWheelScroll(new WheelEvent.Impl(
- JavaPlatform.NOOP_EVENT_FLAGS, time, m.x, m.y, -Mouse.getEventDWheel()));
+ new Events.Flags.Impl(), time, m.x, m.y, -Mouse.getEventDWheel()));
} else {
- onMouseMove(new MotionEvent.Impl(JavaPlatform.NOOP_EVENT_FLAGS, time, m.x, m.y, dx, dy));
+ onMouseMove(new MotionEvent.Impl(new Events.Flags.Impl(), time, m.x, m.y, dx, dy));
pointer.onMouseMove(time, m.x, m.y);
}
}
@@ -40,12 +40,6 @@
public class JavaPlatform extends AbstractPlatform {
- /** Ignores all event flags. We don't currently need them for java. */
- static Events.Flags NOOP_EVENT_FLAGS = new Events.Flags() {
- @Override public boolean getPreventDefault () {return false;}
- @Override public void setPreventDefault (boolean preventDefault) { }
- };
-
/** Defines JavaPlatform configurable parameters. */
public static class Config {
/** The graphics scale factor. Allows simulating HiDPI mode during testing. */
@@ -15,25 +15,26 @@
*/
package playn.java;
+import playn.core.Events;
import playn.core.PointerImpl;
class JavaPointer extends PointerImpl {
private boolean mouseDown;
void onMouseDown(double time, float x, float y) {
- onPointerStart(new Event.Impl(JavaPlatform.NOOP_EVENT_FLAGS, time, x, y, false), false);
+ onPointerStart(new Event.Impl(new Events.Flags.Impl(), time, x, y, false), false);
mouseDown = true;
}
void onMouseUp(double time, float x, float y) {
- onPointerEnd(new Event.Impl(JavaPlatform.NOOP_EVENT_FLAGS, time, x, y, false), false);
+ onPointerEnd(new Event.Impl(new Events.Flags.Impl(), time, x, y, false), false);
mouseDown = false;
}
void onMouseMove(double time, float x, float y) {
if (mouseDown) {
- onPointerDrag(new Event.Impl(JavaPlatform.NOOP_EVENT_FLAGS, time, x, y, false), false);
+ onPointerDrag(new Event.Impl(new Events.Flags.Impl(), time, x, y, false), false);
}
}

0 comments on commit 4012a48

Please sign in to comment.