Code example for VelocityTracker

Methods: getXVelocitygetYVelocityaddMovementcomputeCurrentVelocity

0
            	mListener.sendGcode("g0x" + cx + "y" + cy + "z5");
            	Log.i("Gcode, init mode","g0x" + cx + "y" + cy + "z5");
		         
	 			break; 
	 		case MotionEvent.ACTION_MOVE:
	 			mVelocityTracker.addMovement(event);
	 			 cx = event.getRawX();
		         cy = event.getRawY();
		        nb_points++;
		        //  Code to display x and y go here 
		        // When you want to determine the velocity, call  
                // computeCurrentVelocity(). Then call getXVelocity()  
                // and getYVelocity() to retrieve the velocity for each pointer ID.  
                mVelocityTracker.computeCurrentVelocity(1000);
                velocityX = VelocityTrackerCompat.getXVelocity(mVelocityTracker, pointerId);
                velocityY = VelocityTrackerCompat.getYVelocity(mVelocityTracker, pointerId);
                 
                float abs_velocityX = (velocityX < 0) ? -velocityX : velocityX;
                float abs_velocityY = (velocityY < 0) ? -velocityY : velocityY;
                 
                // Log velocity of pixels per second 
Experience pair programming with AI  Get Codota for Java