MotionEvent getAxisValue - 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 getAxisValue method.

This code example shows how to use the following methods:getAxisValue
	} 
 
	@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
	private static class GetAxisValueAccessorHoneyComb { 
		private static float getAxisValue(final MotionEvent event, final int axis) {
			return event.getAxisValue(axis);
		} 
	} 
 
	@TargetApi(Build.VERSION_CODES.GINGERBREAD)
	private static class GetSourceAccessorGingerbread { 
		private static int getSource(final MotionEvent event) {
			return event.getSource();
		} 
	} 
} 
6
CodeRank
This code example shows how to use the following methods:getAxisValue, getSource
        step(historyPos < 0 ? event.getEventTime() : event.getHistoricalEventTime(historyPos));
    } 
 
    private static float getCenteredAxis(MotionEvent event, InputDevice device,
            int axis, int historyPos) {
        final InputDevice.MotionRange range = device.getMotionRange(axis, event.getSource());
        if (range != null) {
            final float flat = range.getFlat();
            final float value = historyPos < 0 ? event.getAxisValue(axis)
                    : event.getHistoricalAxisValue(axis, historyPos);
 
            // Ignore axis values that are within the 'flat' region of the joystick axis center. 
            // A joystick at rest does not always report an absolute position of (0,0). 
            if (Math.abs(value) > flat) {
                return value;
            } 
        } 
        return 0; 
    } 
 
6
CodeRank
This code example shows how to use the following methods:getAction, getAxisValue, getOrientation, getPointerCoords
		layout.setOnTouchListener(new View.OnTouchListener() {
			 
			@Override 
			public boolean onTouch(View view, MotionEvent event) {
				// TODO Auto-generated method stub 
				int action = event.getAction();
				PointerCoords curCoord = new PointerCoords();
				event.getPointerCoords(0, curCoord);
				Calendar calendar = Calendar.getInstance();
				long curTime = calendar.getTimeInMillis();
				switch(action) {
				case MotionEvent.ACTION_DOWN:
					xTouchDown = event.getAxisValue(MotionEvent.AXIS_X);// curCoord.x;
					yTouchDown = curCoord.y;
					timeTouchDown = curTime;
					cntDataPoint = 0;
					break; 
//				case MotionEvent.ACTION_MOVE: 
					default: 
					int dt = (int) (curTime - timeTouchDown);

5
CodeRank
This code example shows how to use the following methods:getAxisValue
		return event.getSource();
	} 
	 
	public static float MotionEventGetAxisValue(final MotionEvent event, final int axis)
	{ 
		return event.getAxisValue(axis);
	} 
} 
4
CodeRank
This code example shows how to use the following methods:getAction, getAxisValue, getMetaState, getSource
        return true; 
    } 
 
    @Override 
    public boolean onGenericMotionEvent(MotionEvent event) {
        if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
            switch (event.getAction()) {
                case MotionEvent.ACTION_SCROLL: {
                    // Handle mouse (or ext. device) by shifting the page depending on the scroll 
                    final float vscroll;
                    final float hscroll;
                    if ((event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0) {
                        vscroll = 0;
                        hscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
                    } else { 
                        vscroll = -event.getAxisValue(MotionEvent.AXIS_VSCROLL);
                        hscroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
                    } 
                    if (hscroll != 0 || vscroll != 0) {
                        if (hscroll > 0 || vscroll > 0) {

4
CodeRank
getAxisValue Method Overview
getAxisValue(int) for the first pointer index (may be an arbitrary pointer identifier).
See Code Examples for other Android MotionEvent Methods: