private void resetToDefaults() { ((PDInputProcessor)Game.instance.getInputProcessor()).resetKeyMappings(); }
public void create() { Game.instance.getInputProcessor().addKeyListener(keyListener = new Signal.Listener<NoosaInputProcessor.Key>() { @Override public void onSignal(NoosaInputProcessor.Key key) { if (Game.instance != null && key.pressed) { switch (key.code) { case Input.Keys.BACK: case Input.Keys.ESCAPE: onBackPressed(); break; case Input.Keys.MENU: case Input.Keys.F5: onMenuPressed(); break; } } } }); }
@Override public void destroy() { Game.instance.getInputProcessor().removeKeyListener(keyListener); super.destroy(); }
@Override public void destroy() { super.destroy(); Game.instance.getInputProcessor().removeAllTouchEvent(); }
@Override public void destroy() { super.destroy(); Camera.remove( camera ); Game.instance.getInputProcessor().removeKeyListener(this); }
private void setupListeners() { NoosaInputProcessor<T> ip = Game.instance.<T>getInputProcessor(); ip.addTouchListener(this); ip.addKeyListener(keyListener); ip.addMouseListener(mouseListener); }
private void populateList() { listContent.clear(); tempPos = 0; final PDInputProcessor inputProcessor = (PDInputProcessor) Game.instance.getInputProcessor(); final Map<Integer, PDInputProcessor.GameActionWrapper> keyMappings = inputProcessor.getKeyMappings(); final Map<GameAction, KeyPair> mappings = new TreeMap<>(); for (GameAction action : GameAction.values()) { if (action.getDescription() != null) { mappings.put( action, new KeyPair() ); } } for (Map.Entry<Integer, PDInputProcessor.GameActionWrapper> entry : keyMappings.entrySet()) { final Integer key = entry.getKey(); final PDInputProcessor.GameActionWrapper value = entry.getValue(); final GameAction action = value.gameAction; final KeyPair keyPair = mappings.get(action); /* if (keyPair == null) { mappings.put(action, keyPair = new KeyPair()); }*/ if (value.defaultKey) { keyPair.key1 = key; } else { keyPair.key2 = key; } } for (Map.Entry<GameAction, KeyPair> entry : mappings.entrySet()) { addKey(listContent, width, entry); } listContent.setSize( 0, tempPos); }
@Override public void destroy() { NoosaInputProcessor<T> ip = Game.instance.<T>getInputProcessor(); ip.removeMouseListener(mouseListener); ip.removeKeyListener(keyListener); ip.removeTouchListener(this); super.destroy(); } }
@Override public void onSignal( NoosaInputProcessor.Key<GameAction> key ) { if (key.pressed) { switch (key.code) { case Input.Keys.BACK: case Input.Keys.ESCAPE: onBackPressed(); break; case Input.Keys.MENU: onMenuPressed(); break; default: onKeyDown(key); break; } } else { onKeyUp( key ); } Game.instance.getInputProcessor().cancelKeyEvent(); }
if (hit && blockWhenInactive) Game.instance.getInputProcessor().cancelTouchEvent(); return; Game.instance.getInputProcessor().cancelTouchEvent();
@Override protected void onKeyDown( NoosaInputProcessor.Key key ) { final PDInputProcessor inputProcessor = (PDInputProcessor) Game.instance.getInputProcessor(); final Map<Integer, PDInputProcessor.GameActionWrapper> keyMappings = inputProcessor.getKeyMappings(); int oldKeycode = getKey(defaultKey); inputProcessor.removeKeyMapping( gameAction, defaultKey, oldKeycode); // Don't allow the modifier key to be replaced. TODO: This should probably be improved if (key.code == PDInputProcessor.MODIFIER_KEY) { setKey(defaultKey, 0); } else { setKey(defaultKey, key.code); final PDInputProcessor.GameActionWrapper replacedAction = inputProcessor.setKeyMapping( gameAction, defaultKey, key.code); if (replacedAction != null) { final ListItem replacedItem = items.get(replacedAction.gameAction); replacedItem.setKey(replacedAction.defaultKey, 0); } } hide(); } } );
chrome.width(), chrome.height ); Game.instance.getInputProcessor().addKeyListener(this);