List of usage examples for android.view InputDevice SOURCE_TOUCHSCREEN
int SOURCE_TOUCHSCREEN
To view the source code for android.view InputDevice SOURCE_TOUCHSCREEN.
Click Source Link
From source file:Main.java
@SuppressLint("InlinedApi") public static String getSourcesString(int sources) { List<String> names = new ArrayList<String>(); addString(sources, InputDevice.SOURCE_KEYBOARD, names); addString(sources, InputDevice.SOURCE_DPAD, names); addString(sources, InputDevice.SOURCE_GAMEPAD, names); addString(sources, InputDevice.SOURCE_TOUCHSCREEN, names); addString(sources, InputDevice.SOURCE_MOUSE, names); addString(sources, InputDevice.SOURCE_STYLUS, names); addString(sources, InputDevice.SOURCE_TOUCHPAD, names); addString(sources, InputDevice.SOURCE_JOYSTICK, names); return TextUtils.join(", ", names); }
From source file:Main.java
/** * Gets the name of the source performing an action. * /*from w w w.j a v a 2s . co 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:love.juhe.androidmonkey.MonkeyTouchEvent.java
public MonkeyTouchEvent(int action) { super(MonkeyEvent.EVENT_TYPE_TOUCH, InputDevice.SOURCE_TOUCHSCREEN, action); }
From source file:net.hoodalabs.cordova.plugins.touchevent.HoodalabsTouchEvent.java
@Override public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException { if ("fireAt".equals(action)) { final float x = args.getInt(0); final float y = args.getInt(1); // List of meta states found here: developer.android.com/reference/android/view/KeyEvent.html#getMetaState() final int metaState = 0; final long timestamp = SystemClock.uptimeMillis(); MotionEvent touchStart = MotionEvent.obtain(timestamp, timestamp + 50, MotionEvent.ACTION_DOWN, x, y, metaState);//from w w w.ja v a 2 s . com touchStart.setSource(InputDevice.SOURCE_TOUCHSCREEN); webView.dispatchTouchEvent(touchStart); MotionEvent touchEnd = MotionEvent.obtain(timestamp + 50, timestamp + 100, MotionEvent.ACTION_UP, x, y, metaState); touchEnd.setSource(InputDevice.SOURCE_TOUCHSCREEN); webView.dispatchTouchEvent(touchEnd); callbackContext.success(); // Thread-safe. return true; } return false; }
From source file:org.gearvrf.weartouchpad.WearInputService.java
@Override public void onCreate() { super.onCreate(); apiClient = new GoogleApiClient.Builder(this).addApi(Wearable.API).build(); apiClient.connect();/*from w w w .ja v a 2s . c om*/ nodes = new HashSet<Node>(); receiveMessenger = new Messenger(new IncomingMsgHandler()); broadcastManager = LocalBroadcastManager.getInstance(this); localBinder = new LocalBinder(); connectedToWatch = false; int touchScreenDeviceId = 0; InputManager im = (InputManager) getSystemService(Context.INPUT_SERVICE); for (int inputDevId : im.getInputDeviceIds()) { InputDevice inputDevice = im.getInputDevice(inputDevId); if ((inputDevice.getSources() & InputDevice.SOURCE_TOUCHSCREEN) == InputDevice.SOURCE_TOUCHSCREEN) { touchScreenDeviceId = inputDevId; break; } } motionEventGenerator = new MotionEventGenerator(touchScreenDeviceId); }
From source file:com.amazon.appstream.fireclient.FireClientActivity.java
/** * A "touch event" includes mouse motion when the mouse button * is down.//from w ww.ja va2 s . c o m */ @Override public boolean dispatchTouchEvent(MotionEvent event) { if (mKeyboardActive) { if (mGestureDetector.onTouchEvent(event)) { return true; } } if (super.dispatchTouchEvent(event)) return true; int flags = 0; if (event.getSource() == InputDevice.SOURCE_TOUCHSCREEN) { flags = AppStreamInterface.CET_TOUCH_FLAG; } event.getPointerCoords(0, mCoordHolder); switch (event.getAction()) { case MotionEvent.ACTION_MOVE: AppStreamInterface.mouseEvent((int) mCoordHolder.x, (int) mCoordHolder.y, flags); break; case MotionEvent.ACTION_DOWN: AppStreamInterface.mouseEvent((int) mCoordHolder.x, (int) mCoordHolder.y, AppStreamInterface.CET_MOUSE_1_DOWN | flags); break; case MotionEvent.ACTION_UP: AppStreamInterface.mouseEvent((int) mCoordHolder.x, (int) mCoordHolder.y, AppStreamInterface.CET_MOUSE_1_UP | flags); break; } return true; }
From source file:com.google.fpl.voltair.VoltAirActivity.java
/** * @brief Returns the hardware deviceId of the touch screen input device, or -1 if none exists. * @note If multiple touch screen devices are present, this returns the id of the first one * discovered./*from w w w .j a va2 s . c om*/ */ public int getTouchScreenDeviceId() { for (int deviceId : mInputManager.getInputDeviceIds()) { InputDevice device = mInputManager.getInputDevice(deviceId); if (isSourceType(device, InputDevice.SOURCE_TOUCHSCREEN)) { return device.getId(); } } return -1; }
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 {//ww w. j av a2 s . com 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 www . j ava 2s . c om*/ return inputHandler.onTouchEvent(event); } catch (NullPointerException e) { } } return super.onGenericMotionEvent(event); }