diff options
author | Sven Gothel <[email protected]> | 2013-10-17 07:56:20 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-10-17 07:56:20 +0200 |
commit | a90bf31f8747dd38c61d518f8af4d4d4a64a8e90 (patch) | |
tree | b99e97fe8644080418e86f1e9da17b01755cfc02 /src/newt/classes/com/jogamp | |
parent | 40863632d1428de015099b5967e5136425e99f25 (diff) |
NEWT PointerEvent: Unify event processing in new doPointerEvent(..) and consumePointerEvent(..) - Unifies native mouse and Android's pointer event, ready for Win7 touch
Unify event processing in new doPointerEvent(..), which is also invoked from doMouseEvent(..),
and consumePointerEvent().
doPointerEvent(..): Validates and modifies event data and finally creates the event,
where consumePointerEvent(..) calls gesture handlers and may synthesize events.
Unifies native mouse and Android's pointer event, ready for Win7 touch.
AndroidNewtEventFactory calls doPointerEvent(..) directly.
Removed lots of duplicated pointer event handling code.
Diffstat (limited to 'src/newt/classes/com/jogamp')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/event/MouseEvent.java | 98 |
1 files changed, 21 insertions, 77 deletions
diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index fd5e27bdd..cb9e7a290 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -145,9 +145,17 @@ public class MouseEvent extends InputEvent super(eventType, source, when, modifiers); this.x = new int[]{x}; this.y = new int[]{y}; - this.pressure = constMousePressure; + switch(eventType) { + case EVENT_MOUSE_CLICKED: + case EVENT_MOUSE_PRESSED: + case EVENT_MOUSE_DRAGGED: + this.pressure = constMousePressure1; + break; + default: + this.pressure = constMousePressure0; + } this.maxPressure= 1.0f; - this.pointerID = constMousePointerIDs; + this.pointerID = new short[] { (short)(button - 1) }; this.clickCount=clickCount; this.button=button; this.rotationXYZ = rotationXYZ; @@ -213,70 +221,6 @@ public class MouseEvent extends InputEvent } /** - * Factory for a multiple-pointer event. - * <p> - * The index for the multiple-pointer fields representing the triggering pointer is passed via <i>actionIdx</i>. - * If <i>actionIdx</i> is not <code>0</code>, all multiple-pointer fields values of index <code>0</code> - * and <i>actionIdx</i> are swapped so that the pointer-index 0 will represent the triggering pointer. - * </p> - * <p> - * See details for <a href="#multiPtrEvent">multiple-pointer events</a>. - * </p> - * - * @param eventType - * @param source - * @param when - * @param modifiers - * @param actionIdx index of multiple-pointer arrays representing the pointer which triggered the event - * @param pointerType PointerType for each pointer (multiple pointer) - * @param pointerID Pointer ID for each pointer (multiple pointer). IDs start w/ 0 and are consecutive numbers. - * @param x X-axis for each pointer (multiple pointer) - * @param y Y-axis for each pointer (multiple pointer) - * @param pressure Pressure for each pointer (multiple pointer) - * @param maxPressure Maximum pointer pressure for all pointer - * @param button Corresponding mouse-button - * @param clickCount Mouse-button click-count - * @param rotationXYZ Rotation of all axis - * @param rotationScale Rotation scale - */ - public static MouseEvent create(short eventType, Object source, long when, int modifiers, - int actionIdx, PointerType pointerType[], short[] pointerID, - int[] x, int[] y, float[] pressure, float maxPressure, - short button, short clickCount, float[] rotationXYZ, float rotationScale) { - if( 0 <= actionIdx && actionIdx < pointerType.length) { - if( 0 < actionIdx ) { - { - final PointerType aType = pointerType[actionIdx]; - pointerType[actionIdx] = pointerType[0]; - pointerType[0] = aType; - } - { - final short s = pointerID[actionIdx]; - pointerID[actionIdx] = pointerID[0]; - pointerID[0] = s; - } - { - int s = x[actionIdx]; - x[actionIdx] = x[0]; - x[0] = s; - s = y[actionIdx]; - y[actionIdx] = y[0]; - y[0] = s; - } - { - final float aPress = pressure[actionIdx]; - pressure[actionIdx] = pressure[0]; - pressure[0] = aPress; - } - } - return new MouseEvent(eventType, source, when, modifiers, - pointerType, pointerID, x, y, pressure, maxPressure, - button, clickCount, rotationXYZ, rotationScale); - } - throw new IllegalArgumentException("actionIdx out of bounds [0.."+(pointerType.length-1)+"]"); - } - - /** * @return the count of pointers involved in this event */ public final int getPointerCount() { @@ -528,15 +472,15 @@ public class MouseEvent extends InputEvent public static String getEventTypeString(short type) { switch(type) { - case EVENT_MOUSE_CLICKED: return "EVENT_MOUSE_CLICKED"; - case EVENT_MOUSE_ENTERED: return "EVENT_MOUSE_ENTERED"; - case EVENT_MOUSE_EXITED: return "EVENT_MOUSE_EXITED"; - case EVENT_MOUSE_PRESSED: return "EVENT_MOUSE_PRESSED"; - case EVENT_MOUSE_RELEASED: return "EVENT_MOUSE_RELEASED"; - case EVENT_MOUSE_MOVED: return "EVENT_MOUSE_MOVED"; - case EVENT_MOUSE_DRAGGED: return "EVENT_MOUSE_DRAGGED"; - case EVENT_MOUSE_WHEEL_MOVED: return "EVENT_MOUSE_WHEEL_MOVED"; - default: return "unknown (" + type + ")"; + case EVENT_MOUSE_CLICKED: return "EVENT_MOUSE_CLICKED"; + case EVENT_MOUSE_ENTERED: return "EVENT_MOUSE_ENTERED"; + case EVENT_MOUSE_EXITED: return "EVENT_MOUSE_EXITED"; + case EVENT_MOUSE_PRESSED: return "EVENT_MOUSE_PRESSED"; + case EVENT_MOUSE_RELEASED: return "EVENT_MOUSE_RELEASED"; + case EVENT_MOUSE_MOVED: return "EVENT_MOUSE_MOVED"; + case EVENT_MOUSE_DRAGGED: return "EVENT_MOUSE_DRAGGED"; + case EVENT_MOUSE_WHEEL_MOVED: return "EVENT_MOUSE_WHEEL_MOVED"; + default: return "unknown (" + type + ")"; } } @@ -558,8 +502,8 @@ public class MouseEvent extends InputEvent private final float rotationScale; private final float maxPressure; - private static final float[] constMousePressure = new float[]{0f}; - private static final short[] constMousePointerIDs = new short[]{0}; + private static final float[] constMousePressure0 = new float[]{0f}; + private static final float[] constMousePressure1 = new float[]{1f}; private static final PointerType[] constMousePointerTypes = new PointerType[] { PointerType.Mouse }; public static final short EVENT_MOUSE_CLICKED = 200; |