Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Unified Diff: sky/shell/apk/src/org/domokit/sky/shell/PlatformView.java

Issue 961483004: Fix multi-touch to work in SkyShell. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/examples/touch-demo.sky ('k') | sky/shell/apk/src/org/domokit/sky/shell/SkyShellActivity.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/shell/apk/src/org/domokit/sky/shell/PlatformView.java
diff --git a/sky/shell/apk/src/org/domokit/sky/shell/PlatformView.java b/sky/shell/apk/src/org/domokit/sky/shell/PlatformView.java
index 2f646c9cedbd2d1b1c8e3171ea7328d82da5e3fd..e24cbdf44da9b53a31de65b9c75960cc5f7dd905 100644
--- a/sky/shell/apk/src/org/domokit/sky/shell/PlatformView.java
+++ b/sky/shell/apk/src/org/domokit/sky/shell/PlatformView.java
@@ -81,10 +81,17 @@ public class PlatformView extends SurfaceView {
}
private int getTypeForAction(int maskedAction) {
+ // Primary pointer:
if (maskedAction == MotionEvent.ACTION_DOWN)
return EventType.POINTER_DOWN;
if (maskedAction == MotionEvent.ACTION_UP)
return EventType.POINTER_UP;
+ // Secondary pointer:
+ if (maskedAction == MotionEvent.ACTION_POINTER_DOWN)
+ return EventType.POINTER_DOWN;
+ if (maskedAction == MotionEvent.ACTION_POINTER_UP)
+ return EventType.POINTER_UP;
+ // All pointers:
if (maskedAction == MotionEvent.ACTION_MOVE)
return EventType.POINTER_MOVE;
if (maskedAction == MotionEvent.ACTION_CANCEL)
@@ -92,13 +99,12 @@ public class PlatformView extends SurfaceView {
return EventType.UNKNOWN;
}
- @Override
- public boolean onTouchEvent(MotionEvent event) {
+ private void sendInputEventForIndex(MotionEvent event, int pointerIndex) {
PointerData pointerData = new PointerData();
- pointerData.pointer = event.getPointerId(0);
+ pointerData.pointer = event.getPointerId(pointerIndex);
pointerData.kind = PointerKind.TOUCH;
- pointerData.x = event.getX();
- pointerData.y = event.getY();
+ pointerData.x = event.getX(pointerIndex);
+ pointerData.y = event.getY(pointerIndex);
InputEvent inputEvent = new InputEvent();
inputEvent.type = getTypeForAction(event.getActionMasked());
@@ -106,6 +112,26 @@ public class PlatformView extends SurfaceView {
inputEvent.pointerData = pointerData;
mViewportObserver.onInputEvent(inputEvent);
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ int maskedAction = event.getActionMasked();
+ // ACTION_UP, ACTION_POINTER_UP, ACTION_DOWN, and ACTION_POINTER_DOWN
+ // only apply to a single pointer, other events apply to all pointers.
+ if (maskedAction == MotionEvent.ACTION_UP
+ || maskedAction == MotionEvent.ACTION_POINTER_UP
+ || maskedAction == MotionEvent.ACTION_DOWN
+ || maskedAction == MotionEvent.ACTION_POINTER_DOWN) {
+ sendInputEventForIndex(event, event.getActionIndex());
+ } else {
+ // ACTION_MOVE may not actually mean all pointers have moved
+ // but it's the responsibility of a later part of the system to
+ // ignore 0-deltas if desired.
+ for (int p = 0; p < event.getPointerCount(); p++) {
+ sendInputEventForIndex(event, p);
+ }
+ }
return true;
}
« no previous file with comments | « sky/examples/touch-demo.sky ('k') | sky/shell/apk/src/org/domokit/sky/shell/SkyShellActivity.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698