public final synchronized void setQueueDepth(int queue_depth) throws IOException { checkReleased(); stop(); close(); createQueue(queue_depth); }
private final void close() throws IOException { nClose(queue_address); } private final static native void nClose(long queue_address) throws IOException;
public final synchronized boolean getNextEvent(OSXEvent event) throws IOException { checkReleased(); return nGetNextEvent(queue_address, event); } private final static native boolean nGetNextEvent(long queue_address, OSXEvent event) throws IOException;
public final synchronized void release() throws IOException { if (!released) { released = true; try { stop(); close(); } finally { nReleaseQueue(queue_address); } } } private final static native void nReleaseQueue(long queue_address) throws IOException;
public OSXHIDQueue(long address, int queue_depth) throws IOException { this.queue_address = address; try { createQueue(queue_depth); } catch (IOException e) { release(); throw e; } }
public final static synchronized boolean getNextDeviceEvent(Event event, OSXHIDQueue queue) throws IOException { if (queue.getNextEvent(osx_event)) { OSXComponent component = queue.mapEvent(osx_event); event.set(component, component.getElement().convertValue(osx_event.getValue()), osx_event.getNanos()); return true; } else return false; } }
public final void addElement(OSXHIDElement element, OSXComponent component) throws IOException { nAddElement(queue_address, element.getCookie()); map.put(new Long(element.getCookie()), component); } private final static native void nAddElement(long queue_address, long cookie) throws IOException;
private final static void addElements(OSXHIDQueue queue, List elements, List components, boolean map_mouse_buttons) throws IOException { Iterator it = elements.iterator(); while (it.hasNext()) { OSXHIDElement element = (OSXHIDElement)it.next(); Component.Identifier id = element.getIdentifier(); if (id == null) continue; if (map_mouse_buttons) { if (id == Component.Identifier.Button._0) { id = Component.Identifier.Button.LEFT; } else if (id == Component.Identifier.Button._1) { id = Component.Identifier.Button.RIGHT; } else if (id == Component.Identifier.Button._2) { id = Component.Identifier.Button.MIDDLE; } } OSXComponent component = new OSXComponent(id, element); components.add(component); queue.addElement(element, component); } }
public final synchronized OSXHIDQueue createQueue(int queue_depth) throws IOException { checkReleased(); long queue_address = nCreateQueue(device_interface_address); return new OSXHIDQueue(queue_address, queue_depth); } private final static native long nCreateQueue(long device_interface_address) throws IOException;