|
@@ -86,6 +86,7 @@ public class InputManager implements RawInputListener {
|
|
|
private final IntMap<Long> pressedButtons = new IntMap<Long>();
|
|
private final IntMap<Long> pressedButtons = new IntMap<Long>();
|
|
|
private final IntMap<Float> axisValues = new IntMap<Float>();
|
|
private final IntMap<Float> axisValues = new IntMap<Float>();
|
|
|
private ArrayList<RawInputListener> rawListeners = new ArrayList<RawInputListener>();
|
|
private ArrayList<RawInputListener> rawListeners = new ArrayList<RawInputListener>();
|
|
|
|
|
+ private RawInputListener[] rawListenerArray = null;
|
|
|
private ArrayList<InputEvent> inputQueue = new ArrayList<InputEvent>();
|
|
private ArrayList<InputEvent> inputQueue = new ArrayList<InputEvent>();
|
|
|
|
|
|
|
|
private static class Mapping {
|
|
private static class Mapping {
|
|
@@ -509,22 +510,30 @@ public class InputManager implements RawInputListener {
|
|
|
|
|
|
|
|
public void addRawInputListener(RawInputListener listener) {
|
|
public void addRawInputListener(RawInputListener listener) {
|
|
|
rawListeners.add(listener);
|
|
rawListeners.add(listener);
|
|
|
|
|
+ rawListenerArray = null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void removeRawInputListener(RawInputListener listener) {
|
|
public void removeRawInputListener(RawInputListener listener) {
|
|
|
rawListeners.remove(listener);
|
|
rawListeners.remove(listener);
|
|
|
|
|
+ rawListenerArray = null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void clearRawInputListeners() {
|
|
public void clearRawInputListeners() {
|
|
|
rawListeners.clear();
|
|
rawListeners.clear();
|
|
|
|
|
+ rawListenerArray = null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private RawInputListener[] getRawListenerArray() {
|
|
|
|
|
+ if (rawListenerArray == null)
|
|
|
|
|
+ rawListenerArray = rawListeners.toArray(new RawInputListener[rawListeners.size()]);
|
|
|
|
|
+ return rawListenerArray;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void processQueue() {
|
|
private void processQueue() {
|
|
|
int queueSize = inputQueue.size();
|
|
int queueSize = inputQueue.size();
|
|
|
- int numRawListeners = rawListeners.size();
|
|
|
|
|
-
|
|
|
|
|
- for (int i = 0; i < numRawListeners; i++) {
|
|
|
|
|
- RawInputListener listener = rawListeners.get(i);
|
|
|
|
|
|
|
+ RawInputListener[] array = getRawListenerArray();
|
|
|
|
|
+
|
|
|
|
|
+ for (RawInputListener listener : array) {
|
|
|
listener.beginInput();
|
|
listener.beginInput();
|
|
|
|
|
|
|
|
for (int j = 0; j < queueSize; j++) {
|
|
for (int j = 0; j < queueSize; j++) {
|