/** * Gets the ids of all input devices in the system. * * @return The input device ids. */ public static int[] getDeviceIds() { IWindowManager wm = Display.getWindowManager(); try { return wm.getInputDeviceIds(); } catch (RemoteException ex) { throw new RuntimeException("Could not get input device ids from Window Manager.", ex); } }
/** * Gets information about the input device with the specified id. * * @param id The device id. * @return The input device or null if not found. */ public static InputDevice getDevice(int id) { IWindowManager wm = Display.getWindowManager(); try { return wm.getInputDevice(id); } catch (RemoteException ex) { throw new RuntimeException("Could not get input device information from Window Manager.", ex); } }
/** * Queries the framework about whether any physical keys exist on the any keyboard attached to the * device that are capable of producing the given array of key codes. * * @param keyCodes The array of key codes to query. * @return A new array of the same size as the key codes array whose elements are set to true if * at least one attached keyboard supports the corresponding key code at the same index in the * key codes array. */ public static boolean[] deviceHasKeys(int[] keyCodes) { boolean[] ret = new boolean[keyCodes.length]; IWindowManager wm = Display.getWindowManager(); try { wm.hasKeys(keyCodes, ret); } catch (RemoteException e) { // no fallback; just return the empty array } return ret; }