activeCursors.clear();
// if there are cursors in the map
if (!sessionIds.isEmpty()) {
// for all cursors
for(long sessionId : sessionIds) {
TuioCursor cursor = cursors.get(sessionId);
if (cursor == null) continue;
// get the cursor id (0,1..)
int CursorID = cursor.getCursorID();
// add it to the active cursors
activeCursors.add(CursorID);
// if the cursor id is not in the availableCursors set then add it and...
if (availableCursors.add(CursorID)) {
// for all listeners call onNew
for (int i = 0; i < listeners.size(); i++) {
TuioInputListener listener = listeners.get(i);
listener.onNew(CursorID, cursor.getScreenX(screenWidth), screenHeight-cursor.getScreenY(screenHeight));
}
} else {
// the cursor id is in the availableCursors set
// get or create the cursor store
TuioCursorStore cstore = null;
if (store.containsKey(CursorID)) {
cstore = store.get(CursorID);
} else {
cstore = new TuioCursorStore();
}
// if the cursor has moved (note hasMoved had to be called to recalculate the position)
if (cstore.hasMoved(cursor.getScreenX(screenWidth), cursor.getScreenY(screenHeight))) {
for (int i = 0; i < listeners.size(); i++) {
// for all listeners call onMove
TuioInputListener listener = listeners.get(i);
listener.onMove(CursorID, cstore.getDeltaX(), cstore.getDeltaY(), cstore.getX(), screenHeight-cstore.getY());
}