MotionEvent getDeviceId - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for MotionEvent getDeviceId method.

This code example shows how to use the following methods:getAction, getDeviceId, getSource
 
    @Override 
    public boolean dispatchGenericMotionEvent(MotionEvent event) {
        // Check that the event came from a joystick since a generic motion event 
        // could be almost anything. 
        if (isJoystick(event.getSource())
                && event.getAction() == MotionEvent.ACTION_MOVE) {
            // Update device state for visualization and logging. 
            InputDeviceState state = getInputDeviceState(event.getDeviceId());
            if (state != null && state.onJoystickMotion(event)) {
                mSummaryAdapter.show(state);
            } 
        } 
        return super.dispatchGenericMotionEvent(event);
    } 
 
    private InputDeviceState getInputDeviceState(int deviceId) {
        InputDeviceState state = mInputDeviceStates.get(deviceId);
        if (state == null) {
            final InputDevice device = mInputManager.getInputDevice(deviceId);
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getDeviceId, getDownTime, getEdgeFlags, getEventTime, getMetaState
			return false; 
		} 
		 
		private boolean actionMove(MotionEvent event)
		{ 
			int newDistance = mMotionStartX - (int) event.getX();
			int newDirection;
			 
			if(newDistance<0) //backwards
			{ 
				newDirection =  (mDistanceX+4 <= newDistance) ? 1 : -1;  //the distance +4 is to allow for jitter
			} 
			else //forwards 
			{ 
				newDirection =  (mDistanceX-4 <= newDistance) ? 1 : -1;  //the distance -4 is to allow for jitter
			} 
			 
			 
			if(newDirection != mPreviousDirection && !mFirstMotionEvent)//changed direction, so reset start point
			{ 

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getDeviceId, getDownTime, getEdgeFlags, getEventTime, getMetaState
            return false; 
        } 
 
        private boolean actionMove(MotionEvent event)
        { 
            int newDistance = mMotionStartX - (int) event.getX();
            int newDirection;
 
            if (newDistance < 0) // backwards
            { 
                newDirection = (mDistanceX + 4 <= newDistance) ? 1 : -1; // the
                                                                         // distance 
                                                                         // +4 
                                                                         // is 
                                                                         // to 
                                                                         // allow 
                                                                         // for 
                                                                         // jitter 
            } 
            else // forwards 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
getDeviceId Method Overview
Gets the id for the device that this event came from.
See Code Examples for other Android MotionEvent Methods: