Example #1
0
        public MapKeystrokeForm(PadTieForm main, Controller cc, KeyAction editing)
            : this(main, cc)
        {
            this.editing = editing;
            capturedKey = editing.Key;
            ctrl.Checked = shift.Checked = alt.Checked = false;
            continuous.Checked = editing.Continuous;

            foreach (Keys mod in editing.Modifiers) {
                if (mod == Keys.Control) ctrl.Checked = true;
                else if (mod == Keys.Shift) shift.Checked = true;
                else if (mod == Keys.Alt) alt.Checked = true;
            }

            keyBox.Text = Util.GetKeyName(editing.Key);
            slotCapture.SetInput(editing.SlotDescription, true);
        }
Example #2
0
        public static KeyAction Parse(InputCore core, string parseable)
        {
            string[]    parts     = parseable.Split(',');
            string[]    modChunks = parts[1].Split('|');
            List <Keys> mods      = new List <Keys> ();

            if (!string.IsNullOrEmpty(parts[1]))
            {
                foreach (string modChunk in modChunks)
                {
                    mods.Add((Keys)Enum.Parse(typeof(Keys), modChunk));
                }
            }
            var key       = (Keys)Enum.Parse(typeof(Keys), parts[0]);
            var keyAction = new KeyAction(key, mods.ToArray());

            if (parts.Length > 2 && !string.IsNullOrEmpty(parts[2]))
            {
                keyAction.Continuous = bool.Parse(parts[2]);
            }
            return(keyAction);
        }
Example #3
0
        public static KeyAction Parse(InputCore core, string parseable)
        {
            string[] parts = parseable.Split(',');
            string[] modChunks = parts[1].Split('|');
            List<Keys> mods = new List<Keys> ();

            if (!string.IsNullOrEmpty(parts[1]))
                foreach (string modChunk in modChunks)
                    mods.Add((Keys)Enum.Parse(typeof(Keys), modChunk));
            var key = (Keys)Enum.Parse(typeof(Keys), parts[0]);
            var keyAction = new KeyAction(key, mods.ToArray());
            if (parts.Length > 2 && !string.IsNullOrEmpty(parts[2])) {
                keyAction.Continuous = bool.Parse(parts[2]);
            }
            return keyAction;
        }
Example #4
0
        private void okBtn_Click(object sender, EventArgs e)
        {
            if (slotCapture.Value == null) {
                MessageBox.Show("Please use the Capture button and press a button or analog direction first.");
                return;
            }

            var slot = slotCapture.Value;
            var key = Keys.None;
            List<Keys> mods = new List<Keys>();

            if (ctrl.Checked)
                mods.Add(Keys.Control);
            if (shift.Checked)
                mods.Add(Keys.Shift);
            if (alt.Checked)
                mods.Add(Keys.Menu);
            if (meta.Checked)
                mods.Add(Keys.LWin);

            key = capturedKey;

            KeyAction action;

            if (editing != null) {
                action = editing;
                action.ChangeBinding(key, mods.ToArray());

                if (slot != action.SlotDescription)
                    MapUtil.Map(MainForm, Controller.Virtual, action.SlotDescription, null);
            } else {
                action = new KeyAction(key, mods.ToArray());
            }
            action.Continuous = continuous.Checked;
            MapUtil.Map(MainForm, Controller.Virtual, slot, action);

            this.DialogResult = DialogResult.OK;
            this.Close();
        }