List of usage examples for android.view InputDevice SOURCE_CLASS_POINTER
int SOURCE_CLASS_POINTER
To view the source code for android.view InputDevice SOURCE_CLASS_POINTER.
Click Source Link
From source file:Main.java
public static MotionEvent hoverMotionEventAtPosition(View view, int action, int xPercent, int yPercent) { MotionEvent ev = motionEventAtPosition(view, action, xPercent, yPercent); MotionEvent.PointerProperties[] pointerProperties = new MotionEvent.PointerProperties[1]; pointerProperties[0] = new MotionEvent.PointerProperties(); MotionEvent.PointerCoords[] pointerCoords = new MotionEvent.PointerCoords[1]; pointerCoords[0] = new MotionEvent.PointerCoords(); pointerCoords[0].x = ev.getX();//from w w w . ja va 2 s .com pointerCoords[0].y = ev.getY(); return MotionEvent.obtain(ev.getDownTime(), ev.getEventTime(), ev.getAction(), 1, pointerProperties, pointerCoords, ev.getMetaState(), 0, ev.getXPrecision(), ev.getYPrecision(), ev.getDeviceId(), ev.getEdgeFlags(), InputDevice.SOURCE_CLASS_POINTER, ev.getFlags()); }
From source file:Main.java
/** * Gets the name of the source performing an action. * /*from ww w.j a v a2 s . c o m*/ * @param source A number representing the source. * * @return The name of the source. */ public static String getSourceName(int source) { switch (source) { case InputDevice.SOURCE_CLASS_BUTTON: return "BUTTON"; case InputDevice.SOURCE_CLASS_POINTER: return "POINTER"; case InputDevice.SOURCE_CLASS_TRACKBALL: return "TRACKBALL"; case InputDevice.SOURCE_CLASS_POSITION: return "POSITION"; case InputDevice.SOURCE_CLASS_JOYSTICK: return "JOYSTICK"; case InputDevice.SOURCE_DPAD: return "dpad"; case InputDevice.SOURCE_GAMEPAD: return "gamepad"; case InputDevice.SOURCE_JOYSTICK: return "joystick"; case InputDevice.SOURCE_KEYBOARD: return "keyboard"; case InputDevice.SOURCE_MOUSE: return "mouse"; case InputDevice.SOURCE_STYLUS: return "stylus"; case InputDevice.SOURCE_TOUCHPAD: return "touchpad"; case InputDevice.SOURCE_TOUCHSCREEN: return "touchscreen"; case InputDevice.SOURCE_TRACKBALL: return "trackball"; case InputDevice.SOURCE_UNKNOWN: return "unknown"; default: return "source_" + source; } }
From source file:Main.java
@SuppressLint("InlinedApi") public static String getSourceClassesString(int sources) { List<String> names = new ArrayList<String>(); addString(sources, InputDevice.SOURCE_CLASS_BUTTON, names); addString(sources, InputDevice.SOURCE_CLASS_POINTER, names); addString(sources, InputDevice.SOURCE_CLASS_TRACKBALL, names); addString(sources, InputDevice.SOURCE_CLASS_POSITION, names); addString(sources, InputDevice.SOURCE_CLASS_JOYSTICK, names); return TextUtils.join(", ", names); }
From source file:org.mariotaku.twidere.view.RecyclerViewBackport.java
@Override public boolean onGenericMotionEvent(MotionEvent event) { final LayoutManager lm = getLayoutManager(); if (lm == null) { return false; }/*from w w w . j ava 2 s .c o m*/ if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { if (event.getAction() == MotionEventCompat.ACTION_SCROLL) { final float vScroll, hScroll; if (lm.canScrollVertically()) { vScroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL); if (!mMouseScrollDirectionDecider.isVerticalAvailable()) { mMouseScrollDirectionDecider.guessDirection(event); } } else { vScroll = 0f; } if (lm.canScrollHorizontally()) { hScroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL); if (!mMouseScrollDirectionDecider.isHorizontalAvailable()) { mMouseScrollDirectionDecider.guessDirection(event); } } else { hScroll = 0f; } if ((vScroll != 0 || hScroll != 0)) { final float scrollFactor = getScrollFactorBackport(); float horizontalDirection = mMouseScrollDirectionDecider.getHorizontalDirection(); float verticalDirection = mMouseScrollDirectionDecider.getVerticalDirection(); final float hFactor = scrollFactor * (horizontalDirection != 0 ? horizontalDirection : -1); final float vFactor = scrollFactor * (verticalDirection != 0 ? verticalDirection : -1); smoothScrollBy((int) (hScroll * hFactor), (int) (vScroll * vFactor)); } } } return false; }
From source file:org.mariotaku.twidere.view.ExtendedRecyclerView.java
@Override public boolean onGenericMotionEvent(MotionEvent event) { final LayoutManager lm = getLayoutManager(); if (lm == null) { return false; }/* w w w .j ava 2s.c o m*/ if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { if (event.getAction() == MotionEventCompat.ACTION_SCROLL) { final float vScroll, hScroll; if (lm.canScrollVertically()) { vScroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL); if (!mMouseScrollDirectionDecider.isVerticalAvailable()) { mMouseScrollDirectionDecider.guessDirection(event); } } else { vScroll = 0f; } if (lm.canScrollHorizontally()) { hScroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL); if (!mMouseScrollDirectionDecider.isHorizontalAvailable()) { mMouseScrollDirectionDecider.guessDirection(event); } } else { hScroll = 0f; } if ((vScroll != 0 || hScroll != 0)) { final float scrollFactor = getScrollFactorBackport(); float horizontalDirection = mMouseScrollDirectionDecider.getHorizontalDirection(); float verticalDirection = mMouseScrollDirectionDecider.getVerticalDirection(); final float hFactor = scrollFactor * (horizontalDirection != 0 ? horizontalDirection : -1); final float vFactor = scrollFactor * (verticalDirection != 0 ? verticalDirection : -1); scrollBy((int) (hScroll * hFactor), (int) (vScroll * vFactor)); } } } return false; }
From source file:org.mariotaku.twidere.util.MouseScrollDirectionDecider.java
public boolean guessDirection(MotionEvent event) { if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) == 0) { return false; }/* ww w .j av a 2 s. c o m*/ if (event.getAction() != MotionEventCompat.ACTION_SCROLL) return false; verticalScroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL); horizontalScroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL); verticalView.onGenericMotionEvent(event); horizontalView.onGenericMotionEvent(event); return verticalScroll != 0 || horizontalScroll != 0; }
From source file:foam.jellyfish.StarwispActivity.java
@Override public boolean onGenericMotionEvent(final MotionEvent event) { //Get the player # int player = OuyaController.getPlayerNumByDeviceId(event.getDeviceId()); Log.i("starwisp", "ogme"); // Joystick//from w ww . j av a 2s . c om if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { //Get all the axis for the event float LS_X = event.getAxisValue(OuyaController.AXIS_LS_X); float LS_Y = event.getAxisValue(OuyaController.AXIS_LS_Y); float RS_X = event.getAxisValue(OuyaController.AXIS_RS_X); float RS_Y = event.getAxisValue(OuyaController.AXIS_RS_Y); float L2 = event.getAxisValue(OuyaController.AXIS_L2); float R2 = event.getAxisValue(OuyaController.AXIS_R2); Log.i("starwisp", "controller " + LS_X + " " + LS_Y + RS_X + " " + RS_Y + L2 + " " + R2); Scheme.eval("(on-fling " + LS_X * -500 + " " + LS_Y * -500 + ")"); } //Touchpad if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { //Print the pixel coordinates of the cursor Log.i("starwisp", "Cursor X: " + event.getX() + "Cursor Y: " + event.getY()); } return true; }
From source file:org.mariotaku.twidere.view.TabPageIndicator.java
@Override public boolean onGenericMotionEvent(final MotionEvent event) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1) return false; if (mAdapter == null) return false; if ((MotionEventAccessor.getSource(event) & InputDevice.SOURCE_CLASS_POINTER) != 0) { switch (event.getAction()) { case MotionEvent.ACTION_SCROLL: { final float vscroll = MotionEventAccessor.getAxisValue(event, MotionEvent.AXIS_VSCROLL); if (vscroll < 0) { if (mCurrentItem + 1 < mAdapter.getCount()) { setCurrentItem(mCurrentItem + 1); }/*from w w w . ja va2 s .co m*/ } else if (vscroll > 0) { if (mCurrentItem - 1 >= 0) { setCurrentItem(mCurrentItem - 1); } } // if (vscroll != 0) { // final int delta = (int) (vscroll * // getVerticalScrollFactor()); // if (!trackMotionScroll(delta, delta)) { // return true; // } // } } } } return true; }
From source file:com.afayear.android.client.view.TabPageIndicator.java
@Override public boolean onGenericMotionEvent(final MotionEvent event) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1) return false; if (mTabProvider == null) return false; if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { switch (event.getAction()) { case MotionEvent.ACTION_SCROLL: { final float vscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL); if (vscroll < 0) { if (mCurrentItem + 1 < mTabProvider.getCount()) { setCurrentItem(mCurrentItem + 1); }// ww w. ja v a2 s . c om } else if (vscroll > 0) { if (mCurrentItem - 1 >= 0) { setCurrentItem(mCurrentItem - 1); } } } } } return true; }
From source file:org.connectbot.util.TerminalTextViewOverlay.java
@Override @TargetApi(12)//from www . j av a 2s. co m public boolean onGenericMotionEvent(MotionEvent event) { if ((MotionEventCompat.getSource(event) & InputDevice.SOURCE_CLASS_POINTER) != 0) { switch (event.getAction()) { case MotionEvent.ACTION_SCROLL: // Process scroll wheel movement: float yDistance = MotionEventCompat.getAxisValue(event, MotionEvent.AXIS_VSCROLL); vt320 vtBuffer = (vt320) terminalView.bridge.buffer; boolean mouseReport = vtBuffer.isMouseReportEnabled(); if (mouseReport) { int row = (int) Math.floor(event.getY() / terminalView.bridge.charHeight); int col = (int) Math.floor(event.getX() / terminalView.bridge.charWidth); vtBuffer.mouseWheel(yDistance > 0, col, row, (event.getMetaState() & KeyEvent.META_CTRL_ON) != 0, (event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0, (event.getMetaState() & KeyEvent.META_META_ON) != 0); return true; } } } return super.onGenericMotionEvent(event); }