@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)); }
public EnumSet<Key> getKeysPressedSince(final KeyboardState previous) { final EnumSet<Key> result = EnumSet.copyOf(_keysDown); result.removeAll(previous._keysDown); return result; }
KeyboardState { public EnumSet<Key> getKeysPressedSince(final KeyboardState previous) { final EnumSet<Key> result = EnumSet.copyOf(_keysDown); result.removeAll(previous._keysDown); return result; } }
KeyboardState { public EnumSet<Key> getKeysPressedSince(final KeyboardState previous) { final EnumSet<Key> result = EnumSet.copyOf(_keysDown); result.removeAll(previous._keysDown); return result; } KeyboardState(final EnumSet<Key> keysDown, final KeyEvent keyEvent); }
KeyboardState { public EnumSet<Key> getKeysPressedSince(final KeyboardState previous) { final EnumSet<Key> result = EnumSet.copyOf(_keysDown); result.removeAll(previous._keysDown); return result; } KeyboardState(final EnumSet<Key> keysDown, final KeyEvent keyEvent); boolean isDown(final Key key); boolean isAllDown(final Key... keys); boolean isAtLeastOneDown(final Key... keys); Set<Key> getKeysDown(); KeyEvent getKeyEvent(); EnumSet<Key> getKeysReleasedSince(final KeyboardState previous); EnumSet<Key> getKeysPressedSince(final KeyboardState previous); EnumSet<Key> getKeysHeldSince(final KeyboardState previous); @Override String toString(); }
KeyboardState { public EnumSet<Key> getKeysPressedSince(final KeyboardState previous) { final EnumSet<Key> result = EnumSet.copyOf(_keysDown); result.removeAll(previous._keysDown); return result; } KeyboardState(final EnumSet<Key> keysDown, final KeyEvent keyEvent); boolean isDown(final Key key); boolean isAllDown(final Key... keys); boolean isAtLeastOneDown(final Key... keys); Set<Key> getKeysDown(); KeyEvent getKeyEvent(); EnumSet<Key> getKeysReleasedSince(final KeyboardState previous); EnumSet<Key> getKeysPressedSince(final KeyboardState previous); EnumSet<Key> getKeysHeldSince(final KeyboardState previous); @Override String toString(); static final KeyboardState NOTHING; }