@Override public Queue<ControllerAction> getInputQueue() { Queue<ControllerAction> result = new ArrayDeque<>(); Event event = new Event(); Iterator<Controller> it = controllers.iterator(); while (it.hasNext()) { Controller c = it.next(); if (c.poll()) { EventQueue queue = c.getEventQueue(); while (queue.getNextEvent(event)) { ControllerAction action = convertEvent(c, event); if (action != null) { result.add(action); } } } else { removeController(c); } } return result; }
/** * Check if the queue is full * @return true if the queue is full */ final synchronized boolean isFull() { return increase(tail) == head; }
public final synchronized void setBufferSize(int size) { event_queue = new EventQueue(size); }
/** * Check if the queue is full * @return true if the queue is full */ final synchronized boolean isFull() { return increase(tail) == head; }
public final synchronized void setBufferSize(int size) { event_queue = new EventQueue(size); }
while (q.getNextEvent(e)){ Identifier id = e.getComponent().getIdentifier(); if (id == Identifier.Axis.POV){
/** * Check if the queue is full * @return true if the queue is full */ final synchronized boolean isFull() { return increase(tail) == head; }
/** * Creates a new EventQueue. Events in old queue are lost. */ public final void setEventQueueSize(int size) { try { setDeviceEventQueueSize(size); event_queue = new EventQueue(size); } catch (IOException e) { ControllerEnvironment.log("Failed to create new event queue of size " + size + ": " + e); } }
public final synchronized boolean getNextEvent(Event event) throws IOException { return event_queue.getNextEvent(event); }
/** * Check if the queue is full * @return true if the queue is full */ final synchronized boolean isFull() { return increase(tail) == head; }
/** * Creates a new EventQueue. Events in old queue are lost. */ public final void setEventQueueSize(int size) { try { setDeviceEventQueueSize(size); event_queue = new EventQueue(size); } catch (IOException e) { ControllerEnvironment.log("Failed to create new event queue of size " + size + ": " + e); } }
public final synchronized boolean getNextEvent(Event event) throws IOException { return event_queue.getNextEvent(event); }
/** * This is an internal method and should not be called by applications using the API */ final synchronized void add(Event event) { queue[tail].set(event); tail = increase(tail); }
/** * Creates a new EventQueue. Events in old queue are lost. */ public final void setEventQueueSize(int size) { try { setDeviceEventQueueSize(size); event_queue = new EventQueue(size); } catch (IOException e) { ControllerEnvironment.log("Failed to create new event queue of size " + size + ": " + e); } }
@Override public void run(){ Thread.currentThread().setName("GamepadEventThread"); while(true){ while(!eventQueue.getNextEvent(event)) try{Thread.sleep(20); if(!controller.poll()){ System.err.println("WARNING: Lost contact with controller: "+controller.getName()+". Escaping poll loop..."); return; } }catch(InterruptedException e){} controllerSourceMap.get(event.getComponent()).notifyPropertyChange(event.getValue()); }//end while(true) }//end run() }//end GamepadEventThread