Java Code Examples for android.view.InputDevice#SOURCE_STYLUS

The following examples show how to use android.view.InputDevice#SOURCE_STYLUS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MotionEvents.java    From android-test with Apache License 2.0 6 votes vote down vote up
private static MotionEvent.PointerProperties[] getPointerProperties(int inputDevice) {
  MotionEvent.PointerProperties[] pointerProperties = {new MotionEvent.PointerProperties()};
  pointerProperties[0].clear();
  pointerProperties[0].id = 0;
  switch (inputDevice) {
    case InputDevice.SOURCE_MOUSE:
      pointerProperties[0].toolType = MotionEvent.TOOL_TYPE_MOUSE;
      break;
    case InputDevice.SOURCE_STYLUS:
      pointerProperties[0].toolType = MotionEvent.TOOL_TYPE_STYLUS;
      break;
    case InputDevice.SOURCE_TOUCHSCREEN:
      pointerProperties[0].toolType = MotionEvent.TOOL_TYPE_FINGER;
      break;
    default:
      pointerProperties[0].toolType = MotionEvent.TOOL_TYPE_UNKNOWN;
      break;
  }
  return pointerProperties;
}
 
Example 2
Source File: ActionsExecutor.java    From appium-uiautomator2-server with Apache License 2.0 5 votes vote down vote up
private static int toolTypeToInputSource(final int toolType) {
    switch (toolType) {
        case MotionEvent.TOOL_TYPE_MOUSE:
            return InputDevice.SOURCE_MOUSE;
        case MotionEvent.TOOL_TYPE_STYLUS:
            return InputDevice.SOURCE_STYLUS;
        default:
            return InputDevice.SOURCE_TOUCHSCREEN;
    }
}