// Touch events @Override public boolean onTouch(View v, MotionEvent event) { final int touchDevId = event.getDeviceId(); final int pointerCount = event.getPointerCount(); // touchId, pointerId, action, x, y, pressure int actionPointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT; /* API 8: event.getActionIndex(); */ int pointerFingerId = event.getPointerId(actionPointerIndex); int action = (event.getAction() & MotionEvent.ACTION_MASK); /* API 8: event.getActionMasked(); */ float x = event.getX(actionPointerIndex) / mWidth; float y = event.getY(actionPointerIndex) / mHeight; float p = event.getPressure(actionPointerIndex); if (action == MotionEvent.ACTION_MOVE && pointerCount > 1) { // TODO send motion to every pointer if its position has // changed since prev event. for (int i = 0; i < pointerCount; i++) { pointerFingerId = event.getPointerId(i); x = event.getX(i) / mWidth; y = event.getY(i) / mHeight; p = event.getPressure(i); SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p); } } else { SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p); } return true; }
// Touch events public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); float x = event.getX(); float y = event.getY(); float p = event.getPressure(); // TODO: Anything else we need to pass? SDLActivity.onNativeTouch(action, x, y, p); return true; }