Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
		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;
		}
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
 public static KeyMapping GetEmptyMapping(Key from)
 {
     return new KeyMapping(from, new Key(-1, -1));
 }
Ejemplo n.º 5
0
 public KeyMapping()
 {
     this.@from = new Key();
     this.to = new Key(); 
 }