From 8815245ebb9efc6d49052ff1fb34a3ee6ecfcc6b Mon Sep 17 00:00:00 2001
From: Sven Gothel
* The index for the element of multiple-pointer arrays represents the pointer which triggered the event
* is passed via actionIdx.
- *
+ * The given pointer names, pNames
, are mapped to consecutive pointer IDs starting w/ 0
+ * using a hash-map if normalPNames
is false
.
+ * Otherwise a simple int
to short
type cast is performed.
+ *
normalPIDs
is true
.
+ * Otherwise we hash-map the values during state pressed to retrieve the normal ID.
* @param pX X-axis for each pointer (multiple pointer)
* @param pY Y-axis for each pointer (multiple pointer)
* @param pPressure Pressure for each pointer (multiple pointer)
* @param maxPressure Maximum pointer pressure for all pointer
*/
- public void doPointerEvent(boolean enqueue, boolean wait,
- int[] pTypesOrdinal, short eventType, int modifiers,
- int actionIdx, short[] pID,
- int[] pX, int[] pY, float[] pPressure, float maxPressure,
- float[] rotationXYZ, float rotationScale) {
+ public final void doPointerEvent(boolean enqueue, boolean wait,
+ final PointerType[] pTypes, short eventType, int modifiers,
+ int actionIdx, boolean normalPNames, final int[] pNames,
+ final int[] pX, final int[] pY, float[] pPressure,
+ float maxPressure, final float[] rotationXYZ, final float rotationScale) {
+ final int pCount = pNames.length;
+ final short[] pIDs = new short[pCount];
+ for(int i=0; i+ * The index for the element of multiple-pointer arrays represents the pointer which triggered the event + * is passed via actionIdx. + *
+ * + * @param enqueue if true, event will be {@link #enqueueEvent(boolean, NEWTEvent) enqueued}, + * otherwise {@link #consumeEvent(NEWTEvent) consumed} directly. + * @param wait if true wait until {@link #consumeEvent(NEWTEvent) consumed}. + * @param pTypes {@link MouseEvent.PointerType} for each pointer (multiple pointer) + * @param eventType + * @param modifiers + * @param pActionIdx index of multiple-pointer arrays representing the pointer which triggered the event + * @param pID Pointer ID for each pointer (multiple pointer). We assume consecutive pointerIDs starting w/ 0. + * @param pX X-axis for each pointer (multiple pointer) + * @param pY Y-axis for each pointer (multiple pointer) + * @param pPressure Pressure for each pointer (multiple pointer) + * @param maxPressure Maximum pointer pressure for all pointer + */ + public final void doPointerEvent(boolean enqueue, boolean wait, + final PointerType[] pTypes, short eventType, int modifiers, + int pActionIdx, final short[] pID, final int[] pX, final int[] pY, final float[] pPressure, + float maxPressure, final float[] rotationXYZ, float rotationScale) { final long when = System.currentTimeMillis(); - final int pointerCount = pTypesOrdinal.length; + final int pCount = pTypes.length; - if( 0 > actionIdx || actionIdx >= pointerCount) { - throw new IllegalArgumentException("actionIdx out of bounds [0.."+(pointerCount-1)+"]"); + if( 0 > pActionIdx || pActionIdx >= pCount) { + throw new IllegalArgumentException("actionIdx out of bounds [0.."+(pCount-1)+"]"); } - if( 0 < actionIdx ) { + if( 0 < pActionIdx ) { // swap values to make idx 0 the triggering pointer { - final int aType = pTypesOrdinal[actionIdx]; - pTypesOrdinal[actionIdx] = pTypesOrdinal[0]; - pTypesOrdinal[0] = aType; + final PointerType aType = pTypes[pActionIdx]; + pTypes[pActionIdx] = pTypes[0]; + pTypes[0] = aType; } { - final short s = pID[actionIdx]; - pID[actionIdx] = pID[0]; + final short s = pID[pActionIdx]; + pID[pActionIdx] = pID[0]; pID[0] = s; } { - int s = pX[actionIdx]; - pX[actionIdx] = pX[0]; + int s = pX[pActionIdx]; + pX[pActionIdx] = pX[0]; pX[0] = s; - s = pY[actionIdx]; - pY[actionIdx] = pY[0]; + s = pY[pActionIdx]; + pY[pActionIdx] = pY[0]; pY[0] = s; } { - final float aPress = pPressure[actionIdx]; - pPressure[actionIdx] = pPressure[0]; + final float aPress = pPressure[pActionIdx]; + pPressure[pActionIdx] = pPressure[0]; pPressure[0] = aPress; } } - final PointerType[] pointerType = new PointerType[pointerCount]; - for(int i=pointerCount-1; i>=0; i--) { - pointerType[i] = PointerType.valueOf(pTypesOrdinal[i]); - } final short id = pID[0]; final short button; { @@ -2548,7 +2608,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer pPressure[0] = maxPressure; } pState1.buttonPressedMask |= InputEvent.getButtonMask(button); - if( 1 == pointerCount ) { + if( 1 == pCount ) { if( when - pState1.lastButtonPressTime < MouseEvent.getClickTimeout() ) { pState1.lastButtonClickCount++; } else { @@ -2556,16 +2616,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } pState1.lastButtonPressTime = when; pState1.buttonPressed = button; - e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, pState1.lastButtonClickCount, rotationXYZ, rotationScale); } else { - e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, (short)1, rotationXYZ, rotationScale); } break; case MouseEvent.EVENT_MOUSE_RELEASED: - if( 1 == pointerCount ) { - e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + if( 1 == pCount ) { + e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, pState1.lastButtonClickCount, rotationXYZ, rotationScale); if( when - pState1.lastButtonPressTime >= MouseEvent.getClickTimeout() ) { pState1.lastButtonClickCount = (short)0; @@ -2573,7 +2633,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } pState1.buttonPressed = 0; } else { - e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, (short)1, rotationXYZ, rotationScale); } pState1.buttonPressedMask &= ~InputEvent.getButtonMask(button); @@ -2583,10 +2643,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer break; case MouseEvent.EVENT_MOUSE_MOVED: if ( 0 != pState1.buttonPressedMask ) { // any button or pointer move -> drag - e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when, modifiers, pointerType, pID, + e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, pState1.buttonPressed, (short)1, rotationXYZ, rotationScale); } else { - e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, (short)0, rotationXYZ, rotationScale); } break; @@ -2596,7 +2656,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } // Fall through intended! default: - e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, (short)0, rotationXYZ, rotationScale); } doEvent(enqueue, wait, e); // actual mouse event diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java index 23c32993f..e5d667f3e 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -33,6 +33,7 @@ import android.view.MotionEvent; import com.jogamp.common.os.AndroidVersion; import com.jogamp.newt.event.InputEvent; +import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.NEWTEvent; public class AndroidNewtEventFactory { @@ -252,7 +253,8 @@ public class AndroidNewtEventFactory { } } - private static void collectPointerData(MotionEvent e, int idx, final int[] x, final int[] y, final float[] pressure, short[] pointerIds, final int[] pointerTypes) { + private static void collectPointerData(MotionEvent e, int idx, final int[] x, final int[] y, final float[] pressure, + final short[] pointerIds, final MouseEvent.PointerType[] pointerTypes) { x[idx] = (int)e.getX(idx); y[idx] = (int)e.getY(idx); pressure[idx] = e.getPressure(idx); @@ -260,14 +262,14 @@ public class AndroidNewtEventFactory { if( pressure[idx] > maxPressure ) { maxPressure = pressure[idx]; } - pointerTypes[idx] = aToolType2PointerType( e.getToolType(idx) ).ordinal(); + pointerTypes[idx] = aToolType2PointerType( e.getToolType(idx) ); if(DEBUG_MOUSE_EVENT) { System.err.println("createMouseEvent: ptr-data["+idx+"] "+x[idx]+"/"+y[idx]+", pressure "+pressure[idx]+", id "+pointerIds[idx]+", type "+pointerTypes[idx]); } } public boolean sendPointerEvent(boolean enqueue, boolean wait, boolean setFocusOnDown, boolean isOnTouchEvent, - android.view.MotionEvent event, jogamp.newt.driver.android.WindowDriver newtSource) { + android.view.MotionEvent event, jogamp.newt.driver.android.WindowDriver newtSource) { if(DEBUG_MOUSE_EVENT) { System.err.println("createMouseEvent: isOnTouchEvent "+isOnTouchEvent+", "+event); } @@ -343,7 +345,7 @@ public class AndroidNewtEventFactory { final int[] y = new int[pCount]; final float[] pressure = new float[pCount]; final short[] pointerIds = new short[pCount]; - final int[] pointerTypes = new int[pCount]; + final MouseEvent.PointerType[] pointerTypes = new MouseEvent.PointerType[pCount]; if( 0 < pCount ) { if(DEBUG_MOUSE_EVENT) { System.err.println("createMouseEvent: collect ptr-data [0.."+(pCount-1)+", count "+pCount+", action "+pIndex+"], aType "+aType+", button "+button); -- cgit v1.2.3