示例#1
0
        public KeyActiveEventGenerator GetKeyGenerator(KeyActiveEventListener keyActiveEventListener)
        {
            var keys = keyActiveEventListener.keys;

            keys.Sort();  // arbitrary built-in sort function; this might not be doing what we expect it does

            if (keyActiveEventGenerators.ContainsKey(keys))
            {
                return(keyActiveEventGenerators[keys]);
            }
            else
            {
                Debug.Log("Making a new listener for key " + keyActiveEventListener.keys[0].keyCode);
                KeyActiveEventGenerator keyActiveEventGenerator;
                if (keys.Count == 1)  // only 1 key
                {
                    var key = keys[0];
                    if (key.isDoubleKey)
                    {
                        keyActiveEventGenerator = new DoubleKeyPressEventGenerator(key);
                    }
                    else
                    {
                        keyActiveEventGenerator = new KeyActiveEventGenerator(key);
                    }
                }
                else // more than 1 key; can't do double press for multikey inputs
                {
                    keyActiveEventGenerator = new KeyActiveEventGenerator(keys.ToArray());
                }

                keyActiveEventGenerators.Add(keys, keyActiveEventGenerator);

                return(keyActiveEventGenerator);
            }
        }
示例#2
0
        public void AddKeyPressListener(KeyActiveEventListener keyActiveEventListener)
        {
            KeyActiveEventGenerator keyActiveEventGenerator = GetKeyGenerator(keyActiveEventListener);

            keyActiveEventGenerator.AddListener(keyActiveEventListener);
        }