예제 #1
0
 private void pollController() {
   if (inputController != null && inputController.poll()) {
     EventQueue eventQueue = inputController.getEventQueue();
     Event event = new Event();
     while (eventQueue.getNextEvent(event)) {
       Component component = event.getComponent();
       float value = event.getValue();
       processControllerEvent(component, value);
     }
   }
 }
예제 #2
0
 public void run() {
   try {
     setChanged();
     Event event = new Event();
     net.java.games.input.EventQueue queue = controller.getEventQueue();
     while (Main.isRunning()) {
       for (int count = 0; count < 5; count++) {
         Thread.sleep(10);
         controller.poll();
         for (ComponentWrapper aComponentsToSave : ComponentWrapper.componentWrappers) {
           if (currentState == State.Recording) {
             if (aComponentsToSave.setDataAverage()) {
               setChanged();
             }
           } else {
             if (aComponentsToSave.setData()) {
               setChanged();
             }
           }
         }
         while (queue.getNextEvent(event)) {
           Component component = event.getComponent();
           ComponentWrapper c = ComponentWrapper.getComponentWrapper(component);
           if (c != null && c.isButton()) {
             c.isPressed();
           }
         }
         notifyObservers(currentState == State.Recording);
       }
       setChanged();
       notifyObservers();
     }
   } catch (InterruptedException e) {
     Main.stopRunning();
     e.printStackTrace();
   }
 }