private static void rebuild() { clearInternal(); Set<Integer> keys = new HashSet<>(); Collection<OverrideGroup> groups = overrideGroups.values(); Iterator<OverrideGroup> iter = groups.iterator(); while (iter.hasNext()) { OverrideGroup group = iter.next(); if (group.ended) { iter.remove(); } else { for (int i : group.keys) { keys.add(i); } } } for (int keyid : keys) { KeyBinding kb = (KeyBinding) kbMap.removeObject(keyid); if (kb != null) { try { pressedField.set(kb, false); } catch (Exception e) { e.printStackTrace(); } // kb.setKeyCode(-1); activeOverrides.put(keyid, new Override(kb)); log("Override new [" + keyid + "]"); } else { log("Override ignored [" + keyid + "]"); } } }
private static void restoreLocks() { for (Map.Entry<Integer, Override> ao : activeOverrides.entrySet()) { try { pressedField.set(ao.getValue().kb, false); } catch (Exception e) { Throwables.propagate(e); } kbMap.removeObject(ao.getKey()); } }