Fix consuming the remaining input events when mapping the gamepad. See GitHub issue 4 for details.

This commit is contained in:
Cameron Gutman
2013-12-29 19:21:33 -06:00
parent f043a505ea
commit 07e39a6525
+14 -16
View File
@@ -306,24 +306,22 @@ public class GamepadConfigFrame extends JFrame {
* Consumes any events left in the queue after the mapping has been made
*/
private void consumeEvents(final Gamepad pad) {
// start a new thread to go through all of the remaining events
Thread consumeEvents = new Thread(new Runnable() {
@Override
public void run() {
if (pad.poll()) {
EventQueue queue = pad.getEvents();
Event event = new Event();
EventQueue queue = pad.getEvents();
Event event = new Event();
while (queue.getNextEvent(event)) {
if (!pad.poll()) {
break;
}
}
}
for (int i = 0; i < 5; i++) {
if (!pad.poll()) {
break;
}
});
consumeEvents.setName("Consume Events Thread");
consumeEvents.start();
// Drop all events currently in the queue
while (queue.getNextEvent(event) && pad.poll());
// Give the queue a bit of time to fill again
try {
Thread.sleep(50);
} catch (InterruptedException e) {}
}
}
/*