List of usage examples for android.view MotionEvent getToolType
public final int getToolType(int pointerIndex)
From source file:Main.java
/** * Identifies if the provided {@link MotionEvent} is a stylus with the primary stylus button * pressed.//from w ww .j av a 2 s . c om * * @param event The event to check. * @return Whether a stylus button press occurred. */ private static boolean isStylusButtonPressed(MotionEvent event) { return event.getToolType(0) == MotionEvent.TOOL_TYPE_STYLUS && ((event.getButtonState() & MotionEvent.BUTTON_SECONDARY) == MotionEvent.BUTTON_SECONDARY); }
From source file:Main.java
/** * Identifies if the provided {@link MotionEvent} is a stylus with the primary stylus button * pressed./*from w w w.j a v a 2 s .c om*/ * * @param event The event to check. * @return Whether a stylus button press occurred. */ public static boolean isStylusButtonPressed(MotionEvent event) { return event.getToolType(0) == MotionEvent.TOOL_TYPE_STYLUS && event.isButtonPressed(MotionEvent.BUTTON_SECONDARY); }
From source file:com.mylikes.likes.etchasketch.Slate.java
@SuppressLint("NewApi") final static int getToolTypeCompat(MotionEvent me, int index) { if (hasToolType()) { return me.getToolType(index); }/*from w ww. j a va 2s.c o m*/ // dirty hack for the HTC Flyer if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { if ("flyer".equals(Build.HARDWARE)) { if (me.getSize(index) <= 0.1f) { // with very high probability this is the stylus return MotionEvent.TOOL_TYPE_STYLUS; } } } return MotionEvent.TOOL_TYPE_FINGER; }
From source file:com.undatech.opaque.RemoteCanvasActivity.java
@Override public boolean onGenericMotionEvent(MotionEvent event) { // Ignore TOOL_TYPE_FINGER events that come from the touchscreen with y == 0.0 // which cause pointer jumping trouble for some users. if (!(event.getY() == 0.0f && event.getSource() == InputDevice.SOURCE_TOUCHSCREEN && event.getToolType(0) == MotionEvent.TOOL_TYPE_FINGER)) { try {//from w w w. java2 s . c om return inputHandler.onTouchEvent(event); } catch (NullPointerException e) { } } return super.onGenericMotionEvent(event); }
From source file:com.iiordanov.bVNC.RemoteCanvasActivity.java
@Override public boolean onGenericMotionEvent(MotionEvent event) { // Ignore TOOL_TYPE_FINGER events that come from the touchscreen with HOVER type action // which cause pointer jumping trouble in simulated touchpad for some devices. int a = event.getAction(); if (!((a == MotionEvent.ACTION_HOVER_ENTER || a == MotionEvent.ACTION_HOVER_EXIT || a == MotionEvent.ACTION_HOVER_MOVE) && event.getSource() == InputDevice.SOURCE_TOUCHSCREEN && event.getToolType(0) == MotionEvent.TOOL_TYPE_FINGER)) { try {//from w w w. j av a 2s . co m return inputHandler.onTouchEvent(event); } catch (NullPointerException e) { } } return super.onGenericMotionEvent(event); }