/** Overriding {@link View#onGenericMotionEvent(MotionEvent)}. */ @Override public boolean onGenericMotionEvent(MotionEvent event) { if (mEmulator != null && event.isFromSource(InputDevice.SOURCE_MOUSE) && event.getAction() == MotionEvent.ACTION_SCROLL) { // Handle mouse wheel scrolling. boolean up = event.getAxisValue(MotionEvent.AXIS_VSCROLL) > 0.0f; doScroll(event, up ? -3 : 3); return true; } return false; }
public boolean onGenericMotion (MotionEvent event, AndroidInput input) { if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) == 0) return false; final int action = event.getAction() & MotionEvent.ACTION_MASK; int x = 0, y = 0; int scrollAmount = 0; long timeStamp = System.nanoTime(); synchronized (input) { switch (action) { case MotionEvent.ACTION_HOVER_MOVE: x = (int)event.getX(); y = (int)event.getY(); if ((x != deltaX) || (y != deltaY)) { // Avoid garbage events postTouchEvent(input, TouchEvent.TOUCH_MOVED, x, y, 0, timeStamp); deltaX = x; deltaY = y; } break; case MotionEvent.ACTION_SCROLL: scrollAmount = (int)-Math.signum(event.getAxisValue(MotionEvent.AXIS_VSCROLL)); postTouchEvent(input, TouchEvent.TOUCH_SCROLLED, 0, 0, scrollAmount, timeStamp); } } Gdx.app.getGraphics().requestRendering(); return true; }
public boolean onGenericMotion (MotionEvent event, AndroidInput input) { if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) == 0) return false; final int action = event.getAction() & MotionEvent.ACTION_MASK; int x = 0, y = 0; int scrollAmount = 0; long timeStamp = System.nanoTime(); synchronized (input) { switch (action) { case MotionEvent.ACTION_HOVER_MOVE: x = (int)event.getX(); y = (int)event.getY(); if ((x != deltaX) || (y != deltaY)) { // Avoid garbage events postTouchEvent(input, TouchEvent.TOUCH_MOVED, x, y, 0, timeStamp); deltaX = x; deltaY = y; } break; case MotionEvent.ACTION_SCROLL: scrollAmount = (int)-Math.signum(event.getAxisValue(MotionEvent.AXIS_VSCROLL)); postTouchEvent(input, TouchEvent.TOUCH_SCROLLED, 0, 0, scrollAmount, timeStamp); } } Gdx.app.getGraphics().requestRendering(); return true; }
float povX = motionEvent.getAxisValue(MotionEvent.AXIS_HAT_X); float povY = motionEvent.getAxisValue(MotionEvent.AXIS_HAT_Y); if (Float.compare(povY, -1.0f) == 0) { direction |= 0x00000001; float axisValue = motionEvent.getAxisValue(axisId); if(controller.getAxis(axisIndex) == axisValue) { axisIndex++;
for (int androidAxis: joystick.getAndroidAxes()) { String axisName = MotionEvent.axisToString(androidAxis); float value = event.getAxisValue(androidAxis); int action = event.getAction(); if (action == MotionEvent.ACTION_MOVE) {
case MotionEvent.ACTION_SCROLL: { if (!mIsBeingDragged) { final float vscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL); final float hscroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL); if (vscroll != 0) { final int verticalScrollRange = getVerticalScrollRange();
public static void input(MotionEvent event) { newGamepadMap.axisX = event.getAxisValue(MotionEvent.AXIS_X); newGamepadMap.axisY = event.getAxisValue(MotionEvent.AXIS_Y); newGamepadMap.axisHatX = event.getAxisValue(MotionEvent.AXIS_HAT_X); newGamepadMap.axisHatY = event.getAxisValue(MotionEvent.AXIS_HAT_Y); newGamepadMap.axisRX = event.getAxisValue(MotionEvent.AXIS_RX); newGamepadMap.axisRY = event.getAxisValue(MotionEvent.AXIS_RY); }
public class Sniffer extends Activity { @Override public boolean dispatchTouchEvent(MotionEvent event) { float x = event.getAxisValue(MotionEvent.AXIS_X); float y = event.getAxisValue(MotionEvent.AXIS_Y); Log.i("t...OUCH: ", x + " " + y); return super.dispatchTouchEvent(event); } }
static float getAxisValue(MotionEvent event, int axis, int pointerIndex) { return event.getAxisValue(axis, pointerIndex); } }
static float getAxisValue(MotionEvent event, int axis) { return event.getAxisValue(axis); }
@Override public boolean onGenericMotionEvent(MotionEvent event) { Log.d("Right Trigger Value", event.getAxisValue(MotionEvent.AXIS_RTRIGGER) + ""); Log.d("Left Trigger Value", event.getAxisValue(MotionEvent.AXIS_LTRIGGER) + ""); Log.d("Left Stick X", event.getX() + ""); Log.d("Left Stick Y", event.getY() + ""); Log.d("Right Stick Y", event.getAxisValue(MotionEvent.AXIS_RZ) + ""); Log.d("Right Stick X", event.getAxisValue(MotionEvent.AXIS_Z) + ""); return super.onGenericMotionEvent(event); }
public static void input(MotionEvent event) { // https://github.com/Samsung/GearVRf/issues/231 newTouchPadMap.axisX = event.getAxisValue(MotionEvent.AXIS_X); newTouchPadMap.axisY = event.getAxisValue(MotionEvent.AXIS_Y); if (event.getAction() == KeyEvent.ACTION_DOWN) { newTouchPadMap.buttonState.pressed = true; } if (event.getAction() == KeyEvent.ACTION_UP) { newTouchPadMap.buttonState.pressed = false; } }
public static void input(MotionEvent event) { // https://github.com/Samsung/GearVRf/issues/231 newTouchPadMap.axisX = event.getAxisValue(MotionEvent.AXIS_X); newTouchPadMap.axisY = event.getAxisValue(MotionEvent.AXIS_Y); if (event.getAction() == KeyEvent.ACTION_DOWN) { newTouchPadMap.buttonState.pressed = true; } if (event.getAction() == KeyEvent.ACTION_UP) { newTouchPadMap.buttonState.pressed = false; } }
public static void debugOuyaMotionEvent(MotionEvent motionEvent) { Log.i(TAG, "("+RazerController.AXIS_DPAD_X + ") OuyaController.AXIS_LS_X value="+motionEvent.getAxisValue(RazerController.AXIS_DPAD_X)); Log.i(TAG, "("+RazerController.AXIS_DPAD_Y + ") OuyaController.AXIS_LS_X value="+motionEvent.getAxisValue(RazerController.AXIS_DPAD_Y)); Log.i(TAG, "("+RazerController.AXIS_LS_X + ") OuyaController.AXIS_LS_X value="+motionEvent.getAxisValue(RazerController.AXIS_LS_X)); Log.i(TAG, "("+RazerController.AXIS_LS_Y + ") OuyaController.AXIS_LS_Y value="+motionEvent.getAxisValue(RazerController.AXIS_LS_Y)); Log.i(TAG, "("+RazerController.AXIS_RS_X + ") OuyaController.AXIS_RS_X value="+motionEvent.getAxisValue(RazerController.AXIS_RS_X)); Log.i(TAG, "("+RazerController.AXIS_RS_Y + ") OuyaController.AXIS_RS_Y value="+motionEvent.getAxisValue(RazerController.AXIS_RS_Y)); Log.i(TAG, "("+RazerController.AXIS_L2 + ") OuyaController.AXIS_L2 value="+motionEvent.getAxisValue(RazerController.AXIS_L2)); Log.i(TAG, "("+RazerController.AXIS_R2 + ") OuyaController.AXIS_R2 value="+motionEvent.getAxisValue(RazerController.AXIS_R2)); }
@Override public boolean onGenericMotionEvent(MotionEvent event) { if (0 != (event.getSource() & InputDevice.SOURCE_CLASS_POINTER)) { switch (event.getAction()) { case MotionEvent.ACTION_SCROLL: if (event.getAxisValue(MotionEvent.AXIS_VSCROLL) < 0.0f) selectNext() else selectPrev(); return true; } } return super.onGenericMotionEvent(event); }
@Override public boolean onGenericMotionEvent(MotionEvent event) { if (0 != (event.getSource() & InputDevice.SOURCE_CLASS_POINTER)) { switch (event.getAction()) { case MotionEvent.ACTION_SCROLL: if (event.getAxisValue(MotionEvent.AXIS_VSCROLL) < 0.0f) selectNext() else selectPrev(); return true; } } return super.onGenericMotionEvent(event); }
/** Overriding {@link View#onGenericMotionEvent(MotionEvent)}. */ @Override public boolean onGenericMotionEvent(MotionEvent event) { if (mEmulator != null && event.isFromSource(InputDevice.SOURCE_MOUSE) && event.getAction() == MotionEvent.ACTION_SCROLL) { // Handle mouse wheel scrolling. boolean up = event.getAxisValue(MotionEvent.AXIS_VSCROLL) > 0.0f; doScroll(event, up ? -3 : 3); return true; } return false; }
@Override public boolean onGenericMotionEvent(MotionEvent e) { if (e.getAction() == MotionEvent.ACTION_SCROLL) { final float distanceY = e.getAxisValue(MotionEvent.AXIS_VSCROLL); accumulatedDistanceY += distanceY; if (accumulatedDistanceY > MinDistanceToSendGenericScroll || accumulatedDistanceY < -MinDistanceToSendGenericScroll) { sendScroll(accumulatedDistanceY); accumulatedDistanceY = 0; } } return super.onGenericMotionEvent(e); }
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; }
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; }