diff --git a/android/core/src/processing/core/PApplet.java b/android/core/src/processing/core/PApplet.java index 1f55d4697..787ef105a 100644 --- a/android/core/src/processing/core/PApplet.java +++ b/android/core/src/processing/core/PApplet.java @@ -229,14 +229,14 @@ public class PApplet extends Activity implements PConstants, Runnable { protected int emouseX, emouseY; protected float emotionX, emotionY; - /** - * Used to set pmotionX/Y to motionX/Y the first time motionX/Y are used, - * otherwise pmotionX/Y are always zero, causing a nasty jump. - *
- * Just using (frameCount == 0) won't work since motionXxxxx() - * may not be called until a couple frames into things. - */ - public boolean firstMotion; +// /** +// * Used to set pmotionX/Y to motionX/Y the first time motionX/Y are used, +// * otherwise pmotionX/Y are always zero, causing a nasty jump. +// *
+// * Just using (frameCount == 0) won't work since motionXxxxx() +// * may not be called until a couple frames into things. +// */ +// public boolean firstMotion; // public int mouseButton; @@ -563,7 +563,7 @@ public class PApplet extends Activity implements PConstants, Runnable { // this will be cleared by draw() if it is not overridden looping = true; redraw = true; // draw this guy once - firstMotion = true; +// firstMotion = true; Context context = getApplicationContext(); sketchPath = context.getFilesDir().getAbsolutePath(); @@ -1985,8 +1985,9 @@ public class PApplet extends Activity implements PConstants, Runnable { // drawing commands can be run inside them. it can't // be before, since a call to background() would wipe // out anything that had been drawn so far. - dequeueMotionEvents(); - dequeueKeyEvents(); +// dequeueMotionEvents(); +// dequeueKeyEvents(); + dequeueEvents(); handleMethods("draw"); @@ -2067,17 +2068,197 @@ public class PApplet extends Activity implements PConstants, Runnable { ////////////////////////////////////////////////////////////// - class PMotionEvent { + InternalEventQueue eventQueue = new InternalEventQueue(); + + + class InternalEventQueue { + protected Event queue[] = new Event[10]; + protected int offset; + protected int count; + + synchronized void add(Event e) { + if (count == queue.length) { + queue = (Event[]) expand(queue); + } + queue[count++] = e; + } + + synchronized Event remove() { + if (offset == count) { + throw new RuntimeException("Nothing left on the event queue."); + } + Event outgoing = queue[offset++]; + if (offset == count) { + // All done, time to reset + offset = 0; + count = 0; + } + return outgoing; + } + + synchronized boolean available() { + return count != 0; + } + } + + /** + * Add an event to the internal event queue, or process it immediately if + * the sketch is not currently looping. + */ + public void postEvent(processing.event.Event pe) { + eventQueue.add(pe); + + if (!looping) { + dequeueEvents(); + } + } + + + protected void dequeueEvents() { + while (eventQueue.available()) { + Event e = eventQueue.remove(); + + switch (e.getFlavor()) { +// case Event.TOUCH: +// handleTouchEvent((TouchEvent) e); +// break; + case Event.MOUSE: + handleMouseEvent((MouseEvent) e); + break; + case Event.KEY: + handleKeyEvent((KeyEvent) e); + break; + } + } + } + + + ////////////////////////////////////////////////////////////// + + + protected void handleMouseEvent(MouseEvent event) { + // http://dev.processing.org/bugs/show_bug.cgi?id=170 + // also prevents mouseExited() on the mac from hosing the mouse + // position, because x/y are bizarre values on the exit event. + // see also the id check below.. both of these go together +// if ((id == java.awt.event.MouseEvent.MOUSE_DRAGGED) || +// (id == java.awt.event.MouseEvent.MOUSE_MOVED)) { + if (event.getAction() == MouseEvent.DRAG || + event.getAction() == MouseEvent.MOVE) { + pmouseX = emouseX; + pmouseY = emouseY; + mouseX = event.getX(); + mouseY = event.getY(); + } + + // Because we only get DRAGGED (and no MOVED) events, pmouseX/Y will make + // things jump because they aren't updated while a finger isn't on the + // screen. This makes for weirdness with the continuous lines example, + // causing it to jump. Since we're emulating the mouse here, do the right + // thing for mouse events. It breaks the situation where random taps/clicks + // to the screen won't show up as 'previous' values, but that's probably + // less common. +// if (event.getAction() == MouseEvent.PRESS) { +// System.out.println("resetting"); +//// pmouseX = event.getX(); +//// pmouseY = event.getY(); +// firstMotion = true; +// } + + // Get the (already processed) button code +// mouseButton = event.getButton(); + + // Added in 0215 (2.0b7) so that pmouseX/Y behave more like one would + // expect from the desktop. This makes the ContinousLines example behave. + if (event.getAction() == MouseEvent.PRESS) { + mouseX = event.getX(); + mouseY = event.getY(); + pmouseX = mouseX; + pmouseY = mouseY; + dmouseX = mouseX; + dmouseY = mouseY; + } + +// if (event.getAction() == MouseEvent.RELEASE) { +// mouseX = event.getX(); +// mouseY = event.getY(); +// } + +// mouseEvent = event; + + // Do this up here in case a registered method relies on the + // boolean for mousePressed. + + switch (event.getAction()) { + case MouseEvent.PRESS: + mousePressed = true; + break; + case MouseEvent.RELEASE: + mousePressed = false; + break; + } + + handleMethods("mouseEvent", new Object[] { event }); + + switch (event.getAction()) { + case MouseEvent.PRESS: + mousePressed(); + break; + case MouseEvent.RELEASE: + mouseReleased(); + break; + case MouseEvent.CLICK: + mouseClicked(); + break; + case MouseEvent.DRAG: + mouseDragged(); + break; + case MouseEvent.MOVE: + mouseMoved(); + break; + case MouseEvent.ENTER: + mouseEntered(); + break; + case MouseEvent.EXIT: + mouseExited(); + break; + } + + if ((event.getAction() == MouseEvent.DRAG) || + (event.getAction() == MouseEvent.MOVE)) { + emouseX = mouseX; + emouseY = mouseY; + } + if (event.getAction() == MouseEvent.PRESS) { // Android-only + emouseX = mouseX; + emouseY = mouseY; + } +// if (event.getAction() == MouseEvent.RELEASE) { // Android-only +// emouseX = mouseX; +// emouseY = mouseY; +// } + } + + + /* + // ******************** NOT CURRENTLY IN USE ******************** + // this class is hiding inside PApplet for now, + // until I have a chance to get the API right inside TouchEvent. + class AndroidTouchEvent extends TouchEvent { int action; int numPointers; float[] motionX, motionY; float[] motionPressure; int[] mouseX, mouseY; - void setAction(int action) { - this.action = action; + AndroidTouchEvent(Object nativeObject, long millis, int action, int modifiers) { + super(nativeObject, millis, action, modifiers); } +// void setAction(int action) { +// this.action = action; +// } + void setNumPointers(int n) { numPointers = n; motionX = new float[n]; @@ -2109,76 +2290,76 @@ public class PApplet extends Activity implements PConstants, Runnable { } } - Object motionLock = new Object(); - PMotionEvent[] motionEventQueue; - int motionEventCount; - - protected void enqueueMotionEvent(MotionEvent event) { - synchronized (motionLock) { - // on first run, allocate array for motion events - if (motionEventQueue == null) { - motionEventQueue = new PMotionEvent[20]; - for (int i = 0; i < motionEventQueue.length; i++) { - motionEventQueue[i] = new PMotionEvent(); - } - } - // allocate more PMotionEvent objects if we're out - int historyCount = event.getHistorySize(); -// println("motion: " + motionEventCount + " " + historyCount + " " + motionEventQueue.length); - if (motionEventCount + historyCount >= motionEventQueue.length) { - int atLeast = motionEventCount + historyCount + 1; - PMotionEvent[] temp = new PMotionEvent[max(atLeast, motionEventCount << 1)]; - if (PApplet.DEBUG) { - println("motion: " + motionEventCount + " " + historyCount + " " + motionEventQueue.length); - println("allocating " + temp.length + " entries for motion events"); - } - System.arraycopy(motionEventQueue, 0, temp, 0, motionEventCount); - motionEventQueue = temp; - for (int i = motionEventCount; i < motionEventQueue.length; i++) { - motionEventQueue[i] = new PMotionEvent(); - } - } - - // this will be the last event in the list - PMotionEvent pme = motionEventQueue[motionEventCount + historyCount]; - pme.setAction(event.getAction()); - pme.setNumPointers(event.getPointerCount()); - pme.setPointers(event); - - // historical events happen before the 'current' values - if (pme.action == MotionEvent.ACTION_MOVE && historyCount > 0) { - for (int i = 0; i < historyCount; i++) { - PMotionEvent hist = motionEventQueue[motionEventCount++]; - hist.setAction(event.getAction()); - hist.setNumPointers(event.getPointerCount()); - hist.setPointers(event, i); - } - } - - // now step over the last one that we used to assign 'pme' - // if historyCount is 0, this just steps over the last - motionEventCount++; - } - } - - protected void dequeueMotionEvents() { - synchronized (motionLock) { - for (int i = 0; i < motionEventCount; i++) { - handleMotionEvent(motionEventQueue[i]); - } - motionEventCount = 0; - } - } +// Object motionLock = new Object(); +// AndroidTouchEvent[] motionEventQueue; +// int motionEventCount; +// +// protected void enqueueMotionEvent(MotionEvent event) { +// synchronized (motionLock) { +// // on first run, allocate array for motion events +// if (motionEventQueue == null) { +// motionEventQueue = new AndroidTouchEvent[20]; +// for (int i = 0; i < motionEventQueue.length; i++) { +// motionEventQueue[i] = new AndroidTouchEvent(); +// } +// } +// // allocate more PMotionEvent objects if we're out +// int historyCount = event.getHistorySize(); +//// println("motion: " + motionEventCount + " " + historyCount + " " + motionEventQueue.length); +// if (motionEventCount + historyCount >= motionEventQueue.length) { +// int atLeast = motionEventCount + historyCount + 1; +// AndroidTouchEvent[] temp = new AndroidTouchEvent[max(atLeast, motionEventCount << 1)]; +// if (PApplet.DEBUG) { +// println("motion: " + motionEventCount + " " + historyCount + " " + motionEventQueue.length); +// println("allocating " + temp.length + " entries for motion events"); +// } +// System.arraycopy(motionEventQueue, 0, temp, 0, motionEventCount); +// motionEventQueue = temp; +// for (int i = motionEventCount; i < motionEventQueue.length; i++) { +// motionEventQueue[i] = new AndroidTouchEvent(); +// } +// } +// +// // this will be the last event in the list +// AndroidTouchEvent pme = motionEventQueue[motionEventCount + historyCount]; +// pme.setAction(event.getAction()); +// pme.setNumPointers(event.getPointerCount()); +// pme.setPointers(event); +// +// // historical events happen before the 'current' values +// if (pme.action == MotionEvent.ACTION_MOVE && historyCount > 0) { +// for (int i = 0; i < historyCount; i++) { +// AndroidTouchEvent hist = motionEventQueue[motionEventCount++]; +// hist.setAction(event.getAction()); +// hist.setNumPointers(event.getPointerCount()); +// hist.setPointers(event, i); +// } +// } +// +// // now step over the last one that we used to assign 'pme' +// // if historyCount is 0, this just steps over the last +// motionEventCount++; +// } +// } +// +// +// protected void dequeueMotionEvents() { +// synchronized (motionLock) { +// for (int i = 0; i < motionEventCount; i++) { +// handleMotionEvent(motionEventQueue[i]); +// } +// motionEventCount = 0; +// } +// } - /** - * Take action based on a motion event. - * Internally updates mouseX, mouseY, mousePressed, and mouseEvent. - * Then it calls the event type with no params, - * i.e. mousePressed() or mouseReleased() that the user may have - * overloaded to do something more useful. - */ - protected void handleMotionEvent(PMotionEvent pme) { + // ******************** NOT CURRENTLY IN USE ******************** + // Take action based on a motion event. + // Internally updates mouseX, mouseY, mousePressed, and mouseEvent. + // Then it calls the event type with no params, + // i.e. mousePressed() or mouseReleased() that the user may have + // overloaded to do something more useful. + protected void handleMotionEvent(AndroidTouchEvent pme) { pmotionX = emotionX; pmotionY = emotionY; motionX = pme.motionX[0]; @@ -2191,6 +2372,8 @@ public class PApplet extends Activity implements PConstants, Runnable { mouseX = pme.mouseX[0]; mouseY = pme.mouseY[0]; + // *** because removed from PApplet + boolean firstMotion = false; // this used to only be called on mouseMoved and mouseDragged // change it back if people run into trouble if (firstMotion) { @@ -2333,6 +2516,15 @@ public class PApplet extends Activity implements PConstants, Runnable { emouseY = mouseY; } } + */ + + + // Added in API 11, so defined here: Constant Value: 4096 (0x00001000) + static final int META_CTRL_ON = 4096; + // Added in API 11, so defined here: 65536 (0x00010000) + static final int META_META_ON = 65536; + + int motionPointerId; /** @@ -2340,15 +2532,82 @@ public class PApplet extends Activity implements PConstants, Runnable { * called, the events will be queued up until drawing is complete. * If noLoop() has been called, then events will happen immediately. */ - protected void nativeMotionEvent(MotionEvent event) { - enqueueMotionEvent(event); + protected void nativeMotionEvent(android.view.MotionEvent motionEvent) { +// enqueueMotionEvent(event); +// +// // this will be the last event in the list +// AndroidTouchEvent pme = motionEventQueue[motionEventCount + historyCount]; +// pme.setAction(event.getAction()); +// pme.setNumPointers(event.getPointerCount()); +// pme.setPointers(event); +// +// // historical events happen before the 'current' values +// if (pme.action == MotionEvent.ACTION_MOVE && historyCount > 0) { +// for (int i = 0; i < historyCount; i++) { +// AndroidTouchEvent hist = motionEventQueue[motionEventCount++]; +// hist.setAction(event.getAction()); +// hist.setNumPointers(event.getPointerCount()); +// hist.setPointers(event, i); +// } +// } - // if not looping, then remove from the queue immediately - // in this case, the queue serves as a temporary safe place for the events - // to be unpacked into individual events (instead of mixed w/ history) - if (!looping) { - dequeueMotionEvents(); + // ACTION_HOVER_ENTER and ACTION_HOVER_EXIT are passed into + // onGenericMotionEvent(android.view.MotionEvent) + // if we want to implement mouseEntered/Exited + + // http://developer.android.com/reference/android/view/MotionEvent.html + // http://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.html + // http://www.techrepublic.com/blog/app-builder/use-androids-gesture-detector-to-translate-a-swipe-into-an-event/1577 + + int metaState = motionEvent.getMetaState(); + int modifiers = 0; + if ((metaState & android.view.KeyEvent.META_SHIFT_ON) != 0) { + modifiers |= Event.SHIFT; } + if ((metaState & META_CTRL_ON) != 0) { + modifiers |= Event.CTRL; + } + if ((metaState & META_META_ON) != 0) { + modifiers |= Event.META; + } + if ((metaState & android.view.KeyEvent.META_ALT_ON) != 0) { + modifiers |= Event.ALT; + } + + int clickCount = 1; // not really set... (i.e. not catching double taps) + int index; + + // MotionEvent.html -> getButtonState() does BUTTON_PRIMARY, SECONDARY, TERTIARY + // use this for left/right/etc + switch (motionEvent.getAction()) { + case MotionEvent.ACTION_DOWN: + motionPointerId = motionEvent.getPointerId(0); + postEvent(new MouseEvent(motionEvent, motionEvent.getEventTime(), + MouseEvent.PRESS, modifiers, + (int) motionEvent.getX(), (int) motionEvent.getY(), + LEFT, clickCount)); + break; + case MotionEvent.ACTION_MOVE: +// int historySize = motionEvent.getHistorySize(); + index = motionEvent.findPointerIndex(motionPointerId); + if (index != -1) { + postEvent(new MouseEvent(motionEvent, motionEvent.getEventTime(), + MouseEvent.DRAG, modifiers, + (int) motionEvent.getX(index), (int) motionEvent.getY(index), + LEFT, clickCount)); + } + break; + case MotionEvent.ACTION_UP: + index = motionEvent.findPointerIndex(motionPointerId); + if (index != -1) { + postEvent(new MouseEvent(motionEvent, motionEvent.getEventTime(), + MouseEvent.RELEASE, modifiers, + (int) motionEvent.getX(index), (int) motionEvent.getY(index), + LEFT, clickCount)); + } + break; + } + //postEvent(pme); } @@ -2362,6 +2621,11 @@ public class PApplet extends Activity implements PConstants, Runnable { public void mouseMoved() { } + public void mouseEntered() { } + + public void mouseExited() { } + + ////////////////////////////////////////////////////////////// @@ -2386,26 +2650,26 @@ public class PApplet extends Activity implements PConstants, Runnable { ////////////////////////////////////////////////////////////// - KeyEvent[] keyEventQueue = new KeyEvent[10]; - int keyEventCount; - - protected void enqueueKeyEvent(KeyEvent e) { - synchronized (keyEventQueue) { - if (keyEventCount == keyEventQueue.length) { - keyEventQueue = (KeyEvent[]) expand(keyEventQueue); - } - keyEventQueue[keyEventCount++] = e; - } - } - - protected void dequeueKeyEvents() { - synchronized (keyEventQueue) { - for (int i = 0; i < keyEventCount; i++) { - handleKeyEvent(keyEventQueue[i]); - } - keyEventCount = 0; - } - } +// KeyEvent[] keyEventQueue = new KeyEvent[10]; +// int keyEventCount; +// +// protected void enqueueKeyEvent(KeyEvent e) { +// synchronized (keyEventQueue) { +// if (keyEventCount == keyEventQueue.length) { +// keyEventQueue = (KeyEvent[]) expand(keyEventQueue); +// } +// keyEventQueue[keyEventCount++] = e; +// } +// } +// +// protected void dequeueKeyEvents() { +// synchronized (keyEventQueue) { +// for (int i = 0; i < keyEventCount; i++) { +// handleKeyEvent(keyEventQueue[i]); +// } +// keyEventCount = 0; +// } +// } protected void handleKeyEvent(KeyEvent event) { @@ -2414,11 +2678,11 @@ public class PApplet extends Activity implements PConstants, Runnable { keyCode = event.getKeyCode(); switch (event.getAction()) { - case KeyEvent.PRESSED: + case KeyEvent.PRESS: keyPressed = true; keyPressed(); break; - case KeyEvent.RELEASED: + case KeyEvent.RELEASE: keyPressed = false; keyReleased(); break; @@ -2428,7 +2692,7 @@ public class PApplet extends Activity implements PConstants, Runnable { // if someone else wants to intercept the key, they should // set key to zero (or something besides the "ESC"). - if (event.getAction() == KeyEvent.PRESSED && + if (event.getAction() == KeyEvent.PRESS && event.getKeyCode() == android.view.KeyEvent.KEYCODE_BACK) { exit(); } @@ -2449,9 +2713,9 @@ public class PApplet extends Activity implements PConstants, Runnable { int keAction = 0; int action = event.getAction(); if (action == android.view.KeyEvent.ACTION_DOWN) { - keAction = KeyEvent.PRESSED; + keAction = KeyEvent.PRESS; } else if (action == android.view.KeyEvent.ACTION_UP) { - keAction = KeyEvent.RELEASED; + keAction = KeyEvent.RELEASE; } // TODO set up proper key modifier handling @@ -2468,11 +2732,7 @@ public class PApplet extends Activity implements PConstants, Runnable { } } - if (looping) { - enqueueKeyEvent(ke); - } else { - handleKeyEvent(ke); - } + postEvent(ke); } @@ -7774,6 +8034,12 @@ public class PApplet extends Activity implements PConstants, Runnable { } + public void arc(float a, float b, float c, float d, + float start, float stop, int mode) { + g.arc(a, b, c, d, start, stop, mode); + } + + public void box(float size) { g.box(size); } diff --git a/android/core/src/processing/core/PConstants.java b/android/core/src/processing/core/PConstants.java index 8e2339973..1263e038a 100644 --- a/android/core/src/processing/core/PConstants.java +++ b/android/core/src/processing/core/PConstants.java @@ -167,13 +167,6 @@ public interface PConstants { public final static int DODGE = 1 << 12; public final static int BURN = 1 << 13; - // colour component bitmasks - - public static final int ALPHA_MASK = 0xff000000; - public static final int RED_MASK = 0x00ff0000; - public static final int GREEN_MASK = 0x0000ff00; - public static final int BLUE_MASK = 0x000000ff; - // for messages @@ -262,6 +255,13 @@ public interface PConstants { static final int CENTER_DIAMETER = 3; + // arc drawing modes + + //static final int OPEN = 1; // shared + static final int CHORD = 2; + static final int PIE = 3; + + // vertically alignment modes for text /** Default vertical alignment for text placement */ diff --git a/android/core/src/processing/core/PGraphics.java b/android/core/src/processing/core/PGraphics.java index 4d8b45990..bdd897ff9 100644 --- a/android/core/src/processing/core/PGraphics.java +++ b/android/core/src/processing/core/PGraphics.java @@ -1995,6 +1995,12 @@ public class PGraphics extends PImage implements PConstants { */ public void arc(float a, float b, float c, float d, float start, float stop) { + arc(a, b, c, d, start, stop, 0); + } + + + public void arc(float a, float b, float c, float d, + float start, float stop, int mode) { float x = a; float y = b; float w = c; @@ -2015,11 +2021,23 @@ public class PGraphics extends PImage implements PConstants { y = b - d/2f; } - // make sure this loop will exit before starting while - if (Float.isInfinite(start) || Float.isInfinite(stop)) return; - while (stop < start) stop += TWO_PI; + // make sure the loop will exit before starting while + if (!Float.isInfinite(start) && !Float.isInfinite(stop)) { + // ignore equal and degenerate cases + if (stop > start) { + // make sure that we're starting at a useful point + while (start < 0) { + start += TWO_PI; + stop += TWO_PI; + } - arcImpl(x, y, w, h, start, stop); + if (stop - start > TWO_PI) { + start = 0; + stop = TWO_PI; + } + arcImpl(x, y, w, h, start, stop, mode); + } + } } @@ -2030,7 +2048,8 @@ public class PGraphics extends PImage implements PConstants { * and the user will still collect $200. */ protected void arcImpl(float x, float y, float w, float h, - float start, float stop) { + float start, float stop, int mode) { + showMissingWarning("arc"); } diff --git a/android/core/src/processing/core/PImage.java b/android/core/src/processing/core/PImage.java index 71ecf0dd2..1fd29b3bd 100644 --- a/android/core/src/processing/core/PImage.java +++ b/android/core/src/processing/core/PImage.java @@ -99,6 +99,12 @@ public class PImage implements PConstants, Cloneable { private int[] blurKernel; private int[][] blurMult; + // colour component bitmasks (moved from PConstants in 2.0b7) + public static final int ALPHA_MASK = 0xff000000; + public static final int RED_MASK = 0x00ff0000; + public static final int GREEN_MASK = 0x0000ff00; + public static final int BLUE_MASK = 0x000000ff; + ////////////////////////////////////////////////////////////// diff --git a/android/core/src/processing/event/Event.java b/android/core/src/processing/event/Event.java index 3b402e088..32bf175c2 100644 --- a/android/core/src/processing/event/Event.java +++ b/android/core/src/processing/event/Event.java @@ -29,12 +29,20 @@ public class Event { 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; + // These correspond to the java.awt.Event modifiers (not to be confused with + // the newer getModifiersEx), though they're not guaranteed to in the future. + static public final int SHIFT = 1 << 0; + static public final int CTRL = 1 << 1; + static public final int META = 1 << 2; + static public final int ALT = 1 << 3; protected int modifiers; + // Types of events. As with all constants in Processing, brevity's preferred. + static public final int KEY = 1; + static public final int MOUSE = 2; + static public final int TOUCH = 3; + protected int flavor; + public Event(Object nativeObject, long millis, int action, int modifiers) { this.nativeObject = nativeObject; @@ -44,6 +52,18 @@ public class Event { } + public int getFlavor() { + return flavor; + } + + + /** + * Get the platform-native event object. This might be the java.awt event + * on the desktop, though if you're using OpenGL on the desktop it'll be a + * NEWT event that JOGL uses. Android events are something else altogether. + * Bottom line, use this only if you know what you're doing, and don't make + * assumptions about the class type. + */ public Object getNative() { return nativeObject; } @@ -85,21 +105,21 @@ public class Event { public boolean isShiftDown() { - return (modifiers & SHIFT_MASK) != 0; + return (modifiers & SHIFT) != 0; } public boolean isControlDown() { - return (modifiers & CTRL_MASK) != 0; + return (modifiers & CTRL) != 0; } public boolean isMetaDown() { - return (modifiers & META_MASK) != 0; + return (modifiers & META) != 0; } public boolean isAltDown() { - return (modifiers & ALT_MASK) != 0; + return (modifiers & ALT) != 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 90c69719d..10bbba92a 100644 --- a/android/core/src/processing/event/KeyEvent.java +++ b/android/core/src/processing/event/KeyEvent.java @@ -24,9 +24,9 @@ package processing.event; public class KeyEvent extends Event { - static public final int PRESSED = 1; - static public final int RELEASED = 2; - static public final int TYPED = 3; + static public final int PRESS = 1; + static public final int RELEASE = 2; + static public final int TYPE = 3; char key; int keyCode; @@ -36,6 +36,7 @@ public class KeyEvent extends Event { long millis, int action, int modifiers, char key, int keyCode) { super(nativeObject, millis, action, modifiers); + this.flavor = KEY; this.key = key; this.keyCode = keyCode; } diff --git a/android/core/src/processing/event/MouseEvent.java b/android/core/src/processing/event/MouseEvent.java index 9a727a8d3..408ef2e95 100644 --- a/android/core/src/processing/event/MouseEvent.java +++ b/android/core/src/processing/event/MouseEvent.java @@ -26,13 +26,13 @@ package processing.event; 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; + static public final int PRESS = 1; + static public final int RELEASE = 2; + static public final int CLICK = 3; + static public final int DRAG = 4; + static public final int MOVE = 5; + static public final int ENTER = 6; + static public final int EXIT = 7; protected int x, y; protected int button; @@ -50,6 +50,7 @@ public class MouseEvent extends Event { long millis, int action, int modifiers, int x, int y, int button, int clickCount) { super(nativeObject, millis, action, modifiers); + this.flavor = MOUSE; this.x = x; this.y = y; this.button = button; diff --git a/android/core/src/processing/event/TouchEvent.java b/android/core/src/processing/event/TouchEvent.java index 50443ca26..f082e539a 100644 --- a/android/core/src/processing/event/TouchEvent.java +++ b/android/core/src/processing/event/TouchEvent.java @@ -23,9 +23,24 @@ package processing.event; +/* +http://developer.android.com/guide/topics/ui/ui-events.html +http://developer.android.com/reference/android/view/MotionEvent.html +http://developer.apple.com/library/safari/#documentation/UserExperience/Reference/TouchEventClassReference/TouchEvent/TouchEvent.html +http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIGestureRecognizer_Class/Reference/Reference.html#//apple_ref/occ/cl/UIGestureRecognizer + +Apple's high-level gesture names: +tap +pinch +rotate +swipe +pan +longpress +*/ public class TouchEvent extends Event { public TouchEvent(Object nativeObject, long millis, int action, int modifiers) { super(nativeObject, millis, action, modifiers); + this.flavor = TOUCH; } -} \ No newline at end of file +} diff --git a/android/todo.txt b/android/todo.txt index c33b2e898..be3a9ad62 100644 --- a/android/todo.txt +++ b/android/todo.txt @@ -3,6 +3,25 @@ X removing default imports for X android.view.MotionEvent, android.view.KeyEvent,android.graphics.Bitmap X due to conflicts w/ the new p5 event system +cleaning/earlier +A Defects in the tessellation of SVG shapes in A3D +A http://code.google.com/p/processing/issues/detail?id=291 + + +_ Finish implementation of OPEN and CHORD drawing modes for arc() +_ http://code.google.com/p/processing/issues/detail?id=1405 + +_ implement blendMode() for Android +_ should be fairly straightforward given Java2D implementation +_ http://code.google.com/p/processing/issues/detail?id=1386 + +_ Update documentation and tools for Android SDK Tools revision 21 +_ http://code.google.com/p/processing/issues/detail?id=1398 + +_ re-implement to use Fragment API +_ and what about daydream or widgets or whatever? +_ http://code.google.com/p/processing/issues/detail?id=1335 + _ implement Android version of command line tools _ http://code.google.com/p/processing/issues/detail?id=1323 @@ -30,6 +49,7 @@ _ PApplet.match(scrubbed, processing.mode.java.JavaBuild.SIZE_REGEX); _ test libraries on android _ no ES2 in the emulator, and no error reported in the PDE +_ http://code.google.com/p/processing/issues/detail?id=1059 _ problem is probably that the error comes via E/AndroidRuntime _ java.lang.RuntimeException: Unable to start activity ComponentInfo{processing.test.fisheye/processing.test.fisheye.FishEye}: java.lang.RuntimeException: P3D: OpenGL ES 2.0 is not supported by this device. diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 597207ea7..02cbf5bb5 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -514,7 +514,12 @@ public class PApplet extends Applet *
* Just using (frameCount == 0) won't work since mouseXxxxx() * may not be called until a couple frames into things. + *
+ * @deprecated Please refrain from using this variable, it will be removed + * from future releases of Processing because it cannot be used consistently + * across platforms and input methods. */ + @Deprecated public boolean firstMouse; /** @@ -529,9 +534,8 @@ public class PApplet extends Applet * *