@Override public int[] removeControllerEventListener(ControllerEventListener listener, int[] controllers) { synchronized(controllerEventListeners) { ControllerListElement cve = null; boolean flag = false; for (int i=0; i < controllerEventListeners.size(); i++) { cve = controllerEventListeners.get(i); if (cve.listener.equals(listener)) { cve.removeControllers(controllers); flag = true; break; } } if (!flag) { return new int[0]; } if (controllers == null) { int index = controllerEventListeners.indexOf(cve); if (index >= 0) { controllerEventListeners.remove(index); } return new int[0]; } return cve.getControllers(); } }
@Override public int[] addControllerEventListener(ControllerEventListener listener, int[] controllers) { synchronized(controllerEventListeners) { // first find the listener. if we have one, add the controllers // if not, create a new element for it. ControllerListElement cve = null; boolean flag = false; for(int i=0; i < controllerEventListeners.size(); i++) { cve = controllerEventListeners.get(i); if (cve.listener.equals(listener)) { cve.addControllers(controllers); flag = true; break; } } if (!flag) { cve = new ControllerListElement(listener, controllers); controllerEventListeners.add(cve); } // and return all the controllers this listener is interested in return cve.getControllers(); } }
private ControllerListElement(ControllerEventListener listener, int[] controllers) { this.listener = listener; if (controllers == null) { controllers = new int[128]; for (int i = 0; i < 128; i++) { controllers[i] = i; } } this.controllers = controllers; }
public int[] addControllerEventListener(ControllerEventListener listener, int[] controllers) { // TODO Auto-generated method stub return null; }
public int[] removeControllerEventListener(ControllerEventListener listener, int[] controllers) { // TODO Auto-generated method stub return null; }