Example #1
0
        public void Map(KeyTrigger trigger, KeyboardInputCallback callback, InputState inputCondition = (InputState.Down | InputState.Pressed | InputState.Released | InputState.Up))
        {
            if (!Bindings.ContainsKey(trigger.Name))
            {
                KeyboardBinding binding = new KeyboardBinding(trigger.Name);
                Bindings.Add(trigger.Name, binding);
                Bindings[trigger.Name].AddAction(callback);
                Bindings[trigger.Name].Condition = inputCondition;
            }

            if (keyBinds.ContainsKey(trigger.Name))
            {
                return;
            }
            Keys[] keys = new Keys[1 + trigger.AlternateKeys.Length];
            keys[0] = trigger.Key;
            for (int i = 0, j = 1; i < trigger.AlternateKeys.Length; i++, j++)
            {
                keys[j] = trigger.AlternateKeys[i];
            }
            keyBinds.Add(trigger.Name, keys);
        }
Example #2
0
        public void Map(KeyTrigger trigger, KeyboardInputCallback callback, InputState inputCondition = (InputState.Down | InputState.Pressed | InputState.Released | InputState.Up))
        {
            if (!Bindings.ContainsKey(trigger.Name))
            {
                KeyboardBinding binding = new KeyboardBinding(trigger.Name);
                Bindings.Add(trigger.Name, binding);
                Bindings[trigger.Name].AddAction(callback);
                Bindings[trigger.Name].Condition = inputCondition;
            }

            if (keyBinds.ContainsKey(trigger.Name))
            {
                return;
            }
            Keys[] keys = new Keys[1 + trigger.AlternateKeys.Length];
            keys[0] = trigger.Key;
            for (int i = 0, j = 1; i < trigger.AlternateKeys.Length; i++, j++)
            {
                keys[j] = trigger.AlternateKeys[i];
            }
            keyBinds.Add(trigger.Name, keys);
        }