List of usage examples for com.badlogic.gdx InputMultiplexer size
public int size()
From source file:rx.libgdx.sources.GdxInputEventSource.java
License:Apache License
/** * @see rx.GdxObservable#fromInput// w w w.j av a 2s . c om */ public static Observable<InputEvent> fromInput() { return create(new Observable.OnSubscribe<InputEvent>() { @Override public void call(final Subscriber<? super InputEvent> subscriber) { final InputProcessor processor = new InputProcessor() { @Override public boolean touchUp(int screenX, int screenY, int pointer, int button) { if (!subscriber.isUnsubscribed()) { subscriber.onNext(new TouchUpEvent(screenX, screenY, pointer, button)); return true; } return false; } @Override public boolean touchDown(int screenX, int screenY, int pointer, int button) { if (!subscriber.isUnsubscribed()) { subscriber.onNext(new TouchDownEvent(screenX, screenY, pointer, button)); return true; } return false; } @Override public boolean touchDragged(int screenX, int screenY, int pointer) { if (!subscriber.isUnsubscribed()) { subscriber.onNext(new TouchDraggedEvent(screenX, screenY, pointer)); return true; } return false; } @Override public boolean keyDown(int keycode) { if (!subscriber.isUnsubscribed()) { subscriber.onNext(new KeyDownEvent(keycode)); return true; } return false; } @Override public boolean keyUp(int keycode) { if (!subscriber.isUnsubscribed()) { subscriber.onNext(new KeyUpEvent(keycode)); return true; } return false; } @Override public boolean keyTyped(char character) { if (!subscriber.isUnsubscribed()) { subscriber.onNext(new KeyTypedEvent(character)); return true; } return false; } @Override public boolean mouseMoved(int screenX, int screenY) { if (!subscriber.isUnsubscribed()) { subscriber.onNext(new MouseMovedEvent(screenX, screenY)); return true; } return false; } @Override public boolean scrolled(int amount) { if (!subscriber.isUnsubscribed()) { subscriber.onNext(new ScrolledEvent(amount)); return true; } return false; } }; final InputProcessor wrapped = Gdx.input.getInputProcessor(); final InputMultiplexer im; if (wrapped instanceof InputMultiplexer) { im = (InputMultiplexer) wrapped; } else if (wrapped != null) { im = new InputMultiplexer(wrapped); } else { im = new InputMultiplexer(); } im.addProcessor(processor); subscriber.add(Subscriptions.create(new Action0() { @Override public void call() { im.removeProcessor(processor); if (wrapped != null && wrapped != im && im.size() == 1) { Gdx.input.setInputProcessor(wrapped); } } })); Gdx.input.setInputProcessor(im); } }); }