diff --git a/android/core/src/processing/event/Event.java b/android/core/src/processing/event/Event.java new file mode 100644 index 000000000..3b402e088 --- /dev/null +++ b/android/core/src/processing/event/Event.java @@ -0,0 +1,105 @@ +/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ + +/* + Part of the Processing project - http://processing.org + + Copyright (c) 2012 The Processing Foundation + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation, version 2.1. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA +*/ + +package processing.event; + + +public class Event { + protected Object nativeObject; + + protected long millis; + protected int action; + + static public final int SHIFT_MASK = 1 << 6; + static public final int CTRL_MASK = 1 << 7; + static public final int META_MASK = 1 << 8; + static public final int ALT_MASK = 1 << 9; + protected int modifiers; + + + public Event(Object nativeObject, long millis, int action, int modifiers) { + this.nativeObject = nativeObject; + this.millis = millis; + this.action = action; + this.modifiers = modifiers; + } + + + public Object getNative() { + return nativeObject; + } + + +// public void setNative(Object nativeObject) { +// this.nativeObject = nativeObject; +// } + + + public long getMillis() { + return millis; + } + + +// public void setMillis(long millis) { +// this.millis = millis; +// } + + + public int getAction() { + return action; + } + + +// public void setAction(int action) { +// this.action = action; +// } + + + public int getModifiers() { + return modifiers; + } + + +// public void setModifiers(int modifiers) { +// this.modifiers = modifiers; +// } + + + public boolean isShiftDown() { + return (modifiers & SHIFT_MASK) != 0; + } + + + public boolean isControlDown() { + return (modifiers & CTRL_MASK) != 0; + } + + + public boolean isMetaDown() { + return (modifiers & META_MASK) != 0; + } + + + public boolean isAltDown() { + return (modifiers & ALT_MASK) != 0; + } +} \ No newline at end of file diff --git a/android/core/src/processing/event/KeyEvent.java b/android/core/src/processing/event/KeyEvent.java index 885a8510e..90c69719d 100644 --- a/android/core/src/processing/event/KeyEvent.java +++ b/android/core/src/processing/event/KeyEvent.java @@ -23,19 +23,30 @@ package processing.event; -public class KeyEvent { - Object nativeObject; +public class KeyEvent extends Event { + static public final int PRESSED = 1; + static public final int RELEASED = 2; + static public final int TYPED = 3; char key; int keyCode; - public KeyEvent(Object nativeObject) { - this.nativeObject = nativeObject; + public KeyEvent(Object nativeObject, + long millis, int action, int modifiers, + char key, int keyCode) { + super(nativeObject, millis, action, modifiers); + this.key = key; + this.keyCode = keyCode; } - public Object getNative() { - return nativeObject; + public char getKey() { + return key; + } + + + public int getKeyCode() { + return keyCode; } } \ No newline at end of file diff --git a/android/core/src/processing/event/MouseEvent.java b/android/core/src/processing/event/MouseEvent.java index 7a92e8e41..9a727a8d3 100644 --- a/android/core/src/processing/event/MouseEvent.java +++ b/android/core/src/processing/event/MouseEvent.java @@ -22,19 +22,68 @@ package processing.event; - -public class MouseEvent { - Object nativeObject; - - int x, y; +//import processing.core.PConstants; - public MouseEvent(Object nativeObject) { - this.nativeObject = nativeObject; +public class MouseEvent extends Event { + static public final int PRESSED = 1; + static public final int RELEASED = 2; + static public final int CLICKED = 3; + static public final int DRAGGED = 4; + static public final int MOVED = 5; + static public final int ENTERED = 6; + static public final int EXITED = 7; + + protected int x, y; + protected int button; + protected int clickCount; + + +// public MouseEvent(int x, int y) { +// this(null, +// System.currentTimeMillis(), PRESSED, 0, +// x, y, PConstants.LEFT, 1); +// } + + + public MouseEvent(Object nativeObject, + long millis, int action, int modifiers, + int x, int y, int button, int clickCount) { + super(nativeObject, millis, action, modifiers); + this.x = x; + this.y = y; + this.button = button; + this.clickCount = clickCount; } - public Object getNative() { - return nativeObject; + public int getX() { + return x; } + + + public int getY() { + return y; + } + + + /** Which button was pressed, either LEFT, CENTER, or RIGHT. */ + public int getButton() { + return button; + } + + +// public void setButton(int button) { +// this.button = button; +// } + + + public int getClickCount() { + return clickCount; + } + + +// public void setClickCount(int clickCount) { +// this.clickCount = clickCount; +// } } \ No newline at end of file diff --git a/android/core/src/processing/event/TouchEvent.java b/android/core/src/processing/event/TouchEvent.java index ccfc00822..50443ca26 100644 --- a/android/core/src/processing/event/TouchEvent.java +++ b/android/core/src/processing/event/TouchEvent.java @@ -23,18 +23,9 @@ package processing.event; -public class TouchEvent { - Object nativeObject; +public class TouchEvent extends Event { - float x, y; - - - public TouchEvent(Object nativeObject) { - this.nativeObject = nativeObject; - } - - - public Object getNative() { - return nativeObject; + public TouchEvent(Object nativeObject, long millis, int action, int modifiers) { + super(nativeObject, millis, action, modifiers); } } \ No newline at end of file diff --git a/core/src/processing/event/TouchEvent.java b/core/src/processing/event/TouchEvent.java index ccfc00822..50443ca26 100644 --- a/core/src/processing/event/TouchEvent.java +++ b/core/src/processing/event/TouchEvent.java @@ -23,18 +23,9 @@ package processing.event; -public class TouchEvent { - Object nativeObject; +public class TouchEvent extends Event { - float x, y; - - - public TouchEvent(Object nativeObject) { - this.nativeObject = nativeObject; - } - - - public Object getNative() { - return nativeObject; + public TouchEvent(Object nativeObject, long millis, int action, int modifiers) { + super(nativeObject, millis, action, modifiers); } } \ No newline at end of file