public OSXHIDQueue(long address, int queue_depth) throws IOException { this.queue_address = address; try { createQueue(queue_depth); } catch (IOException e) { release(); throw e; } }
private final static AbstractController createControllerFromDevice(OSXHIDDevice device, List elements, Controller.Type type) throws IOException { List components = new ArrayList(); OSXHIDQueue queue = device.createQueue(AbstractController.EVENT_QUEUE_DEPTH); try { addElements(queue, elements, components, false); } catch (IOException e) { queue.release(); throw e; } Component[] components_array = new Component[components.size()]; components.toArray(components_array); AbstractController controller = new OSXAbstractController(device, queue, components_array, new Controller[]{}, new Rumbler[]{}, type); return controller; }
private final static Keyboard createKeyboardFromDevice(OSXHIDDevice device, List elements) throws IOException { List components = new ArrayList(); OSXHIDQueue queue = device.createQueue(AbstractController.EVENT_QUEUE_DEPTH); try { addElements(queue, elements, components, false); } catch (IOException e) { queue.release(); throw e; } Component[] components_array = new Component[components.size()]; components.toArray(components_array); Keyboard keyboard = new OSXKeyboard(device, queue, components_array, new Controller[]{}, new Rumbler[]{}); return keyboard; }
private final static Mouse createMouseFromDevice(OSXHIDDevice device, List elements) throws IOException { List components = new ArrayList(); OSXHIDQueue queue = device.createQueue(AbstractController.EVENT_QUEUE_DEPTH); try { addElements(queue, elements, components, true); } catch (IOException e) { queue.release(); throw e; } Component[] components_array = new Component[components.size()]; components.toArray(components_array); Mouse mouse = new OSXMouse(device, queue, components_array, new Controller[]{}, new Rumbler[]{}); if (mouse.getPrimaryButton() != null && mouse.getX() != null && mouse.getY() != null) { return mouse; } else { queue.release(); return null; } }