|
|
@ -35,11 +35,13 @@ public class AndroidInput extends GLSurfaceView implements TouchInput, |
|
|
|
final private static int MAX_EVENTS = 1024; |
|
|
|
final private static int MAX_EVENTS = 1024; |
|
|
|
|
|
|
|
|
|
|
|
final private RingBuffer<TouchEvent> eventQueue = new RingBuffer<TouchEvent>(MAX_EVENTS); |
|
|
|
final private RingBuffer<TouchEvent> eventQueue = new RingBuffer<TouchEvent>(MAX_EVENTS); |
|
|
|
|
|
|
|
final private RingBuffer<TouchEvent> eventPoolUnConsumed = new RingBuffer<TouchEvent>(MAX_EVENTS); |
|
|
|
final private RingBuffer<TouchEvent> eventPool = new RingBuffer<TouchEvent>(MAX_EVENTS); |
|
|
|
final private RingBuffer<TouchEvent> eventPool = new RingBuffer<TouchEvent>(MAX_EVENTS); |
|
|
|
final private HashMap<Integer, Vector2f> lastPositions = new HashMap<Integer, Vector2f>(); |
|
|
|
final private HashMap<Integer, Vector2f> lastPositions = new HashMap<Integer, Vector2f>(); |
|
|
|
|
|
|
|
|
|
|
|
public boolean fireMouseEvents = true; |
|
|
|
public boolean fireMouseEvents = true; |
|
|
|
public boolean fireKeyboardEvents = false; |
|
|
|
public boolean fireKeyboardEvents = false; |
|
|
|
|
|
|
|
public boolean dontSendHistory = false; |
|
|
|
|
|
|
|
|
|
|
|
private ScaleGestureDetector scaledetector; |
|
|
|
private ScaleGestureDetector scaledetector; |
|
|
|
private GestureDetector detector; |
|
|
|
private GestureDetector detector; |
|
|
@ -169,9 +171,36 @@ public class AndroidInput extends GLSurfaceView implements TouchInput, |
|
|
|
return getNextFreeTouchEvent(false); |
|
|
|
return getNextFreeTouchEvent(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Fetches a touch event from the reuse pool |
|
|
|
|
|
|
|
* @param wait |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
private TouchEvent getNextFreeTouchEvent(boolean wait) |
|
|
|
private TouchEvent getNextFreeTouchEvent(boolean wait) |
|
|
|
{ |
|
|
|
{ |
|
|
|
TouchEvent evt; |
|
|
|
TouchEvent evt = null; |
|
|
|
|
|
|
|
synchronized(eventPoolUnConsumed) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int size = eventPoolUnConsumed.size(); |
|
|
|
|
|
|
|
while (size > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
evt = eventPoolUnConsumed.pop(); |
|
|
|
|
|
|
|
if (!evt.isConsumed()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
eventPoolUnConsumed.push(evt); |
|
|
|
|
|
|
|
evt = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
size--; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (evt == null) |
|
|
|
|
|
|
|
{ |
|
|
|
if (eventPool.isEmpty() && wait) |
|
|
|
if (eventPool.isEmpty() && wait) |
|
|
|
{ |
|
|
|
{ |
|
|
|
logger.warning("eventPool buffer underrun"); |
|
|
|
logger.warning("eventPool buffer underrun"); |
|
|
@ -185,17 +214,24 @@ public class AndroidInput extends GLSurfaceView implements TouchInput, |
|
|
|
try { Thread.sleep(50); } catch (InterruptedException e) { } |
|
|
|
try { Thread.sleep(50); } catch (InterruptedException e) { } |
|
|
|
} |
|
|
|
} |
|
|
|
while (isEmpty); |
|
|
|
while (isEmpty); |
|
|
|
|
|
|
|
synchronized(eventPool) |
|
|
|
|
|
|
|
{ |
|
|
|
evt = eventPool.pop(); |
|
|
|
evt = eventPool.pop(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else if (eventPool.isEmpty()) |
|
|
|
else if (eventPool.isEmpty()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
evt = new TouchEvent(); |
|
|
|
evt = new TouchEvent(); |
|
|
|
logger.warning("eventPool buffer underrun"); |
|
|
|
logger.warning("eventPool buffer underrun"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
synchronized(eventPool) |
|
|
|
{ |
|
|
|
{ |
|
|
|
evt = eventPool.pop(); |
|
|
|
evt = eventPool.pop(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return evt; |
|
|
|
return evt; |
|
|
|
} |
|
|
|
} |
|
|
|
/** |
|
|
|
/** |
|
|
@ -211,16 +247,36 @@ public class AndroidInput extends GLSurfaceView implements TouchInput, |
|
|
|
this.detector.onTouchEvent(event); |
|
|
|
this.detector.onTouchEvent(event); |
|
|
|
this.scaledetector.onTouchEvent(event); |
|
|
|
this.scaledetector.onTouchEvent(event); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final int historySize = event.getHistorySize(); |
|
|
|
|
|
|
|
final int pointerCount = event.getPointerCount(); |
|
|
|
|
|
|
|
|
|
|
|
switch (event.getAction()) |
|
|
|
switch (event.getAction()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case MotionEvent.ACTION_DOWN: |
|
|
|
case MotionEvent.ACTION_DOWN: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!dontSendHistory) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Process history
|
|
|
|
|
|
|
|
for (int h = 0; h < historySize; h++) |
|
|
|
|
|
|
|
{ |
|
|
|
// Convert all pointers into events
|
|
|
|
// Convert all pointers into events
|
|
|
|
for (int p = 0; p < event.getPointerCount(); p++) |
|
|
|
for (int p = 0; p < pointerCount; p++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
touch = getNextFreeTouchEvent(); |
|
|
|
|
|
|
|
touch.set(Type.DOWN, event.getHistoricalX(p, h), this.getHeight() - event.getHistoricalY(p, h), 0, 0); |
|
|
|
|
|
|
|
touch.setPointerId(event.getPointerId(p)); |
|
|
|
|
|
|
|
touch.setTime(event.getHistoricalEventTime(h)); |
|
|
|
|
|
|
|
touch.setPressure(event.getHistoricalPressure(p, h)); |
|
|
|
|
|
|
|
processEvent(touch); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Convert all pointers into events
|
|
|
|
|
|
|
|
for (int p = 0; p < pointerCount; p++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
touch = getNextFreeTouchEvent(); |
|
|
|
touch = getNextFreeTouchEvent(); |
|
|
|
touch.set(Type.DOWN, event.getX(p), event.getY(p), 0, 0); |
|
|
|
touch.set(Type.DOWN, event.getX(p), this.getHeight() - event.getY(p), 0, 0); |
|
|
|
touch.setPointerId(event.getPointerId(p)); |
|
|
|
touch.setPointerId(event.getPointerId(p)); |
|
|
|
touch.setTime(event.getEventTime()); |
|
|
|
touch.setTime(event.getEventTime()); |
|
|
|
touch.setPressure(event.getPressure(p)); |
|
|
|
touch.setPressure(event.getPressure(p)); |
|
|
@ -232,11 +288,30 @@ public class AndroidInput extends GLSurfaceView implements TouchInput, |
|
|
|
|
|
|
|
|
|
|
|
case MotionEvent.ACTION_UP: |
|
|
|
case MotionEvent.ACTION_UP: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!dontSendHistory) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Process history
|
|
|
|
|
|
|
|
for (int h = 0; h < historySize; h++) |
|
|
|
|
|
|
|
{ |
|
|
|
// Convert all pointers into events
|
|
|
|
// Convert all pointers into events
|
|
|
|
for (int p = 0; p < event.getPointerCount(); p++) |
|
|
|
for (int p = 0; p < pointerCount; p++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
touch = getNextFreeTouchEvent(); |
|
|
|
|
|
|
|
touch.set(Type.UP, event.getHistoricalX(p, h), this.getHeight() - event.getHistoricalY(p, h), 0, 0); |
|
|
|
|
|
|
|
touch.setPointerId(event.getPointerId(p)); |
|
|
|
|
|
|
|
touch.setTime(event.getHistoricalEventTime(h)); |
|
|
|
|
|
|
|
touch.setPressure(event.getHistoricalPressure(p, h)); |
|
|
|
|
|
|
|
processEvent(touch); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Convert all pointers into events
|
|
|
|
|
|
|
|
for (int p = 0; p < pointerCount; p++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
touch = getNextFreeTouchEvent(); |
|
|
|
touch = getNextFreeTouchEvent(); |
|
|
|
touch.set(Type.UP, event.getX(p), event.getY(p), 0, 0); |
|
|
|
touch.set(Type.UP, event.getX(p), this.getHeight() - event.getY(p), 0, 0); |
|
|
|
touch.setPointerId(event.getPointerId(p)); |
|
|
|
touch.setPointerId(event.getPointerId(p)); |
|
|
|
touch.setTime(event.getEventTime()); |
|
|
|
touch.setTime(event.getEventTime()); |
|
|
|
touch.setPressure(event.getPressure(p)); |
|
|
|
touch.setPressure(event.getPressure(p)); |
|
|
@ -247,22 +322,50 @@ public class AndroidInput extends GLSurfaceView implements TouchInput, |
|
|
|
break; |
|
|
|
break; |
|
|
|
case MotionEvent.ACTION_MOVE: |
|
|
|
case MotionEvent.ACTION_MOVE: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!dontSendHistory) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Process history
|
|
|
|
|
|
|
|
for (int h = 0; h < historySize; h++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Convert all pointers into events
|
|
|
|
|
|
|
|
for (int p = 0; p < pointerCount; p++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Vector2f lastPos = lastPositions.get(event.getPointerId(p)); |
|
|
|
|
|
|
|
if (lastPos == null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
lastPos = new Vector2f(event.getHistoricalX(p,h ), this.getHeight() - event.getHistoricalY(p, h)); |
|
|
|
|
|
|
|
lastPositions.put(event.getPointerId(p), lastPos); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
touch = getNextFreeTouchEvent(); |
|
|
|
|
|
|
|
touch.set(Type.MOVE, event.getHistoricalX(p, h), this.getHeight() - event.getHistoricalY(p, h), |
|
|
|
|
|
|
|
event.getHistoricalX(p, h) - lastPos.x, this.getHeight() - event.getHistoricalY(p, h) - lastPos.y); |
|
|
|
|
|
|
|
touch.setPointerId(event.getPointerId(p)); |
|
|
|
|
|
|
|
touch.setTime(event.getHistoricalEventTime(h)); |
|
|
|
|
|
|
|
touch.setPressure(event.getHistoricalPressure(p, h)); |
|
|
|
|
|
|
|
processEvent(touch); |
|
|
|
|
|
|
|
lastPos.set(event.getHistoricalX(p, h), this.getHeight() - event.getHistoricalY(p, h)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Convert all pointers into events
|
|
|
|
// Convert all pointers into events
|
|
|
|
for (int p = 0; p < event.getPointerCount(); p++) |
|
|
|
for (int p = 0; p < event.getPointerCount(); p++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Vector2f lastPos = lastPositions.get(event.getPointerId(p)); |
|
|
|
Vector2f lastPos = lastPositions.get(event.getPointerId(p)); |
|
|
|
if (lastPos == null) |
|
|
|
if (lastPos == null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
lastPos = new Vector2f(event.getX(p), event.getY(p)); |
|
|
|
lastPos = new Vector2f(event.getX(p), this.getHeight() - event.getY(p)); |
|
|
|
lastPositions.put(event.getPointerId(p), lastPos); |
|
|
|
lastPositions.put(event.getPointerId(p), lastPos); |
|
|
|
} |
|
|
|
} |
|
|
|
touch = getNextFreeTouchEvent(); |
|
|
|
touch = getNextFreeTouchEvent(); |
|
|
|
touch.set(Type.MOVE, event.getX(p), event.getY(p), event.getX(p) - lastPos.x, event.getY(p) - lastPos.y); |
|
|
|
touch.set(Type.MOVE, event.getX(p), this.getHeight() - event.getY(p), event.getX(p) - lastPos.x, this.getHeight() - event.getY(p) - lastPos.y); |
|
|
|
touch.setPointerId(event.getPointerId(p)); |
|
|
|
touch.setPointerId(event.getPointerId(p)); |
|
|
|
touch.setTime(event.getEventTime()); |
|
|
|
touch.setTime(event.getEventTime()); |
|
|
|
touch.setPressure(event.getPressure(p)); |
|
|
|
touch.setPressure(event.getPressure(p)); |
|
|
|
processEvent(touch); |
|
|
|
processEvent(touch); |
|
|
|
lastPos.set(event.getX(p), event.getY(p)); |
|
|
|
lastPos.set(event.getX(p), this.getHeight() - event.getY(p)); |
|
|
|
} |
|
|
|
} |
|
|
|
bWasHandled = true; |
|
|
|
bWasHandled = true; |
|
|
|
break; |
|
|
|
break; |
|
|
@ -296,10 +399,7 @@ public class AndroidInput extends GLSurfaceView implements TouchInput, |
|
|
|
// Send the event
|
|
|
|
// Send the event
|
|
|
|
processEvent(evt); |
|
|
|
processEvent(evt); |
|
|
|
|
|
|
|
|
|
|
|
// Handle all keys ourself, except the back button (4)
|
|
|
|
// Handle all keys ourself
|
|
|
|
if (keyCode == 4) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -316,10 +416,7 @@ public class AndroidInput extends GLSurfaceView implements TouchInput, |
|
|
|
// Send the event
|
|
|
|
// Send the event
|
|
|
|
processEvent(evt); |
|
|
|
processEvent(evt); |
|
|
|
|
|
|
|
|
|
|
|
// Handle all keys ourself, except the back button (4)
|
|
|
|
// Handle all keys ourself
|
|
|
|
if (keyCode == 4) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -408,8 +505,8 @@ public class AndroidInput extends GLSurfaceView implements TouchInput, |
|
|
|
|
|
|
|
|
|
|
|
if (fireMouseEvents) |
|
|
|
if (fireMouseEvents) |
|
|
|
{ |
|
|
|
{ |
|
|
|
newX = getWidth() - (int) event.getX(); |
|
|
|
newX = this.getWidth() - (int) event.getX(); |
|
|
|
newY = (int) event.getY(); |
|
|
|
newY = this.getHeight() - (int) event.getY(); |
|
|
|
switch (event.getType()) |
|
|
|
switch (event.getType()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case DOWN: |
|
|
|
case DOWN: |
|
|
@ -451,11 +548,23 @@ public class AndroidInput extends GLSurfaceView implements TouchInput, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (event.isConsumed() == false) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
synchronized (eventPoolUnConsumed) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
eventPoolUnConsumed.push(event); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
synchronized (eventPool) |
|
|
|
synchronized (eventPool) |
|
|
|
{ |
|
|
|
{ |
|
|
|
eventPool.push(event); |
|
|
|
eventPool.push(event); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -470,7 +579,7 @@ public class AndroidInput extends GLSurfaceView implements TouchInput, |
|
|
|
public void onLongPress(MotionEvent event) |
|
|
|
public void onLongPress(MotionEvent event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
TouchEvent touch = getNextFreeTouchEvent(); |
|
|
|
TouchEvent touch = getNextFreeTouchEvent(); |
|
|
|
touch.set(Type.LONGPRESSED, event.getX(), event.getY(), 0f, 0f); |
|
|
|
touch.set(Type.LONGPRESSED, event.getX(), this.getHeight() - event.getY(), 0f, 0f); |
|
|
|
touch.setPointerId(0); |
|
|
|
touch.setPointerId(0); |
|
|
|
touch.setTime(event.getEventTime()); |
|
|
|
touch.setTime(event.getEventTime()); |
|
|
|
processEvent(touch); |
|
|
|
processEvent(touch); |
|
|
@ -479,7 +588,7 @@ public class AndroidInput extends GLSurfaceView implements TouchInput, |
|
|
|
public boolean onFling(MotionEvent event, MotionEvent event2, float vx, float vy) |
|
|
|
public boolean onFling(MotionEvent event, MotionEvent event2, float vx, float vy) |
|
|
|
{ |
|
|
|
{ |
|
|
|
TouchEvent touch = getNextFreeTouchEvent(); |
|
|
|
TouchEvent touch = getNextFreeTouchEvent(); |
|
|
|
touch.set(Type.FLING, event.getX(), event.getY(), vx, vy); |
|
|
|
touch.set(Type.FLING, event.getX(), this.getHeight() - event.getY(), vx, vy); |
|
|
|
touch.setPointerId(0); |
|
|
|
touch.setPointerId(0); |
|
|
|
touch.setTime(event.getEventTime()); |
|
|
|
touch.setTime(event.getEventTime()); |
|
|
|
processEvent(touch); |
|
|
|
processEvent(touch); |
|
|
@ -490,7 +599,7 @@ public class AndroidInput extends GLSurfaceView implements TouchInput, |
|
|
|
public boolean onSingleTapConfirmed(MotionEvent event) |
|
|
|
public boolean onSingleTapConfirmed(MotionEvent event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
TouchEvent touch = getNextFreeTouchEvent(); |
|
|
|
TouchEvent touch = getNextFreeTouchEvent(); |
|
|
|
touch.set(Type.TAP, event.getX(), event.getY(), 0f, 0f); |
|
|
|
touch.set(Type.TAP, event.getX(), this.getHeight() - event.getY(), 0f, 0f); |
|
|
|
touch.setPointerId(0); |
|
|
|
touch.setPointerId(0); |
|
|
|
touch.setTime(event.getEventTime()); |
|
|
|
touch.setTime(event.getEventTime()); |
|
|
|
processEvent(touch); |
|
|
|
processEvent(touch); |
|
|
@ -501,7 +610,7 @@ public class AndroidInput extends GLSurfaceView implements TouchInput, |
|
|
|
public boolean onDoubleTap(MotionEvent event) |
|
|
|
public boolean onDoubleTap(MotionEvent event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
TouchEvent touch = getNextFreeTouchEvent(); |
|
|
|
TouchEvent touch = getNextFreeTouchEvent(); |
|
|
|
touch.set(Type.DOUBLETAP, event.getX(), event.getY(), 0f, 0f); |
|
|
|
touch.set(Type.DOUBLETAP, event.getX(), this.getHeight() - event.getY(), 0f, 0f); |
|
|
|
touch.setPointerId(0); |
|
|
|
touch.setPointerId(0); |
|
|
|
touch.setTime(event.getEventTime()); |
|
|
|
touch.setTime(event.getEventTime()); |
|
|
|
processEvent(touch); |
|
|
|
processEvent(touch); |
|
|
@ -524,7 +633,7 @@ public class AndroidInput extends GLSurfaceView implements TouchInput, |
|
|
|
public boolean onScale(ScaleGestureDetector scaleGestureDetector) |
|
|
|
public boolean onScale(ScaleGestureDetector scaleGestureDetector) |
|
|
|
{ |
|
|
|
{ |
|
|
|
TouchEvent touch = getNextFreeTouchEvent(); |
|
|
|
TouchEvent touch = getNextFreeTouchEvent(); |
|
|
|
touch.set(Type.SCALE_MOVE, scaleGestureDetector.getFocusX(), scaleGestureDetector.getFocusY(), 0f, 0f); |
|
|
|
touch.set(Type.SCALE_MOVE, scaleGestureDetector.getFocusX(), this.getHeight() - scaleGestureDetector.getFocusY(), 0f, 0f); |
|
|
|
touch.setPointerId(0); |
|
|
|
touch.setPointerId(0); |
|
|
|
touch.setTime(scaleGestureDetector.getEventTime()); |
|
|
|
touch.setTime(scaleGestureDetector.getEventTime()); |
|
|
|
touch.setScaleSpan(scaleGestureDetector.getCurrentSpan()); |
|
|
|
touch.setScaleSpan(scaleGestureDetector.getCurrentSpan()); |
|
|
@ -537,7 +646,7 @@ public class AndroidInput extends GLSurfaceView implements TouchInput, |
|
|
|
public void onScaleEnd(ScaleGestureDetector scaleGestureDetector) |
|
|
|
public void onScaleEnd(ScaleGestureDetector scaleGestureDetector) |
|
|
|
{ |
|
|
|
{ |
|
|
|
TouchEvent touch = getNextFreeTouchEvent(); |
|
|
|
TouchEvent touch = getNextFreeTouchEvent(); |
|
|
|
touch.set(Type.SCALE_END, scaleGestureDetector.getFocusX(), scaleGestureDetector.getFocusY(), 0f, 0f); |
|
|
|
touch.set(Type.SCALE_END, scaleGestureDetector.getFocusX(), this.getHeight() - scaleGestureDetector.getFocusY(), 0f, 0f); |
|
|
|
touch.setPointerId(0); |
|
|
|
touch.setPointerId(0); |
|
|
|
touch.setTime(scaleGestureDetector.getEventTime()); |
|
|
|
touch.setTime(scaleGestureDetector.getEventTime()); |
|
|
|
touch.setScaleSpan(scaleGestureDetector.getCurrentSpan()); |
|
|
|
touch.setScaleSpan(scaleGestureDetector.getCurrentSpan()); |
|
|
@ -548,7 +657,7 @@ public class AndroidInput extends GLSurfaceView implements TouchInput, |
|
|
|
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) |
|
|
|
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) |
|
|
|
{ |
|
|
|
{ |
|
|
|
TouchEvent touch = getNextFreeTouchEvent(); |
|
|
|
TouchEvent touch = getNextFreeTouchEvent(); |
|
|
|
touch.set(Type.SCROLL, e1.getX(), e1.getY(), distanceX, distanceY); |
|
|
|
touch.set(Type.SCROLL, e1.getX(), this.getHeight() - e1.getY(), distanceX, distanceY*(-1)); |
|
|
|
touch.setPointerId(0); |
|
|
|
touch.setPointerId(0); |
|
|
|
touch.setTime(e1.getEventTime()); |
|
|
|
touch.setTime(e1.getEventTime()); |
|
|
|
processEvent(touch); |
|
|
|
processEvent(touch); |
|
|
@ -558,7 +667,7 @@ public class AndroidInput extends GLSurfaceView implements TouchInput, |
|
|
|
public void onShowPress(MotionEvent event) |
|
|
|
public void onShowPress(MotionEvent event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
TouchEvent touch = getNextFreeTouchEvent(); |
|
|
|
TouchEvent touch = getNextFreeTouchEvent(); |
|
|
|
touch.set(Type.SHOWPRESS, event.getX(), event.getY(), 0f, 0f); |
|
|
|
touch.set(Type.SHOWPRESS, event.getX(), this.getHeight() - event.getY(), 0f, 0f); |
|
|
|
touch.setPointerId(0); |
|
|
|
touch.setPointerId(0); |
|
|
|
touch.setTime(event.getEventTime()); |
|
|
|
touch.setTime(event.getEventTime()); |
|
|
|
processEvent(touch); |
|
|
|
processEvent(touch); |
|
|
@ -567,7 +676,7 @@ public class AndroidInput extends GLSurfaceView implements TouchInput, |
|
|
|
public boolean onSingleTapUp(MotionEvent event) |
|
|
|
public boolean onSingleTapUp(MotionEvent event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
TouchEvent touch = getNextFreeTouchEvent(); |
|
|
|
TouchEvent touch = getNextFreeTouchEvent(); |
|
|
|
touch.set(Type.TAP, event.getX(), event.getY(), 0f, 0f); |
|
|
|
touch.set(Type.TAP, event.getX(), this.getHeight() - event.getY(), 0f, 0f); |
|
|
|
touch.setPointerId(0); |
|
|
|
touch.setPointerId(0); |
|
|
|
touch.setTime(event.getEventTime()); |
|
|
|
touch.setTime(event.getEventTime()); |
|
|
|
processEvent(touch); |
|
|
|
processEvent(touch); |
|
|
@ -585,5 +694,10 @@ public class AndroidInput extends GLSurfaceView implements TouchInput, |
|
|
|
{ |
|
|
|
{ |
|
|
|
fireKeyboardEvents = simulate; |
|
|
|
fireKeyboardEvents = simulate; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void setOmitHistoricEvents(boolean dontSendHistory) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
this.dontSendHistory = dontSendHistory; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|