List of usage examples for android.view InputDevice SOURCE_CLASS_BUTTON
int SOURCE_CLASS_BUTTON
To view the source code for android.view InputDevice SOURCE_CLASS_BUTTON.
Click Source Link
From source file:Main.java
public static int getConnectedInputDevices() { int[] deviceIDs = InputDevice.getDeviceIds(); int result = 0; for (int i = 0; i < deviceIDs.length; i++) { InputDevice dev = InputDevice.getDevice(deviceIDs[i]); /*if (dev.isVirtual()) continue;*///from w w w . j a v a 2 s . com int sources = dev.getSources(); if ((sources & InputDevice.SOURCE_CLASS_BUTTON) != 0) result++; } return result; }
From source file:Main.java
/** * Gets the name of the source performing an action. * //from ww w . j a va2 s .com * @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); }