public boolean apply(final TwoInputStates twoInputStates) { final InputState currentState = twoInputStates.getCurrent(); final InputState previousState = twoInputStates.getPrevious(); return !currentState.getKeyboardState().getKeysPressedSince(previousState.getKeyboardState()).isEmpty(); } }
public boolean apply(final TwoInputStates states) { final InputState currentState = states.getCurrent(); final InputState previousState = states.getPrevious(); return currentState.getKeyboardState().getKeysPressedSince(previousState.getKeyboardState()).contains(key); } }
public boolean apply(final TwoInputStates twoInputStates) { final InputState currentState = twoInputStates.getCurrent(); final InputState previousState = twoInputStates.getPrevious(); return !currentState.getKeyboardState().getKeysPressedSince(previousState.getKeyboardState()).isEmpty(); } }
public boolean apply(final TwoInputStates states) { final InputState currentState = states.getCurrent(); final InputState previousState = states.getPrevious(); return currentState.getKeyboardState().getKeysPressedSince(previousState.getKeyboardState()).contains(key); } }
@Test public void testKeysPressed3() throws Exception { ks1 = new KeyboardState(EnumSet.of(Key.A, Key.C, Key.D), KeyEvent.NOTHING); ks2 = new KeyboardState(EnumSet.of(Key.A), KeyEvent.NOTHING); final EnumSet<Key> pressed = ks2.getKeysPressedSince(ks1); assertEquals("0 key", 0, pressed.size()); }
@Test public void testKeysPressed1() throws Exception { ks1 = new KeyboardState(EnumSet.of(Key.A, Key.B), KeyEvent.NOTHING); ks2 = new KeyboardState(EnumSet.of(Key.A, Key.C, Key.D), KeyEvent.NOTHING); final EnumSet<Key> pressed = ks2.getKeysPressedSince(ks1); assertEquals("2 key", 2, pressed.size()); assertTrue("c pressed", pressed.contains(Key.C)); assertTrue("d pressed", pressed.contains(Key.D)); }
@Test public void testKeysPressed2() throws Exception { ks1 = new KeyboardState(EnumSet.noneOf(Key.class), KeyEvent.NOTHING); ks2 = new KeyboardState(EnumSet.of(Key.A, Key.C, Key.D), KeyEvent.NOTHING); final EnumSet<Key> pressed = ks2.getKeysPressedSince(ks1); assertEquals("2 key", 3, pressed.size()); assertTrue("a pressed", pressed.contains(Key.A)); assertTrue("c pressed", pressed.contains(Key.C)); assertTrue("d pressed", pressed.contains(Key.D)); }
if (!currentKState.getKeysDown().isEmpty()) { final EnumSet<Key> pressed = currentKState.getKeysPressedSince(previousKState); if (!pressed.isEmpty()) { for (final Key key : pressed) {
if (!currentKState.getKeysDown().isEmpty()) { final EnumSet<Key> pressed = currentKState.getKeysPressedSince(previousKState); if (!pressed.isEmpty()) { for (final Key key : pressed) {