1 package com.replica.replicaisland; 2 3 import android.content.Context; 4 import android.content.pm.PackageManager; 5 import android.view.MotionEvent; 6 7 public class MultiTouchFilter extends SingleTouchFilter { 8 private boolean mCheckedForMultitouch = false; 9 private boolean mSupportsMultitouch = false; 10 11 @Override updateTouch(MotionEvent event)12 public void updateTouch(MotionEvent event) { 13 ContextParameters params = sSystemRegistry.contextParameters; 14 final int pointerCount = event.getPointerCount(); 15 for (int x = 0; x < pointerCount; x++) { 16 final int action = event.getAction(); 17 final int actualEvent = action & MotionEvent.ACTION_MASK; 18 final int id = event.getPointerId(x); 19 if (actualEvent == MotionEvent.ACTION_POINTER_UP || 20 actualEvent == MotionEvent.ACTION_UP || 21 actualEvent == MotionEvent.ACTION_CANCEL) { 22 BaseObject.sSystemRegistry.inputSystem.touchUp(id, 23 event.getX(x) * (1.0f / params.viewScaleX), 24 event.getY(x) * (1.0f / params.viewScaleY)); 25 } else { 26 BaseObject.sSystemRegistry.inputSystem.touchDown(id, 27 event.getX(x) * (1.0f / params.viewScaleX), 28 event.getY(x) * (1.0f / params.viewScaleY)); 29 } 30 } 31 } 32 33 @Override supportsMultitouch(Context context)34 public boolean supportsMultitouch(Context context) { 35 if (!mCheckedForMultitouch) { 36 PackageManager packageManager = context.getPackageManager(); 37 mSupportsMultitouch = packageManager.hasSystemFeature("android.hardware.touchscreen.multitouch"); 38 mCheckedForMultitouch = true; 39 } 40 41 return mSupportsMultitouch; 42 } 43 } 44