public KeyMapping(Key keyFrom, Key keyTo) { if (ReferenceEquals(keyFrom, null) || ReferenceEquals(keyTo, null)) { throw new NullReferenceException("Key can't be null"); } From = keyFrom; To = keyTo; }
public KeyMapping(Key keyFrom, Key keyTo) { if (ReferenceEquals(keyFrom, null) || ReferenceEquals(keyTo, null)) { throw new NullReferenceException("Key can't be null"); } this.@from = keyFrom; this.to = keyTo; this.type = MappingType.Null; }
private static Collection<KeyMapping> GetMappingsFromScancodeMap(byte[] map) { // Transform the byte array into keymappings var maps = new Collection<KeyMapping>(); int count = 0; int length = map.GetLength(0); // How many mappings are there? // (Make sure there are at least 8 bytes in the array) if (length > 8) count = map[8] - 1; if (count == 0) { return maps; } const int start = 12; for (int i = 0; i < count; i++) { // Make sure we don't extend beyond array bounds if (length >= (start + (i * 4) + 3)) { // First pair is the action - what the mapped key does. int word1 = map[start + (i * 4)]; int word2 = map[start + (i * 4) + 1]; var tokey = new Key(word1, word2); // Second pair is the physical key which performs the new action word1 = map[start + (i * 4) + 2]; word2 = map[start + (i * 4) + 3]; var fromkey = new Key(word1, word2); var mapping = new KeyMapping(fromkey, tokey); if (mapping.IsValid()) { maps.Add(mapping); } else // Just ignore it and hope it goes away. // A manually added - or garbled - entry could be invalid. { } } } return maps; }
public static KeyMapping GetEmptyMapping(Key from) { return new KeyMapping(from, new Key(-1, -1)); }
public KeyMapping() { this.@from = new Key(); this.to = new Key(); }