public boolean apply(final TwoInputStates states) { final InputState currentState = states.getCurrent(); final InputState previousState = states.getPrevious(); if (currentState == null || previousState == null || !currentState.getMouseState().hasButtonState(ButtonState.DOWN)) { return false; } return currentState.getMouseState().getButtonsPressedSince(previousState.getMouseState()).contains(_button); } }
new InputState(KeyboardState.NOTHING, prev.getMouseState(), prev.getControllerState(), prev.getGestureState()), new InputState(KeyboardState.NOTHING, curr.getMouseState(), curr.getControllerState(), prev.getGestureState())); forwardTo.getApplier().checkAndPerformTriggers(forwardTo.getTriggers(), source, forwardingState, tpf); new InputState(prev.getKeyboardState(), MouseState.NOTHING, prev.getControllerState(), prev.getGestureState()), new InputState(curr.getKeyboardState(), MouseState.NOTHING, curr.getControllerState(), prev.getGestureState())); forwardTo.getApplier().checkAndPerformTriggers(forwardTo.getTriggers(), source, forwardingState, tpf);
@Override public boolean mousePressed(final MouseButton button, final InputState state) { if (button != MouseButton.LEFT) { return super.mousePressed(button, state); } final boolean copyToggled = state.getKeyboardState().isAtLeastOneDown(Key.LEFT_SHIFT, Key.RIGHT_SHIFT); updateSelection(state.getMouseState(), copyToggled); return true; }
protected boolean isCtrtlDown(final InputState state) { if (System.getProperty("mrj.version") != null) { // mac return state.getKeyboardState().isAtLeastOneDown(Key.LEFT_META, Key.RIGHT_META); } else { // non-mac return state.getKeyboardState().isAtLeastOneDown(Key.LEFT_CONTROL, Key.RIGHT_CONTROL); } }
@Test public void testTriggers1() throws Exception { final InputState state1 = new InputState(ks, ms, cs, gs); final InputState state2 = new InputState(ks, ms, cs, gs); final double tpf = 14; final LinkedList<InputState> states1 = new LinkedList<InputState>(); final LinkedList<InputState> states2 = new LinkedList<InputState>(); states1.add(state1); states2.add(state2); pl.readState(); pl.readState(); expect(pl.drainAvailableStates()).andReturn(states1); expect(pl.drainAvailableStates()).andReturn(states2); expect(p1.apply(isA(TwoInputStates.class))).andReturn(false); expect(p1.apply(isA(TwoInputStates.class))).andReturn(true); ta1.perform(canvas, new TwoInputStates(state1, state2), tpf); replay(mocks); ll.registerTrigger(new InputTrigger(p1, ta1)); ll.checkTriggers(tpf); ll.checkTriggers(tpf); }
public boolean apply(final TwoInputStates states) { final ControllerState oldState = states.getPrevious().getControllerState(); final ControllerState currentState = states.getCurrent().getControllerState(); final boolean apply = !oldState.equals(currentState); return apply; }
@Override public boolean apply(final TwoInputStates states) { final InputState current = states.getCurrent(); if (current == null) { return false; } final List<AbstractGestureEvent> events = current.getGestureState().getEvents(); for (int i = 0, maxI = events.size(); i < maxI; i++) { if (_clazz.isInstance(events.get(i))) { return true; } } return false; } }
protected boolean isShiftDown(final InputState state) { return state.getKeyboardState().isAtLeastOneDown(Key.LEFT_SHIFT, Key.RIGHT_SHIFT); }
@Test public void testLostFocus3() throws Exception { keyboardWrapper.init(); mouseWrapper.init(); controllerWrapper.init(); gestureWrapper.init(); focusWrapper.init(); expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(noKeys.iterator())).times(3); expect(mouseWrapper.getEvents()).andReturn(Iterators.peekingIterator(buttonDown.iterator())); expect(mouseWrapper.getEvents()).andReturn(Iterators.peekingIterator(noMice.iterator())).times(2); expect(controllerWrapper.getEvents()).andReturn(Iterators.peekingIterator(nothing.iterator())).times(3); expect(gestureWrapper.getEvents()).andReturn(Iterators.peekingIterator(noGestures.iterator())).times(3); expect(focusWrapper.getAndClearFocusLost()).andReturn(false); expect(focusWrapper.getAndClearFocusLost()).andReturn(true); replay(mocks); pl.readState(); pl.readState(); inputStates = pl.drainAvailableStates(); assertEquals("2 states", 2, inputStates.size()); is = inputStates.get(0); assertFalse("a down", is.getKeyboardState().isDown(Key.A)); assertFalse("b down", is.getKeyboardState().isDown(Key.B)); assertEquals("mb down", ButtonState.DOWN, is.getMouseState().getButtonState(MouseButton.LEFT)); is = inputStates.get(1); assertEquals("lost focus", InputState.LOST_FOCUS, is); assertFalse("a down", is.getKeyboardState().isDown(Key.A)); assertFalse("b down", is.getKeyboardState().isDown(Key.B)); assertEquals("mb up", ButtonState.UP, is.getMouseState().getButtonState(MouseButton.LEFT)); }
@Test public void testLostFocus() throws Exception { final InputState state1 = new InputState(ks, ms, cs, gs); final InputState state2 = new InputState(ks, ms, cs, gs);
public boolean apply(final TwoInputStates states) { final ControllerState oldState = states.getPrevious().getControllerState(); final ControllerState currentState = states.getCurrent().getControllerState(); final boolean apply = !oldState.equals(currentState); return apply; }
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final PinchGestureEvent event = inputStates.getCurrent().getGestureState() .first(PinchGestureEvent.class); if (event.isStartOfGesture()) { initialZoom = _sphereCoords.getX(); } if (event.getScale() != 0.0) { _sphereCoords.setX(MathUtils.clamp((1.0 / event.getScale()) * initialZoom, _minZoomDistance, _maxZoomDistance)); makeDirty(); } if (_updateCameraFromInput) { _camera = source.getCanvasRenderer().getCamera(); } } }));
public boolean apply(final TwoInputStates states) { final InputState currentState = states.getCurrent(); final InputState previousState = states.getPrevious(); if (currentState == null || previousState == null || !previousState.getMouseState().hasButtonState(ButtonState.DOWN)) { return false; } return currentState.getMouseState().getButtonsReleasedSince(previousState.getMouseState()).contains(_button); } }
new InputState(KeyboardState.NOTHING, states.getCurrent().getMouseState(), states .getCurrent().getControllerState())); forwardTo.getApplier().checkAndPerformTriggers(forwardTo.getTriggers(), source, forwardingState, tpf); new InputState(states.getCurrent().getKeyboardState(), MouseState.NOTHING, states .getCurrent().getControllerState())); forwardTo.getApplier().checkAndPerformTriggers(forwardTo.getTriggers(), source, forwardingState, tpf);
public boolean apply(final TwoInputStates states) { final InputState currentState = states.getCurrent(); final InputState previousState = states.getPrevious(); return currentState.getKeyboardState().getKeysReleasedSince(previousState.getKeyboardState()).contains(key); } }
@Override public boolean mousePressed(final MouseButton button, final InputState state) { final int x = state.getMouseState().getX() - UITextField.this.getHudX() - UITextField.this.getPadding().getLeft(); final int y = state.getMouseState().getY() - UITextField.this.getHudY() - UITextField.this.getPadding().getBottom(); if (isCopyable() && state.getKeyboardState().isAtLeastOneDown(Key.LSHIFT, Key.RSHIFT)) { _selection.checkStart(); if (_selection.getState() == SelectionState.AT_START_OF_SELECTION) {
_stateQueue.add(new InputState(_currentKeyboardState, _currentMouseState, _currentControllerState, _currentGestureState));
public boolean apply(final TwoInputStates states) { final Map<String, Float> currentStates = states.getCurrent().getControllerState() .getControllerComponentValues(controllerName); final Map<String, Float> previousStates = states.getPrevious().getControllerState() .getControllerComponentValues(controllerName);
public boolean apply(final TwoInputStates states) { final InputState currentState = states.getCurrent(); final InputState previousState = states.getPrevious(); if (currentState == null || previousState == null || !currentState.getMouseState().hasButtonState(ButtonState.DOWN)) { return false; } return currentState.getMouseState().getButtonsPressedSince(previousState.getMouseState()).contains(_button); } }
public boolean apply(final TwoInputStates states) { final InputState currentState = states.getCurrent(); final InputState previousState = states.getPrevious(); return currentState.getKeyboardState().getKeysPressedSince(previousState.getKeyboardState()).contains(key); } }