summaryrefslogtreecommitdiffstats
path: root/src/newt/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-03-24 07:08:42 +0100
committerSven Gothel <[email protected]>2013-03-24 07:08:42 +0100
commitded080fd890c21b54ba1f96d84f9e355711dc88a (patch)
treeba90a80580cf26b17731690d37ffae68da0b32e1 /src/newt/classes/jogamp
parent654a678bd7171e81ec947cafa854dad366f5041e (diff)
Newt/MouseEvent: Add 'float[3] getRotation()', getWheelScale() -> getRotationScale(), refinement of commit 18cb57246372eda72c25a5cd9a69a873bdf09489
Turns out the 'wheel' semantics are not generic enough and confining rotation values to one axis only satisfies the traditional mouse wheel. Widen the definition of 'rotation' and delivering 3-axis if supported. On NEWT/Android, we deliver the 2-axis for example, allowing to rotate around both or scrolling using both directions (-> GearsES2).
Diffstat (limited to 'src/newt/classes/jogamp')
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java35
1 files changed, 14 insertions, 21 deletions
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 83d3e7d90..21f552fdb 100644
--- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java
+++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java
@@ -45,7 +45,7 @@ public class AndroidNewtEventFactory {
private static final com.jogamp.newt.event.MouseEvent.PointerType aToolType2PointerType(int aToolType) {
switch( aToolType ) {
case MotionEvent.TOOL_TYPE_FINGER:
- return com.jogamp.newt.event.MouseEvent.PointerType.Touch;
+ return com.jogamp.newt.event.MouseEvent.PointerType.TouchScreen;
case MotionEvent.TOOL_TYPE_MOUSE:
return com.jogamp.newt.event.MouseEvent.PointerType.Mouse;
case MotionEvent.TOOL_TYPE_STYLUS:
@@ -288,7 +288,8 @@ public class AndroidNewtEventFactory {
//
final int aType;
final short nType;
- float[] rotationXY = null;
+ final float rotationScale = touchSlop;
+ final float[] rotationXYZ = new float[] { 0f, 0f, 0f };
int rotationSource = 0; // 1 - Gesture, 2 - ACTION_SCROLL
{
final int aType0 = event.getActionMasked();
@@ -314,7 +315,9 @@ public class AndroidNewtEventFactory {
}
if( gesture2FingerScrl.isWithinGesture() ) {
- rotationXY = gesture2FingerScrl.getScrollDistanceXY();
+ final float[] rot = gesture2FingerScrl.getScrollDistanceXY();
+ rotationXYZ[0] = rot[0] / rotationScale;
+ rotationXYZ[1] = rot[1] / rotationScale;
aType = ACTION_SCROLL; // 8
rotationSource = 1;
} else {
@@ -327,30 +330,20 @@ public class AndroidNewtEventFactory {
final short clickCount = 1;
int modifiers = 0;
- if( null == rotationXY && AndroidVersion.SDK_INT >= 12 && ACTION_SCROLL == aType ) { // API Level 12
- rotationXY = new float[] { event.getAxisValue(android.view.MotionEvent.AXIS_X),
- event.getAxisValue(android.view.MotionEvent.AXIS_Y) };
+ if( 0 == rotationSource && AndroidVersion.SDK_INT >= 12 && ACTION_SCROLL == aType ) { // API Level 12
+ rotationXYZ[0] = event.getAxisValue(android.view.MotionEvent.AXIS_X) / rotationScale;
+ rotationXYZ[1] = event.getAxisValue(android.view.MotionEvent.AXIS_Y) / rotationScale;
rotationSource = 2;
}
- final float rotation;
- final float rotationScale = touchSlop;
- if( null != rotationXY ) {
- final float _rotation;
- if( rotationXY[0]*rotationXY[0] > rotationXY[1]*rotationXY[1] ) {
+ if( 0 != rotationSource ) {
+ if( rotationXYZ[0]*rotationXYZ[0] > rotationXYZ[1]*rotationXYZ[1] ) {
// Horizontal
modifiers |= com.jogamp.newt.event.InputEvent.SHIFT_MASK;
- _rotation = rotationXY[0];
- } else {
- // Vertical
- _rotation = rotationXY[1];
}
- rotation = _rotation / rotationScale;
if(DEBUG_MOUSE_EVENT) {
- System.err.println("createMouseEvent: Scroll "+rotationXY[0]+"/"+rotationXY[1]+" -> "+_rotation+" / "+rotationScale+" -> "+rotation+" scaled -- mods "+modifiers+", source "+rotationSource);
+ System.err.println("createMouseEvent: Scroll "+rotationXYZ[0]+"/"+rotationXYZ[1]+", "+rotationScale+", mods "+modifiers+", source "+rotationSource);
}
- } else {
- rotation = 0.0f;
}
//
@@ -414,14 +407,14 @@ public class AndroidNewtEventFactory {
final com.jogamp.newt.event.MouseEvent me1 = new com.jogamp.newt.event.MouseEvent(
nType, src, unixTime,
modifiers, x, y, pressure, maxPressure, pointerTypes, pointerIds,
- clickCount, button, rotation, rotationScale);
+ clickCount, button, rotationXYZ, rotationScale);
if( com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED == nType ) {
return new com.jogamp.newt.event.MouseEvent[] { me1,
new com.jogamp.newt.event.MouseEvent(
com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED,
src, unixTime, modifiers, x, y, pressure, maxPressure, pointerTypes, pointerIds,
- clickCount, button, rotation, rotationScale) };
+ clickCount, button, rotationXYZ, rotationScale) };
} else {
return new com.jogamp.newt.event.MouseEvent[] { me1 };
}