Esempio n. 1
0
        private void loadSettings()
        {
            loadingSettings    = true;
            numNormalX.Value   = Properties.Settings.Default.normalX;
            numNormalY.Value   = Properties.Settings.Default.normalY;
            numSwitchedX.Value = Properties.Settings.Default.switchX;
            numSwitchedY.Value = Properties.Settings.Default.switchY;

            chkEnableEditKeySwitch.Checked = Properties.Settings.Default.enableEdit;
            enableEditKey   = Properties.Settings.Default.enableEdit;
            editKey         = KeyStroke.KeyboardStroke(Properties.Settings.Default.editKey);
            btnEditKey.Text = editKey.ToString();

            loadLists();
            loadingSettings = false;
        }
Esempio n. 2
0
        private void Input_OnMousePressed(object sender, MousePressedEventArgs e)
        {
            if (e.State > MouseState.LeftUp)
            {
                KeyStroke stroke = KeyStroke.MouseStroke(e.State);

                if (isAwaitingNormalKey || isAwaitingSwitchedKey)
                {
                    bool isNormal = isAwaitingNormalKey;
                    BindingList <KeyStroke> keyList = isNormal ? normalKeys : switchedKeys;

                    if (!keyList.Contains(stroke))
                    {
                        this.Invoke((MethodInvoker) delegate
                        {
                            keyList.Add(stroke);
                            saveSettings();
                        });

                        isAwaitingSwitchedKey = false;
                        isAwaitingNormalKey   = false;
                    }
                    return;
                }

                bool switchContained = switchedKeys.Contains(stroke);
                bool normalContained = normalKeys.Contains(stroke);
                if (switchContained && normalContained)
                {
                    isMouseSpeedSwitched = !isMouseSpeedSwitched;
                }
                else if (switchContained)
                {
                    isMouseSpeedSwitched = true;
                }
                else if (normalContained)
                {
                    isMouseSpeedSwitched = false;
                }
            }

            e.X *= isMouseSpeedSwitched ? switchedXMultiplier : normalXMultiplier;
            e.Y *= isMouseSpeedSwitched ? switchedYMultiplier : normalYMultiplier;
        }
Esempio n. 3
0
        private void Input_OnKeyPressed(object sender, KeyPressedEventArgs e)
        {
            KeyStroke stroke = KeyStroke.KeyboardStroke(e.Key);

            if (isAwaitingNormalKey || isAwaitingSwitchedKey)
            {
                bool isNormal = isAwaitingNormalKey;
                BindingList <KeyStroke> keyList = isNormal ? normalKeys : switchedKeys;

                if (e.State == KeyState.Down && !keyList.Contains(stroke))
                {
                    this.Invoke((MethodInvoker) delegate
                    {
                        keyList.Add(stroke);
                        saveSettings();
                    });

                    isAwaitingSwitchedKey = false;
                    isAwaitingNormalKey   = false;
                }
                return;
            }
            else if (isAwaitingEditKey && e.State == KeyState.Down)
            {
                editKey = stroke;
                this.Invoke((MethodInvoker) delegate
                {
                    btnEditKey.Text = editKey.ToString();
                    saveSettings();
                });
                isAwaitingEditKey = false;
                return;
            }

            if (enableEditKey && editKey != null && stroke.Equals(editKey))
            {
                if (waitingEditKeyRelease)
                {
                    if (e.State == KeyState.Up)
                    {
                        waitingEditKeyRelease = false;
                    }
                    return;
                }
                if (!isMouseSpeedSwitched)
                {
                    isMouseSpeedSwitched      = true;
                    enteredSwitchUsingEditkey = true;
                }
                else
                {
                    if (enteredSwitchUsingEditkey)
                    {
                        isMouseSpeedSwitched = false;
                    }
                }
                waitingEditKeyRelease = true;
                return;
            }

            bool switchContained = switchedKeys.Contains(stroke);
            bool normalContained = normalKeys.Contains(stroke);

            if (switchContained || normalContained)
            {
                if (!isAwaitingRelease && e.State == KeyState.Down)
                {
                    isMouseSpeedSwitched      = switchContained && normalContained ? !isMouseSpeedSwitched : switchContained;
                    enteredSwitchUsingEditkey = false;
                }
                else if (isAwaitingRelease && e.State == KeyState.Up)
                {
                    isAwaitingRelease = false;
                }
            }
        }