| 1187 | |
| 1188 | static public Set<Character> charsPressed(KeyboardState before, KeyboardState after) { |
| 1189 | Set<Character> b = new LinkedHashSet<>(after.charsDown.values()); |
| 1190 | b.removeAll(before.charsDown.values()); |
| 1191 | return b; |
| 1192 | } |
| 1193 | |
| 1194 | static public Set<Character> charsReleased(KeyboardState before, KeyboardState after) { |
| 1195 | Set<Character> b = new LinkedHashSet<>(before.charsDown.values()); |
| 1196 | b.removeAll(after.charsDown.values()); |
| 1197 | return b; |
| 1198 | } |
| 1199 | |
| 1200 | public KeyboardState next(int key, char character, boolean state, long time) { |
| 1201 | Set<Integer> keysDown = new LinkedHashSet<>(this.keysDown); |
| 1202 | Map<Integer, Character> charsDown = new LinkedHashMap<>(this.charsDown); |
| 1203 | if (state) { |
| 1204 | keysDown.add(key); |
| 1205 | charsDown.put(key, character); |
| 1206 | } else { |
| 1207 | keysDown.remove(key); |
| 1208 | charsDown.remove(key); |
| 1209 | } |
| 1210 | |
| 1211 | return new KeyboardState(keysDown, charsDown, time); |
| 1212 | } |
| 1213 | |
| 1214 | public KeyboardState withKey(int key, boolean down) { |
| 1215 | Set<Integer> keysDown = new LinkedHashSet<>(this.keysDown); |
| 1216 | Map<Integer, Character> charsDown = new LinkedHashMap<>(this.charsDown); |
| 1217 | if (down) { |
| 1218 | keysDown.add(key); |
| 1219 | } else { |
| 1220 | keysDown.remove(key); |
| 1221 | } |
| 1222 | |
| 1223 | return new KeyboardState(keysDown, charsDown, time); |
| 1224 | } |
| 1225 | |
| 1226 | public KeyboardState withChar(char c, boolean down) { |
| 1227 | Set<Integer> keysDown = new LinkedHashSet<>(this.keysDown); |
| 1228 | Map<Integer, Character> charsDown = new LinkedHashMap<>(this.charsDown); |
| 1229 | if (down) { |
| 1230 | charsDown.put((int) c, c); |
| 1231 | } else { |
| 1232 | charsDown.remove((int) c); |
| 1233 | } |
| 1234 | |
| 1235 | return new KeyboardState(keysDown, charsDown, time); |
| 1236 | } |
| 1237 | |
| 1238 | public boolean isShiftDown() { |
| 1239 | return keysDown.contains(GLFW_KEY_LEFT_SHIFT) || keysDown.contains(GLFW_KEY_RIGHT_SHIFT); |
| 1240 | } |
| 1241 | |
| 1242 | public boolean isAltDown() { |
| 1243 | return keysDown.contains(GLFW_KEY_LEFT_ALT) || keysDown.contains(GLFW_KEY_RIGHT_ALT); |
| 1244 | } |
| 1245 | |
| 1246 | public boolean isSuperDown() { |
nothing calls this directly
no outgoing calls
no test coverage detected