List of usage examples for android.view MotionEvent ACTION_POINTER_DOWN
int ACTION_POINTER_DOWN
To view the source code for android.view MotionEvent ACTION_POINTER_DOWN.
Click Source Link
From source file:ch.fhnw.comgr.GLES3Activity.java
@Override public boolean onTouch(View v, final MotionEvent event) { if (event == null) { Log.i(TAG, "onTouch: null event"); return false; }/*from w w w . ja v a 2 s . co m*/ int action = event.getAction(); int actionCode = action & MotionEvent.ACTION_MASK; try { if (actionCode == MotionEvent.ACTION_DOWN || actionCode == MotionEvent.ACTION_POINTER_DOWN) return handleTouchDown(event); else if (actionCode == MotionEvent.ACTION_UP || actionCode == MotionEvent.ACTION_POINTER_UP) return handleTouchUp(event); else if (actionCode == MotionEvent.ACTION_MOVE) return handleTouchMove(event); else Log.i(TAG, "Unhandeled Event: " + actionCode); } catch (Exception ex) { Log.i(TAG, "onTouch (Exception: " + actionCode); } return false; }
From source file:com.example.manan.enhancedurdureader.EpubReader.BookView.java
@TargetApi(Build.VERSION_CODES.KITKAT) @Override/* w w w . jav a 2s.co m*/ public void onActivityCreated(Bundle saved) { super.onActivityCreated(saved); view = (WebView) getView().findViewById(R.id.Viewport); view.getSettings().setTextZoom(textSize); mScaleDetector = new ScaleGestureDetector(getActivity().getBaseContext(), new ScaleGestureDetector.OnScaleGestureListener() { @Override public void onScaleEnd(ScaleGestureDetector detector) { } @Override public boolean onScaleBegin(ScaleGestureDetector detector) { return true; } @Override public boolean onScale(ScaleGestureDetector detector) { //Log.w(LOG_KEY, "zoom ongoing, scale: " + detector.getScaleFactor()); return false; } }); // enable JavaScript for cool things to happen! view.getSettings().setJavaScriptEnabled(true); // ----- SWIPE PAGE view.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { /* if (state == ViewStateEnum.books) swipePage(v, event, 0); //int fontSize, newFont;*/ WebView view = (WebView) v; switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: x1 = event.getX(); break; case MotionEvent.ACTION_UP: if (mode != ZOOM && swipeFlag) { //if (state == ViewStateEnum.books) //swipePage(v, event, 0); } break; case MotionEvent.ACTION_POINTER_DOWN: oldDist = spacing(event); if (oldDist > 10f) { mode = ZOOM; } break; case MotionEvent.ACTION_POINTER_UP: mode = NONE; break; case MotionEvent.ACTION_MOVE: if (mode == ZOOM) { float newDist = spacing(event); if (newDist > 10f) { float scale = newDist / oldDist; if (scale > 1) { int currentTextSize = view.getSettings().getTextZoom(); textSize = currentTextSize + 15; view.getSettings().setTextZoom(textSize); mode = NONE; swipeFlag = false; } else { int currentTextSize = view.getSettings().getTextZoom(); textSize = currentTextSize - 15; view.getSettings().setTextZoom(textSize); mode = NONE; swipeFlag = false; } } } break; } return view.onTouchEvent(event); } }); // ----- NOTE & LINK view.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { Message msg = new Message(); msg.setTarget(new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); String url = msg.getData().getString(getString(R.string.url)); if (url != null) navigator.setNote(url, index); } }); view.requestFocusNodeHref(msg); return false; } }); view.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { try { navigator.setBookPage(url, index); } catch (Exception e) { errorMessage(getString(R.string.error_LoadPage)); } return true; } }); loadPage(viewedPage); }
From source file:com.bluetech.gallery5.ui.ImageDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { /*/*w ww.j a va2 s .com*/ // Inflate and locate the main ImageView final View v = inflater.inflate(R.layout.image_detail_fragment, container, false); mImageView = (ImageView) v.findViewById(R.id.imageRecycView); return v; */ final View v = inflater.inflate(R.layout.image_detail_fragment, container, false); mImageView = (ImageView) v.findViewById(R.id.imageRecycView); //ImageView img = new ImageView(getActivity()); mImageView.setPadding(6, 6, 6, 6); // mImageView.setLayoutParams(new Gallery.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)) ; //ImageViewHelperURL.setUrlDrawable((ImageView) img, url, R.drawable.no_image) ; mImageView.setOnTouchListener(new View.OnTouchListener() { private static final String TAG = "SlideImageView"; // These matrices will be used to move and zoom image Matrix matrix = new Matrix(); Matrix savedMatrix = new Matrix(); // We can be in one of these 3 states static final int NONE = 0; static final int DRAG = 1; static final int ZOOM = 2; int mode = NONE; // Remember some things for zooming PointF start = new PointF(); PointF mid = new PointF(); float oldDist = 1f; @Override public boolean onTouch(View v, MotionEvent event) { ImageView view = (ImageView) v; // Dump touch event to log dumpEvent(event); // Handle touch events here... switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: savedMatrix.set(matrix); start.set(event.getX(), event.getY()); Log.d(TAG, "mode=DRAG"); mode = DRAG; break; case MotionEvent.ACTION_POINTER_DOWN: oldDist = spacing(event); Log.d(TAG, "oldDist=" + oldDist); if (oldDist > 10f) { savedMatrix.set(matrix); midPoint(mid, event); mode = ZOOM; Log.d(TAG, "mode=ZOOM"); } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: mode = NONE; Log.d(TAG, "mode=NONE"); break; case MotionEvent.ACTION_MOVE: if (mode == DRAG) { // ... matrix.set(savedMatrix); matrix.postTranslate(event.getX() - start.x, event.getY() - start.y); } else if (mode == ZOOM) { float newDist = spacing(event); Log.d(TAG, "newDist=" + newDist); if (newDist > 10f) { matrix.set(savedMatrix); float scale = newDist / oldDist; Log.d(TAG, "ZOOOOOOOM: " + scale); matrix.postScale(scale, scale, mid.x, mid.y); } } break; } view.setImageMatrix(matrix); return true; // indicate event was handled } /** Show an event in the LogCat view, for debugging */ private void dumpEvent(MotionEvent event) { String names[] = { "DOWN", "UP", "MOVE", "CANCEL", "OUTSIDE", "POINTER_DOWN", "POINTER_UP", "7?", "8?", "9?" }; StringBuilder sb = new StringBuilder(); int action = event.getAction(); int actionCode = action & MotionEvent.ACTION_MASK; sb.append("event ACTION_").append(names[actionCode]); if (actionCode == MotionEvent.ACTION_POINTER_DOWN || actionCode == MotionEvent.ACTION_POINTER_UP) { sb.append("(pid ").append(action >> MotionEvent.ACTION_POINTER_ID_SHIFT); sb.append(")"); } sb.append("["); for (int i = 0; i < event.getPointerCount(); i++) { sb.append("#").append(i); sb.append("(pid ").append(event.getPointerId(i)); sb.append(")=").append((int) event.getX(i)); sb.append(",").append((int) event.getY(i)); if (i + 1 < event.getPointerCount()) sb.append(";"); } sb.append("]"); Log.d(TAG, sb.toString()); } /** Determine the space between the first two fingers */ private float spacing(MotionEvent event) { float x = event.getX(0) - event.getX(1); float y = event.getY(0) - event.getY(1); return (float) Math.sqrt(x * x + y * y); } /** Calculate the mid point of the first two fingers */ private void midPoint(PointF point, MotionEvent event) { float x = event.getX(0) + event.getX(1); float y = event.getY(0) + event.getY(1); point.set(x / 2, y / 2); } }); return v; }
From source file:com.csounds.examples.tests.MultiTouchXYActivity.java
/** Called when the activity is first created. */ @Override//from w w w . j a v a 2 s. c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); for (int i = 0; i < touchIds.length; i++) { touchIds[i] = -1; touchX[i] = -1; touchY[i] = -1; } /* File outputFile = new File(DIR_NAME); File outputDir = this.getCacheDir(); // context being the Activity pointer try { outputFile = File.createTempFile("temp", "txt", outputDir); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ContextWrapper cw = new ContextWrapper(this); File directory = cw.getExternalFilesDir(null); txtfile = new File(directory,"temp.txt"); */ multiTouchView = new View(this); setContentView(R.layout.multitouchxy); multiTouchView = (RelativeLayout) findViewById(R.id.multitouchxy); Button loadPresetButton = (Button) findViewById(R.id.load_button); this.createLoadListener(loadPresetButton); multiTouchView.setOnTouchListener(new OnTouchListener() { /* (non-Javadoc) * @see android.view.View.OnTouchListener#onTouch(android.view.View, android.view.MotionEvent) */ public boolean onTouch(View v, MotionEvent event) { final int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_POINTER_DOWN: for (int i = 0; i < event.getPointerCount(); i++) { int pointerId = event.getPointerId(i); int id = getTouchId(pointerId); if (id == -1) { id = getTouchIdAssignment(); if (id != -1) { touchIds[id] = pointerId; touchX[id] = event.getX(i) / multiTouchView.getWidth(); touchY[id] = 1 - (event.getY(i) / multiTouchView.getHeight()); //TODO calculte interval Y int a = Math.round(id / 440); System.out.println("y " + a); if (touchXPtr[id] != null) { //TODO swtich touchid Log.d("touchXtouchY", "touchX[id]) " + touchX[id] + " touchY[id]) " + touchY[id] + " multitouchview width " + multiTouchView.getWidth() + " multitouchview width " + multiTouchView.getHeight()); // get the key from the touch coordinates float[] touchArray = new float[2]; touchArray = evaluateTouchKey(touchX[id], touchY[id]); touchX[id] = touchArray[0]; touchY[id] = touchArray[1]; Log.d("touchXtouchY", "touchX[id]) " + touchX[id] + " touchY[id]) " + touchY[id]); touchXPtr[id].SetValue(0, touchX[id]); touchYPtr[id].SetValue(0, touchY[id]); csoundObj.sendScore(String.format("i1.%d 0 -2 %d", id, id)); } //write file /* System.out.println(String.format( "i1.%d 0 -2 %d", id, a)); writeToFile(String.format( "i1.%d 0 -2 %d", id, a)); */ } } } break; case MotionEvent.ACTION_MOVE: for (int i = 0; i < event.getPointerCount(); i++) { int pointerId = event.getPointerId(i); int id = getTouchId(pointerId); if (id != -1) { touchX[id] = event.getX(i) / multiTouchView.getWidth(); touchY[id] = 1 - (event.getY(i) / multiTouchView.getHeight()); } //write file /* System.out.println(String.format( "i1.%d 0 -2 %d", id, id)); writeToFile(String.format( "i1.%d 0 -2 %d", id, id)); */ } break; case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_UP: { int activePointerIndex = event.getActionIndex(); int pointerId = event.getPointerId(activePointerIndex); int id = getTouchId(pointerId); if (id != -1) { touchIds[id] = -1; csoundObj.sendScore(String.format("i-1.%d 0 0 %d", id, id)); } //write file /* System.out.println(String.format( "i1.%d 0 -2 %d", id, id)); writeToFile(String.format( "i1.%d 0 -2 %d", id, id)); */ } break; } return true; } }); setContentView(multiTouchView); String csd = getResourceFileAsString(R.raw.multitouch_xy_kx); File f = createTempFile(csd); csoundObj.addBinding(this); csoundObj.startCsound(f); }
From source file:danonino.danonino_the_game.Core.GamePanel.java
@Override public boolean onTouchEvent(MotionEvent event) { int action = MotionEventCompat.getActionMasked(event); switch (action) { case MotionEvent.ACTION_POINTER_DOWN: case MotionEvent.ACTION_DOWN: { if (this.gameOver) { GameOver.onTouch(event);/* w w w .ja va2 s . c o m*/ } else if (this.powerUpLabel != null && this.powerUpLabel.onTouch(event) == 1) { return true; } if (!this.joystickEnabled && action == MotionEvent.ACTION_DOWN) { this.movePlayer(event); } return true; } case MotionEvent.ACTION_MOVE: { this.movePlayer(event); break; } case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_UP: { if (this.gameOver) { if (GameOver.onTouch(event) == 1) { this.initPlayerFeatures(); Player.setPowerUp(null); this.powerUpLabel = null; } else if (GameOver.onTouch(event) == 2) { Intent i = new Intent(getContext(), MoreGamesMenu.class); getContext().startActivity(i); } } else if (this.powerUpLabel != null) { if (this.powerUpLabel.onTouch(event) == 1) { Player.getPowerUp().applyEffect(this.player); } } this.player.setSpeedX(0); this.player.setSpeedY(0); joystick.resetPosition(); return true; } } return super.onTouchEvent(event); }
From source file:com.arthurpitman.common.SlidingPanel.java
@Override public boolean onTouchEvent(MotionEvent event) { float y = event.getY(); int action = event.getActionMasked(); int pointerId = event.getPointerId(event.getActionIndex()); switch (action) { case MotionEvent.ACTION_POINTER_DOWN: case MotionEvent.ACTION_DOWN: startTouchY = y;//from w w w .j a v a 2s . c o m startTouchScrollY = getScrollY(); // if touch didn't occur on the actual control, ignore it float touchBoundary = viewHeight - collapsedHeight - startTouchScrollY; if (y < touchBoundary) { return false; } // start tracking velocity if (velocityTracker == null) { velocityTracker = VelocityTracker.obtain(); } else { velocityTracker.clear(); } velocityTracker.addMovement(event); break; case MotionEvent.ACTION_MOVE: // determine if a valid touch has started if (Math.abs(y - startTouchY) > touchSlop) { touchState = TOUCH_STARTED; } if (velocityTracker != null) { velocityTracker.addMovement(event); } // scroll as appropriate if (touchState == TOUCH_STARTED) { final int scrollDelta = (int) (startTouchY - y); scrollTo(0, Math.max(0, Math.min(viewHeight, startTouchScrollY + scrollDelta))); } break; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_UP: if (touchState == TOUCH_STARTED) { final int currentScrollY = getScrollY(); // get velocity float velocity = 0; if (velocityTracker != null) { velocityTracker.computeCurrentVelocity(1000); velocity = VelocityTrackerCompat.getYVelocity(velocityTracker, pointerId); velocityTracker.recycle(); velocityTracker = null; } // snap to final scroll position int target = startTouchScrollY; if ((Math.abs(velocity) > minimumflingVelocity) || (Math.abs(y - startTouchY) > (viewHeight / 2))) { if (velocity < 0) { target = viewHeight; } else { target = 0; } } scroller.startScroll(0, currentScrollY, 0, target - currentScrollY); invalidate(); touchState = TOUCH_NONE; } break; } return true; }
From source file:me.wizos.loread.view.webview.NestedScrollWebView.java
@Override public boolean onTouchEvent(MotionEvent ev) { final int actionMasked = ev.getActionMasked(); switch (actionMasked) { case MotionEvent.ACTION_DOWN: mIsBeingDragged = false;/*from w ww . j a v a 2s .c om*/ // Remember where the motion event started mLastMotionY = (int) ev.getY(); // downY = (int) ev.getY(); mActivePointerId = ev.getPointerId(0); startNestedScroll(ViewCompat.SCROLL_AXIS_VERTICAL); break; case MotionEvent.ACTION_MOVE: // KLog.e(""); final int activePointerIndex = ev.findPointerIndex(mActivePointerId); if (activePointerIndex == -1) { break; } // if( !onlyVerticalMove(ev) ){ // break; // } final int y = (int) ev.getY(activePointerIndex); int deltaY = mLastMotionY - y; if (dispatchNestedPreScroll(0, deltaY, mScrollConsumed, mScrollOffset)) { deltaY -= mScrollConsumed[1]; } // Scroll to follow the motion event mLastMotionY = y - mScrollOffset[1]; final int oldY = getScrollY(); final int scrolledDeltaY = Math.max(0, oldY + deltaY) - oldY; final int unconsumedY = deltaY - scrolledDeltaY; if (dispatchNestedScroll(0, scrolledDeltaY, 0, unconsumedY, mScrollOffset)) { mLastMotionY -= mScrollOffset[1]; } // KLog.e("?"); break; case MotionEvent.ACTION_UP: mActivePointerId = INVALID_POINTER; endDrag(); break; case MotionEvent.ACTION_CANCEL: mActivePointerId = INVALID_POINTER; endDrag(); break; case MotionEvent.ACTION_POINTER_DOWN: { final int index = ev.getActionIndex(); mLastMotionY = (int) ev.getY(index); mActivePointerId = ev.getPointerId(index); break; } case MotionEvent.ACTION_POINTER_UP: onSecondaryPointerUp(ev); mLastMotionY = (int) ev.getY(ev.findPointerIndex(mActivePointerId)); break; default: break; } return super.onTouchEvent(ev); }
From source file:com.tearoffcalendar.activities.FaceDownCardFragment.java
public boolean onTouch(View view, MotionEvent event) { // We need to register click here final float y = event.getRawY(); switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: deltaY = 0;/*ww w . j a va2s. c o m*/ clickStartedOnY = y; Log.v(TAG, "Click started on:" + String.valueOf(clickStartedOnY)); break; case MotionEvent.ACTION_UP: Log.v(TAG, "Resulted deltaY:" + String.valueOf(deltaY)); // This one is for when finger is up, not a rude gesture bro! if (deltaY >= DELTA_Y_MAX) { Log.v(TAG, "Greater than max of delta y - not a click!"); } else { Log.v(TAG, "Smaller than max of delta y - a click!"); if (null != onFaceDownCardClickListener) { Log.v(TAG, "Calling on face down card click listener"); onFaceDownCardClickListener.onFaceDownCardClick(); } else { Log.e(TAG, "On face down card click listener is missing!"); } } deltaY = clickStartedOnY = 0; break; case MotionEvent.ACTION_POINTER_DOWN: break; case MotionEvent.ACTION_POINTER_UP: break; case MotionEvent.ACTION_MOVE: deltaY += Math.abs(y - clickStartedOnY); Log.v(TAG, "Current delta: " + String.valueOf(deltaY)); break; } return false; }
From source file:org.libreoffice.impressremote.fragment.slides.PointerFragment.java
@Override public boolean onTouch(View v, MotionEvent event) { float x = (event.getX() - xoffset) / displaywidth; float y = (event.getY() - yoffset) / displayheight; // get masked action int aMaskedAction = event.getActionMasked(); switch (aMaskedAction) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_POINTER_DOWN: // a pointer start mCommunicationService.getCommandsTransmitter().startPointer(x, y); break;// w w w . j a v a 2 s . c o m case MotionEvent.ACTION_MOVE: // a pointer was moved if (nextUpdate <= event.getEventTime()) { mCommunicationService.getCommandsTransmitter().movePointer(x, y); nextUpdate = event.getEventTime() + REFRESH_MILLIS; } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_CANCEL: // a pointer was removed mCommunicationService.getCommandsTransmitter().stopPointer(); break; } return true; }
From source file:com.csounds.examples.tests.SynthActivity.java
/** Called when the activity is first created. */ @Override/*from w w w . j ava 2 s. c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); for (int i = 0; i < touchIds.length; i++) { touchIds[i] = -1; touchX[i] = -1; touchY[i] = -1; } multiTouchView = new View(this); setContentView(R.layout.synth2); multiTouchView = (RelativeLayout) findViewById(R.id.synth); octPlusButton = (Button) findViewById(R.id.plusoctavebutton); octMinusButton = (Button) findViewById(R.id.minusoctavebutton); diode4 = (ToggleButton) findViewById(R.id.diode4); diode3 = (ToggleButton) findViewById(R.id.diode3); LcdScreenView lcd = (LcdScreenView) findViewById(R.id.lcd_screen); new DrumMachineLcdUpdater(lcd.getModel()); this.createLoadListener((View) lcd); keyboardLayout = (RelativeLayout) findViewById(R.id.keyboard); keyboardLayout.setOnTouchListener(new OnTouchListener() { /* (non-Javadoc) * @see android.view.View.OnTouchListener#onTouch(android.view.View, android.view.MotionEvent) */ public boolean onTouch(View v, MotionEvent event) { final int action = event.getAction() & MotionEvent.ACTION_MASK; float[] touchArrayDown = new float[2]; switch (action) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_POINTER_DOWN: for (int i = 0; i < event.getPointerCount(); i++) { int pointerId = event.getPointerId(i); int id = getTouchId(pointerId); if (id == -1) { id = getTouchIdAssignment(); if (id != -1) { touchIds[id] = pointerId; touchX[id] = event.getX(i) / keyboardLayout.getWidth(); touchY[id] = 1 - (event.getY(i) / keyboardLayout.getHeight()); //TODO calculte interval Y if (touchXPtr[id] != null) { //TODO swtich touchid // Log.d("touchXtouchY","touchX[id]) " + touchX[id] + " touchY[id]) " + touchY[id] + " multitouchview width " + multiTouchView.getWidth() + " multitouchview width " + multiTouchView.getHeight()); // Log.d("touchXtouchY","keyboardLayout width " + keyboardLayout.getWidth() + " keyboardLayout width " + keyboardLayout.getHeight()); // get the key from the touch coordinates float[] touchArray = new float[2]; touchArray = evaluateTouchKey(touchX[id], touchY[id]); touchArrayDown[0] = touchX[id]; touchArrayDown[1] = touchY[id]; touchX[id] = touchArray[0]; touchY[id] = touchArray[1]; // Log.d("touchXtouchY","touchX[id]) " + touchX[id] + " touchY[id]) " + touchY[id]); touchXPtr[id].SetValue(0, touchX[id]); touchYPtr[id].SetValue(0, touchY[id]); csoundObj.sendScore(String.format("i1.%d 0 -2 %d", id, id)); } } } } break; case MotionEvent.ACTION_MOVE: for (int i = 0; i < event.getPointerCount(); i++) { int pointerId = event.getPointerId(i); int id = getTouchId(pointerId); if (id != -1) { touchIds[id] = pointerId; touchX[id] = event.getX(i) / keyboardLayout.getWidth(); touchY[id] = 1 - (event.getY(i) / keyboardLayout.getHeight()); //TODO calculte interval Y if (touchXPtr[id] != null) { //TODO swtich touchid // Log.d("aaa","touchX[id]) " + touchX[id] + " touchY[id]) " + touchY[id] + " multitouchview width " + multiTouchView.getWidth() + " multitouchview width " + multiTouchView.getHeight()); // Log.d("aaa","keyboardLayout width " + keyboardLayout.getWidth() + " keyboardLayout width " + keyboardLayout.getHeight()); // get the key from the touch coordinates float[] touchArray = new float[2]; touchArray = evaluateTouchKey(touchX[id], touchY[id]); touchX[id] = touchArray[0]; touchY[id] = touchArray[1]; // Log.d("touchXtouchY","touchX[id]) " + touchX[id] + " touchY[id]) " + touchY[id]); touchXPtr[id].SetValue(0, touchX[id]); touchYPtr[id].SetValue(0, touchY[id]); csoundObj.sendScore(String.format("i1.%d 0 -2 %d", id, id)); } } } break; case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_UP: { int activePointerIndex = event.getActionIndex(); int pointerId = event.getPointerId(activePointerIndex); int id = getTouchId(pointerId); if (id != -1) { touchIds[id] = -1; csoundObj.sendScore(String.format("i-1.%d 0 0 %d", id, id)); } //write file /* System.out.println(String.format( "i1.%d 0 -2 %d", id, id)); writeToFile(String.format( "i1.%d 0 -2 %d", id, id)); */ } break; } return true; } }); OnTouchListener octBtnOk = new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: if (octNbr < 12) octNbr += 12; break; } return false; } }; octPlusButton.setOnTouchListener(octBtnOk); OnTouchListener octBtnMinus = new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: if (octNbr > -36) octNbr -= 12; break; } return false; } }; octMinusButton.setOnTouchListener(octBtnMinus); String csd = getResourceFileAsString(R.raw.multitouch_xy_kx); File f = createTempFile(csd); csoundObj.addBinding(this); csoundObj.startCsound(f); // initknobs(); initSeekBar(diode3, diode4); }