public static bool ReadKey(out KeyBindingData bindingKey)
        {
            KeyCode keyCode = KeyCode.None;

            foreach (KeyCode keyHeld in Enum.GetValues(typeof(KeyCode)))
            {
                if (keyHeld == KeyCode.None || keyHeld > KeyCode.PageDown)
                {
                    continue;
                }

                if (Input.GetKey(keyHeld))
                {
                    keyCode = keyHeld;
                    break;
                }
            }

            //if (keyCode != KeyCode.None)
            //{
            bindingKey = new KeyBindingData()
            {
                Key         = keyCode,
                IsCtrlDown  = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl),
                IsAltDown   = Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt),
                IsShiftDown = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)
            };
            return(true);
            //}
            //else
            //{
            //    bindingKey = null;
            //    return false;
            //}
        }
Exemple #2
0
    /// <summary>
    /// Load Settings
    /// </summary>
    public void LoadKeyBindings()
    {
        if (File.Exists(keyBindingPath))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(keyBindingPath, FileMode.Open);
            KeyBindingData  kbd  = (KeyBindingData)bf.Deserialize(file);
            file.Close();

            horizontalInverted   = kbd.horizontalInverted;
            verticalInverted     = kbd.verticalInverted;
            fpHorizontalInverted = kbd.fpHorizontalInverted;
            fpVerticalInverted   = kbd.fpVerticalInverted;
            bindedKeys           = kbd.bindedKeys;

            keyMap = new Dictionary <string, int>();
            for (int i = 0; i < bindedKeys.Length; i++)
            {
                keyMap.Add(bindedKeys[i].action, i);
            }
        }
        else
        {
            LoadKeyBindingDefaultData();
        }
    }
Exemple #3
0
        public void Ctor1()
        {
            var binding = KeyBinding.Parse("Global::Ctrl+Left Arrow");
            var command = new CommandKeyBinding(new CommandId(), "Foo", binding);
            var data    = new KeyBindingData(new ReadOnlyCollection <CommandKeyBinding>(new CommandKeyBinding[] { command }));

            Assert.Equal("Ctrl+Left Arrow", data.KeyName);
            Assert.False(data.HandledByVsVim);
        }
Exemple #4
0
        public void Ctor1()
        {
            var binding = KeyBinding.Parse("Global::Ctrl+Left Arrow");
            var command = new CommandKeyBinding("Foo", binding);
            var data    = new KeyBindingData(new CommandKeyBinding[] { command });

            Assert.AreEqual("Ctrl+Left Arrow", data.KeyName);
            Assert.IsFalse(data.HandledByVsVim);
        }
        public static void RegisterKey(string bindingName, KeyBindingData bindingKey,
                                       KeyboardAccess.GameModesGroup gameMode = KeyboardAccess.GameModesGroup.World)
        {
            Game.Instance.Keyboard.UnregisterBinding(bindingName);

            if (bindingKey.Key == KeyCode.None && bindingKey.Key != KeyCode.None)
            {
                Game.Instance.Keyboard.RegisterBinding(bindingName, bindingKey, gameMode, false);
            }
        }
        public static bool CanBeRegistered(string bindingName, KeyBindingData bindingKey,
                                           KeyboardAccess.GameModesGroup gameMode = KeyboardAccess.GameModesGroup.World)
        {
            bool result = Game.Instance.Keyboard.CanBeRegistered(
                bindingName,
                bindingKey.Key,
                gameMode,
                bindingKey.IsCtrlDown,
                bindingKey.IsAltDown,
                bindingKey.IsShiftDown);

            return(result);
        }
 public static string GetKeyText(KeyBindingData bindingKey)
 {
     if (bindingKey.Key == KeyCode.None)
     {
         return("None");
     }
     else
     {
         return(string.Concat(
                    bindingKey.IsCtrlDown ? "Ctrl+" : null,
                    bindingKey.IsAltDown ? "Alt+" : null,
                    bindingKey.IsShiftDown ? "Shift+" : null,
                    bindingKey.Key.ToString()));
     }
 }
Exemple #8
0
    /// <summary>
    /// Save Settings
    /// </summary>
    public void SaveKeyBindings()
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(keyBindingPath);

        KeyBindingData kbd = new KeyBindingData
        {
            horizontalInverted   = horizontalInverted,
            verticalInverted     = verticalInverted,
            fpHorizontalInverted = fpHorizontalInverted,
            fpVerticalInverted   = fpVerticalInverted,
            bindedKeys           = bindedKeys
        };

        bf.Serialize(file, kbd);
        file.Close();
    }