List of usage examples for android.view MotionEvent getAxisValue
public final float getAxisValue(int axis)
From source file:com.example.libwidgettv.bak.AbsListView.java
@Override public boolean onGenericMotionEvent(MotionEvent event) { if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { switch (event.getAction()) { case MotionEvent.ACTION_SCROLL: { if (mTouchMode == TOUCH_MODE_REST) { final float vscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL); if (vscroll != 0) { final int delta = (int) (vscroll * 0.3); if (!trackMotionScroll(delta, delta)) { return true; }/*from w w w. ja va2s . c o m*/ } } } } } return super.onGenericMotionEvent(event); }
From source file:com.appunite.list.AbsHorizontalListView.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @Override/*from w ww .jav a 2 s.co m*/ public boolean onGenericMotionEvent(MotionEvent event) { if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { switch (event.getAction()) { case MotionEvent.ACTION_SCROLL: { if (mTouchMode == TOUCH_MODE_REST) { final float hscroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL); if (hscroll != 0) { final int delta = (int) (hscroll * getHorizontalScrollFactorUnhide()); if (!trackMotionScroll(delta, delta)) { return true; } } } } } } return super.onGenericMotionEvent(event); }
From source file:com.appunite.list.AbsListView.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @Override/* w w w .j ava 2 s. com*/ public boolean onGenericMotionEvent(MotionEvent event) { if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { switch (event.getAction()) { case MotionEvent.ACTION_SCROLL: { if (mTouchMode == TOUCH_MODE_REST) { final float vscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL); if (vscroll != 0) { final int delta = (int) (vscroll * getVerticalScrollFactorUnhide()); if (!trackMotionScroll(delta, delta)) { return true; } } } } } } return super.onGenericMotionEvent(event); }
From source file:jmri.enginedriver.throttle.java
@Override public boolean dispatchGenericMotionEvent(android.view.MotionEvent event) { //Log.d("Engine_Driver", "dgme " + event.getAction()); // if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB_MR1) { if (!whichGamePadMode.equals(WHICH_GAMEPAD_MODE_NONE)) { // respond to the gamepad and keyboard inputs only if the preference is set boolean acceptEvent = true; // default to assuming that we will respond to the event int action; int whichThrottle; int repeatCnt = 0; int whichGamePadIsEventFrom = findWhichGamePadEventIsFrom(event.getDeviceId(), 0); // dummy eventKeyCode if ((whichGamePadIsEventFrom > -1) && (whichGamePadIsEventFrom < gamePadDeviceIdsTested.length)) { // the event came from a gamepad if (gamePadDeviceIdsTested[getGamePadIndexFromThrottleNo( whichGamePadIsEventFrom)] != GAMEPAD_GOOD) { //if not, testing for this gamepad is not complete or has failed acceptEvent = false;/*from w ww . java 2 s . co m*/ } } else { acceptEvent = false; } if (acceptEvent) { float xAxis; xAxis = event.getAxisValue(MotionEvent.AXIS_X); float yAxis = event.getAxisValue(MotionEvent.AXIS_Y); float xAxis2 = event.getAxisValue(MotionEvent.AXIS_Z); float yAxis2 = event.getAxisValue(MotionEvent.AXIS_RZ); if ((xAxis != 0) || (yAxis != 0)) { action = ACTION_DOWN; } else { action = ACTION_UP; } if ((usingMultiplePads) && (whichGamePadIsEventFrom >= -1)) { // we have multiple gamepads AND the preference is set to make use of them AND the event came for a gamepad if (whichGamePadIsEventFrom >= 0) { whichThrottle = whichGamePadIsEventFrom; } else { GamepadFeedbackSound(true); return (true); } } else { whichThrottle = whichVolume; // work out which throttle the volume keys are currently set to contol... and use that one } boolean isActive = getConsist(whichThrottle).isActive(); if (action == ACTION_UP) { mGamepadAutoIncrement = false; mGamepadAutoDecrement = false; GamepadFeedbackSoundStop(); } if (yAxis == -1) { // DPAD Up Button performButtonAction(5, action, isActive, whichThrottle, whichGamePadIsEventFrom, repeatCnt); return (true); // stop processing this key } else if (yAxis == 1) { // DPAD Down Button performButtonAction(7, action, isActive, whichThrottle, whichGamePadIsEventFrom, repeatCnt); return (true); // stop processing this key } else if (xAxis == -1) { // DPAD Left Button performButtonAction(8, action, isActive, whichThrottle, whichGamePadIsEventFrom, repeatCnt); return (true); // stop processing this key } else if (xAxis == 1) { // DPAD Right Button performButtonAction(6, action, isActive, whichThrottle, whichGamePadIsEventFrom, repeatCnt); return (true); // stop processing this key } if (yAxis2 == -1) { // DPAD2 Up Button performButtonAction(5, action, isActive, whichThrottle, whichGamePadIsEventFrom, repeatCnt); return (true); // stop processing this key } else if (yAxis2 == 1) { // DPAD2 Down Button performButtonAction(7, action, isActive, whichThrottle, whichGamePadIsEventFrom, repeatCnt); return (true); // stop processing this key } else if (xAxis2 == -1) { // DPAD2 Left Button performButtonAction(8, action, isActive, whichThrottle, whichGamePadIsEventFrom, repeatCnt); return (true); // stop processing this key } else if (xAxis2 == 1) { // DPAD2 Right Button performButtonAction(6, action, isActive, whichThrottle, whichGamePadIsEventFrom, repeatCnt); return (true); // stop processing this key } } else { // event is from a gamepad that has not finished testing. Ignore it return (true); // stop processing this key } // } } return super.dispatchGenericMotionEvent(event); }