Esempio n. 1
0
        public static void OnMouseMove(Control ctrl)
        {
            if (_mouseCaptured && AllowMouseCapture)
            {
                HideMouse();
                _tmrHideMouse.Stop();
                Form  frm       = Application.OpenForms[0];
                Point centerPos = frm.PointToScreen(new Point(frm.Width / 2, frm.Height / 2));
                Point diff      = new Point(Cursor.Position.X - centerPos.X, Cursor.Position.Y - centerPos.Y);
                if (diff.X != 0 || diff.Y != 0)
                {
                    InputApi.SetMouseMovement((Int16)diff.X, (Int16)diff.Y);
                    Cursor.Position = centerPos;
                }
            }
            else
            {
                _mouseCaptured = false;

                if (!EmuRunner.IsRunning() || EmuApi.IsPaused())
                {
                    ShowMouse();
                }                 /* TODO else if(ConfigManager.Config.Input.HideMousePointerForZapper && CursorManager.IsLightGun) {
                                   *    //Keep mouse hidden when using zapper if option to hide mouse is enabled
                                   *    HideMouse();
                                   *    return;
                                   * }*/

                _tmrHideMouse.Stop();

                if (!CursorManager.NeedMouseIcon)
                {
                    //Only hide mouse if no zapper (otherwise this could be pretty annoying)
                    ctrl.Cursor = Cursors.Default;

                    if (EmuRunner.IsRunning() && !EmuApi.IsPaused())
                    {
                        _tmrHideMouse.Start();
                    }
                }
            }
        }
Esempio n. 2
0
        public frmGetKey(bool singleKeyMode)
        {
            InitializeComponent();
            _singleKeyMode = singleKeyMode;
            if (_singleKeyMode)
            {
                tableLayoutPanel1.RowStyles[1].SizeType = SizeType.Absolute;
                tableLayoutPanel1.RowStyles[1].Height   = 0;
            }
            if (_singleKeyMode)
            {
                lblCurrentKeys.Height  = 1;
                lblCurrentKeys.Visible = false;
            }
            ShortcutKey = new KeyCombination();
            InputApi.UpdateInputDevices();
            InputApi.ResetKeyState();

            //Prevent other keybindings from interfering/activating
            InputApi.DisableAllKeys(true);
        }
Esempio n. 3
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            ScreenSize size       = EmuApi.GetScreenSize(false);
            int        leftMargin = (this.Width - size.Width) / 2;
            int        topMargin  = (this.Height - size.Height) / 2;

            CursorManager.OnMouseMove(this);

            if (CursorManager.NeedMouseIcon)
            {
                this.Cursor = Cursors.Cross;
            }

            double xPos = (double)(e.X - leftMargin) / size.Width;
            double yPos = (double)(e.Y - topMargin) / size.Height;

            xPos = Math.Max(0.0, Math.Min(1.0, xPos));
            yPos = Math.Max(0.0, Math.Min(1.0, yPos));

            InputApi.SetMousePosition(xPos, yPos);
        }
Esempio n. 4
0
        public void InitializeDefaultShortcuts()
        {
            if (ShortcutKeys1 != null && ShortcutKeys2 != null)
            {
                return;
            }

            ShortcutKeys1 = new List <ShortcutKeyInfo>();
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.FastForward, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Tab")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.Rewind, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Backspace")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.IncreaseSpeed, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("=")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.DecreaseSpeed, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("-")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.MaxSpeed, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("F9")
            }));

            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.ToggleFps, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("F10")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.ToggleFullscreen, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("F11")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.TakeScreenshot, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("F12")
            }));

            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.Reset, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Ctrl"), Key2 = InputApi.GetKeyCode("R")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.PowerCycle, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Ctrl"), Key2 = InputApi.GetKeyCode("T")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.Pause, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Esc")
            }));

            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.SetScale1x, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Alt"), Key2 = InputApi.GetKeyCode("1")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.SetScale2x, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Alt"), Key2 = InputApi.GetKeyCode("2")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.SetScale3x, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Alt"), Key2 = InputApi.GetKeyCode("3")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.SetScale4x, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Alt"), Key2 = InputApi.GetKeyCode("4")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.SetScale5x, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Alt"), Key2 = InputApi.GetKeyCode("5")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.SetScale6x, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Alt"), Key2 = InputApi.GetKeyCode("6")
            }));

            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.OpenFile, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Ctrl"), Key2 = InputApi.GetKeyCode("O")
            }));

            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.SaveStateSlot1, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Shift"), Key2 = InputApi.GetKeyCode("F1")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.SaveStateSlot2, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Shift"), Key2 = InputApi.GetKeyCode("F2")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.SaveStateSlot3, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Shift"), Key2 = InputApi.GetKeyCode("F3")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.SaveStateSlot4, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Shift"), Key2 = InputApi.GetKeyCode("F4")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.SaveStateSlot5, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Shift"), Key2 = InputApi.GetKeyCode("F5")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.SaveStateSlot6, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Shift"), Key2 = InputApi.GetKeyCode("F6")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.SaveStateSlot7, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Shift"), Key2 = InputApi.GetKeyCode("F7")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.SaveStateToFile, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Ctrl"), Key2 = InputApi.GetKeyCode("S")
            }));

            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.LoadStateSlot1, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("F1")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.LoadStateSlot2, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("F2")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.LoadStateSlot3, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("F3")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.LoadStateSlot4, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("F4")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.LoadStateSlot5, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("F5")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.LoadStateSlot6, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("F6")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.LoadStateSlot7, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("F7")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.LoadStateSlotAuto, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("F8")
            }));
            ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.LoadStateFromFile, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Ctrl"), Key2 = InputApi.GetKeyCode("L")
            }));

            ShortcutKeys2 = new List <ShortcutKeyInfo>();
            ShortcutKeys2.Add(new ShortcutKeyInfo(EmulatorShortcut.FastForward, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Pad1 R2")
            }));
            ShortcutKeys2.Add(new ShortcutKeyInfo(EmulatorShortcut.Rewind, new KeyCombination()
            {
                Key1 = InputApi.GetKeyCode("Pad1 L2")
            }));
        }
Esempio n. 5
0
 protected override void OnFormClosing(FormClosingEventArgs e)
 {
     InputApi.DisableAllKeys(false);
     base.OnFormClosing(e);
 }
Esempio n. 6
0
        private void tmrInput_Tick(object sender, EventArgs e)
        {
            //Use player 1's controls to navigate the recent game selection screen
            if (Application.OpenForms.Count > 0 && Application.OpenForms[0].ContainsFocus && this.Visible)
            {
                if (Mode != GameScreenMode.RecentGames && !EmuApi.IsPaused())
                {
                    this.Visible = false;
                    return;
                }
                List <uint> keyCodes = InputApi.GetPressedKeys();
                uint        keyCode  = keyCodes.Count > 0 ? keyCodes[0] : 0;
                if (keyCode > 0)
                {
                    if (!_waitForRelease)
                    {
                        List <KeyMapping> mappings = new List <KeyMapping>()
                        {
                            ConfigManager.Config.Input.Controllers[0].Keys.Mapping1,
                            ConfigManager.Config.Input.Controllers[0].Keys.Mapping2,
                            ConfigManager.Config.Input.Controllers[0].Keys.Mapping3,
                            ConfigManager.Config.Input.Controllers[0].Keys.Mapping4
                        };

                        foreach (KeyMapping mapping in mappings)
                        {
                            if (mapping.Left == keyCode)
                            {
                                _waitForRelease = true;
                                if (_currentIndex == 0)
                                {
                                    _currentIndex = _recentGames.Count - 1;
                                }
                                else
                                {
                                    _currentIndex--;
                                }
                                UpdateGameInfo();
                            }
                            else if (mapping.Right == keyCode)
                            {
                                _waitForRelease = true;
                                _currentIndex   = (_currentIndex + 1) % _recentGames.Count;
                                UpdateGameInfo();
                            }
                            else if (mapping.Down == keyCode)
                            {
                                _waitForRelease = true;
                                if (_currentIndex + _columnCount < _recentGames.Count)
                                {
                                    _currentIndex += _columnCount;
                                }
                                else
                                {
                                    _currentIndex = Math.Min(_currentIndex % _columnCount, _recentGames.Count - 1);
                                }
                                UpdateGameInfo();
                            }
                            else if (mapping.Up == keyCode)
                            {
                                _waitForRelease = true;
                                if (_currentIndex < _columnCount)
                                {
                                    _currentIndex = _recentGames.Count - (_columnCount - (_currentIndex % _columnCount));
                                }
                                else
                                {
                                    _currentIndex -= _columnCount;
                                }
                                UpdateGameInfo();
                            }
                            else if (mapping.A == keyCode || mapping.B == keyCode || mapping.Select == keyCode || mapping.Start == keyCode)
                            {
                                _waitForRelease = true;
                                _controls[_currentIndex % _elementsPerPage].ProcessClick();
                            }
                        }
                    }
                }
                else
                {
                    _waitForRelease = false;
                }
            }
        }
Esempio n. 7
0
        public void Listen(bool useSto0Z, int stoozPercent, List <JoystickButtons> joystickButtons, InputApi inputApi, GameProfile gameProfile)
        {
            try
            {
                KillMe = false;
                InputListenerXInput.KillMe      = false;
                InputListenerDirectInput.KillMe = false;
                InputListenerRawInput.KillMe    = false;
                _gameprofile = gameProfile;
                _inputApi    = inputApi;

                if (_inputApi == InputApi.DirectInput)
                {
                    var thread = new Thread(() => _inputListenerDirectInput.ListenDirectInput(joystickButtons, gameProfile));
                    thread.Start();
                }
                else if (_inputApi == InputApi.XInput)
                {
                    _xi1 = new Thread(() => _inputListenerXInput.ListenXInput(useSto0Z, stoozPercent, joystickButtons, UserIndex.One, gameProfile));
                    _xi1.Start();

                    _xi2 = new Thread(() => _inputListenerXInput.ListenXInput(useSto0Z, stoozPercent, joystickButtons, UserIndex.Two, gameProfile));
                    _xi2.Start();

                    _xi3 = new Thread(() => _inputListenerXInput.ListenXInput(useSto0Z, stoozPercent, joystickButtons, UserIndex.Three, gameProfile));
                    _xi3.Start();

                    _xi4 = new Thread(() => _inputListenerXInput.ListenXInput(useSto0Z, stoozPercent, joystickButtons, UserIndex.Four, gameProfile));
                    _xi4.Start();
                    var thread = new Thread(() => ThreadRespawnerXInput(useSto0Z, stoozPercent, joystickButtons));
                    thread.Start();
                }
                else if (_inputApi == InputApi.RawInput)
                {
                    var thread = new Thread(() => _inputListenerRawInput.ListenRawInput(joystickButtons, gameProfile));
                    thread.Start();
                }
            }
            catch (Exception)
            {
                // ignored
            }
            while (!KillMe)
            {
                Thread.Sleep(1000);
            }
        }
Esempio n. 8
0
 private void ctrlRenderer_MouseLeave(object sender, EventArgs e)
 {
     CursorManager.OnMouseLeave();
     InputApi.SetMousePosition(-1, -1);
 }
Esempio n. 9
0
 private void SetMouseButtonState(MouseButtons pressedButtons)
 {
     InputApi.SetKeyState(LeftMouseButtonKeyCode, pressedButtons.HasFlag(MouseButtons.Left));
     InputApi.SetKeyState(RightMouseButtonKeyCode, pressedButtons.HasFlag(MouseButtons.Right));
     InputApi.SetKeyState(MiddleMouseButtonKeyCode, pressedButtons.HasFlag(MouseButtons.Middle));
 }
Esempio n. 10
0
        public KeyPresets()
        {
            _wasdLayout = new KeyMapping()
            {
                A      = InputApi.GetKeyCode("K"),
                B      = InputApi.GetKeyCode("J"),
                X      = InputApi.GetKeyCode(","),
                Y      = InputApi.GetKeyCode("M"),
                Select = InputApi.GetKeyCode("O"),
                Start  = InputApi.GetKeyCode("L"),
                L      = InputApi.GetKeyCode("U"),
                R      = InputApi.GetKeyCode("I"),
                Up     = InputApi.GetKeyCode("W"),
                Down   = InputApi.GetKeyCode("S"),
                Left   = InputApi.GetKeyCode("A"),
                Right  = InputApi.GetKeyCode("D")
            };

            _arrowLayout = new KeyMapping()
            {
                A      = InputApi.GetKeyCode("S"),
                B      = InputApi.GetKeyCode("A"),
                X      = InputApi.GetKeyCode("X"),
                Y      = InputApi.GetKeyCode("Z"),
                Select = InputApi.GetKeyCode("E"),
                Start  = InputApi.GetKeyCode("D"),
                L      = InputApi.GetKeyCode("Q"),
                R      = InputApi.GetKeyCode("W"),
                Up     = InputApi.GetKeyCode("Up Arrow"),
                Down   = InputApi.GetKeyCode("Down Arrow"),
                Left   = InputApi.GetKeyCode("Left Arrow"),
                Right  = InputApi.GetKeyCode("Right Arrow")
            };

            if (Program.IsMono)
            {
                //TODO test and update for Mono
                for (int i = 0; i < 2; i++)
                {
                    string prefix = "Pad" + (i + 1).ToString() + " ";
                    _xboxLayouts[i] = new KeyMapping()
                    {
                        A      = InputApi.GetKeyCode(prefix + "A"),
                        B      = InputApi.GetKeyCode(prefix + "X"),
                        X      = InputApi.GetKeyCode(prefix + "B"),
                        Y      = InputApi.GetKeyCode(prefix + "Y"),
                        Select = InputApi.GetKeyCode(prefix + "Select"),
                        Start  = InputApi.GetKeyCode(prefix + "Start"),
                        Up     = InputApi.GetKeyCode(prefix + "Up"),
                        Down   = InputApi.GetKeyCode(prefix + "Down"),
                        Left   = InputApi.GetKeyCode(prefix + "Left"),
                        Right  = InputApi.GetKeyCode(prefix + "Right")
                    };

                    _ps4Layouts[i] = new KeyMapping()
                    {
                        A      = InputApi.GetKeyCode(prefix + "B"),
                        B      = InputApi.GetKeyCode(prefix + "A"),
                        X      = InputApi.GetKeyCode(prefix + "C"),
                        Y      = InputApi.GetKeyCode(prefix + "X"),
                        Select = InputApi.GetKeyCode(prefix + "L2"),
                        Start  = InputApi.GetKeyCode(prefix + "R2"),
                        Up     = InputApi.GetKeyCode(prefix + "Up"),
                        Down   = InputApi.GetKeyCode(prefix + "Down"),
                        Left   = InputApi.GetKeyCode(prefix + "Left"),
                        Right  = InputApi.GetKeyCode(prefix + "Right")
                    };

                    _snes30Layouts[i] = new KeyMapping()
                    {
                        A      = InputApi.GetKeyCode(prefix + "Thumb"),
                        B      = InputApi.GetKeyCode(prefix + "Top2"),
                        X      = InputApi.GetKeyCode(prefix + "Trigger"),
                        Y      = InputApi.GetKeyCode(prefix + "Top"),
                        Select = InputApi.GetKeyCode(prefix + "Base5"),
                        Start  = InputApi.GetKeyCode(prefix + "Base6"),
                        Up     = InputApi.GetKeyCode(prefix + "Y-"),
                        Down   = InputApi.GetKeyCode(prefix + "Y+"),
                        Left   = InputApi.GetKeyCode(prefix + "X-"),
                        Right  = InputApi.GetKeyCode(prefix + "X+")
                    };
                }
            }
            else
            {
                for (int i = 0; i < 2; i++)
                {
                    string prefix = "Pad" + (i + 1).ToString() + " ";
                    _xboxLayouts[i] = new KeyMapping()
                    {
                        A      = InputApi.GetKeyCode(prefix + "B"),
                        B      = InputApi.GetKeyCode(prefix + "A"),
                        X      = InputApi.GetKeyCode(prefix + "Y"),
                        Y      = InputApi.GetKeyCode(prefix + "X"),
                        Select = InputApi.GetKeyCode(prefix + "Back"),
                        Start  = InputApi.GetKeyCode(prefix + "Start"),
                        L      = InputApi.GetKeyCode(prefix + "L1"),
                        R      = InputApi.GetKeyCode(prefix + "R1"),
                        Up     = InputApi.GetKeyCode(prefix + "Up"),
                        Down   = InputApi.GetKeyCode(prefix + "Down"),
                        Left   = InputApi.GetKeyCode(prefix + "Left"),
                        Right  = InputApi.GetKeyCode(prefix + "Right")
                    };

                    prefix         = "Joy" + (i + 1).ToString() + " ";
                    _ps4Layouts[i] = new KeyMapping()
                    {
                        A      = InputApi.GetKeyCode(prefix + "But3"),
                        B      = InputApi.GetKeyCode(prefix + "But2"),
                        X      = InputApi.GetKeyCode(prefix + "But4"),
                        Y      = InputApi.GetKeyCode(prefix + "But1"),
                        Select = InputApi.GetKeyCode(prefix + "But9"),
                        Start  = InputApi.GetKeyCode(prefix + "But10"),
                        L      = InputApi.GetKeyCode(prefix + "But5"),
                        R      = InputApi.GetKeyCode(prefix + "But6"),
                        Up     = InputApi.GetKeyCode(prefix + "DPad Up"),
                        Down   = InputApi.GetKeyCode(prefix + "DPad Down"),
                        Left   = InputApi.GetKeyCode(prefix + "DPad Left"),
                        Right  = InputApi.GetKeyCode(prefix + "DPad Right")
                    };

                    _snes30Layouts[i] = new KeyMapping()
                    {
                        A      = InputApi.GetKeyCode(prefix + "But1"),
                        B      = InputApi.GetKeyCode(prefix + "But2"),
                        X      = InputApi.GetKeyCode(prefix + "But4"),
                        Y      = InputApi.GetKeyCode(prefix + "But5"),
                        Select = InputApi.GetKeyCode(prefix + "But11"),
                        Start  = InputApi.GetKeyCode(prefix + "But12"),
                        L      = InputApi.GetKeyCode(prefix + "But7"),
                        R      = InputApi.GetKeyCode(prefix + "But8"),
                        Up     = InputApi.GetKeyCode(prefix + "Y+"),
                        Down   = InputApi.GetKeyCode(prefix + "Y-"),
                        Left   = InputApi.GetKeyCode(prefix + "X-"),
                        Right  = InputApi.GetKeyCode(prefix + "X+")
                    };
                }
            }
        }
Esempio n. 11
0
        private void BtnSaveSettings(object sender, RoutedEventArgs e)
        {
            string inputApiString = _gameProfile.ConfigValues.Find(cv => cv.FieldName == "Input API")?.FieldValue;

            if (inputApiString != null)
            {
                _inputApi = (InputApi)Enum.Parse(typeof(InputApi), inputApiString);
            }

            foreach (var t in _gameProfile.JoystickButtons)
            {
                if (_inputApi == InputApi.DirectInput)
                {
                    t.BindName = t.BindNameDi;
                }
                else if (_inputApi == InputApi.XInput)
                {
                    t.BindName = t.BindNameXi;
                }
                else if (_inputApi == InputApi.RawInput)
                {
                    t.BindName = t.BindNameRi;
                }
            }

            string NameString = _gameProfile.ConfigValues.Find(cv => cv.FieldName == "Submission Name")?.FieldValue;

            if (NameString != null)
            {
                if (_gameProfile.ConfigValues.Any(x => x.FieldName == "Enable Submission (Patreon Only)" && x.FieldValue == "1"))
                {
                    bool CheckName = String.IsNullOrWhiteSpace(_gameProfile.ConfigValues.Find(cv => cv.FieldName == "Submission Name").FieldValue);
                    if (CheckName)
                    {
                        SubmissionNameBad = true;
                        MessageBox.Show("Score Submission requires a name!");
                    }
                    else
                    {
                        SubmissionNameBad = false;
                    }
                }
                else
                {
                    SubmissionNameBad = false;
                }

                string[] badWords = new[] { "f**k", "c**t", "f*****t", "f*g", "dick", "shit", "c**k", "pussy", "ass", "asshole", "bitch", "h**o", "f****t", "@ss", "f@g", "f****r", "f*****g", "fuk", "f****n", "fucken", "teknoparrot", "tp", "arse", "@rse", "@$$", "bastard", "crap", "effing", "god", "hell", "m**********r", "w***e", "twat", "gay", "g@y", "ash0le", "assh0le", "a$$hol", "anal", };

                NameString = Filter(NameString, badWords);
                _gameProfile.ConfigValues.Find(cv => cv.FieldName == "Submission Name").FieldValue = NameString;
            }

            if (!SubmissionNameBad)
            {
                JoystickHelper.SerializeGameProfile(_gameProfile);
                _gameProfile.GamePath = GamePathBox.Text;
                Lazydata.GamePath     = GamePathBox.Text;
                JoystickHelper.SerializeGameProfile(_gameProfile);
                _comboItem.Tag = _gameProfile;
                Application.Current.Windows.OfType <MainWindow>().Single().ShowMessage(string.Format(Properties.Resources.SuccessfullySaved, System.IO.Path.GetFileName(_gameProfile.FileName)));
                _library.ListUpdate(_gameProfile.GameName);
                _contentControl.Content = _library;
            }
        }
        public void LoadNewSettings(GameProfile gameProfile, ListBoxItem comboItem)
        {
            _gameProfile            = gameProfile;
            _comboItem              = comboItem;
            _isKeyboardorButtonAxis = gameProfile.ConfigValues.Any(x => x.FieldName == "Use Keyboard/Button For Axis" && x.FieldValue == "1");
            _RelativeAxis           = gameProfile.ConfigValues.Any(x => x.FieldName == "Use Relative Input" && x.FieldValue == "1");
            _BG4ProMode             = gameProfile.ConfigValues.Any(x => x.FieldName == "Professional Edition Enable" && x.FieldValue == "1");

            string UseDPadForGUN1Stick_String = _gameProfile.ConfigValues.Find(cv => cv.FieldName == "GUN1StickAxisInputStyle")?.FieldValue;

            if (UseDPadForGUN1Stick_String == "UseDPadForGUN1Stick")
            {
                _UseDPadForGUN1Stick = true;
            }
            else
            {
                _UseDPadForGUN1Stick = false;
            }
            string UseDPadForGUN2Stick_String = _gameProfile.ConfigValues.Find(cv => cv.FieldName == "GUN2StickAxisInputStyle")?.FieldValue;

            if (UseDPadForGUN2Stick_String == "UseDPadForGUN2Stick")
            {
                _UseDPadForGUN2Stick = true;
            }
            else
            {
                _UseDPadForGUN2Stick = false;
            }
            string UseAnalogAxisToAimGUN1_String = _gameProfile.ConfigValues.Find(cv => cv.FieldName == "GUN1AimingInputStyle")?.FieldValue;

            if (UseAnalogAxisToAimGUN1_String == "UseAnalogAxisToAim")
            {
                _UseAnalogAxisToAimGUN1 = true;
            }
            else
            {
                _UseAnalogAxisToAimGUN1 = false;
            }
            string UseAnalogAxisToAimGUN2_String = _gameProfile.ConfigValues.Find(cv => cv.FieldName == "GUN2AimingInputStyle")?.FieldValue;

            if (UseAnalogAxisToAimGUN2_String == "UseAnalogAxisToAim")
            {
                _UseAnalogAxisToAimGUN2 = true;
            }
            else
            {
                _UseAnalogAxisToAimGUN2 = false;
            }

            string inputApiString = _gameProfile.ConfigValues.Find(cv => cv.FieldName == "Input API")?.FieldValue;

            if (inputApiString != null)
            {
                _inputApi = (InputApi)Enum.Parse(typeof(InputApi), inputApiString);
            }

            // Hack
            foreach (var t in gameProfile.JoystickButtons)
            {
                if (_inputApi == InputApi.DirectInput)
                {
                    t.BindName = t.BindNameDi;
                }
                else if (_inputApi == InputApi.XInput)
                {
                    t.BindName = t.BindNameXi;
                }
                else if (_inputApi == InputApi.RawInput)
                {
                    t.BindName = t.BindNameRi;
                }
            }

            JoystickMappingItems.ItemsSource = gameProfile.JoystickButtons;
            if (_joystickControlRawInput == null)
            {
                _joystickControlRawInput = new JoystickControlRawInput();
            }
            if (_joystickControlXInput == null)
            {
                _joystickControlXInput = new JoystickControlXInput();
            }
            if (_joystickControlDirectInput == null)
            {
                _joystickControlDirectInput = new JoystickControlDirectInput();
            }
        }
Esempio n. 13
0
 protected override void OnActivated(EventArgs e)
 {
     base.OnActivated(e);
     InputApi.ResetKeyState();
 }
Esempio n. 14
0
        private void tmrInput_Tick(object sender, EventArgs e)
        {
            //Use player 1's controls to navigate the recent game selection screen
            if (frmMain.Instance?.ContainsFocus == true && !EmuRunner.IsRunning())
            {
                List <uint> keyCodes = InputApi.GetPressedKeys();
                uint        keyCode  = keyCodes.Count > 0 ? keyCodes[0] : 0;
                if (keyCode > 0)
                {
                    if (!_waitForRelease)
                    {
                        List <KeyMapping> mappings = new List <KeyMapping>()
                        {
                            ConfigManager.Config.Input.Controllers[0].Keys.Mapping1,
                            ConfigManager.Config.Input.Controllers[0].Keys.Mapping2,
                            ConfigManager.Config.Input.Controllers[0].Keys.Mapping3,
                            ConfigManager.Config.Input.Controllers[0].Keys.Mapping4
                        };

                        foreach (KeyMapping mapping in mappings)
                        {
                            if (mapping.Left == keyCode)
                            {
                                _waitForRelease = true;
                                if (_currentIndex == 0)
                                {
                                    _currentIndex = _recentGames.Count - 1;
                                }
                                else
                                {
                                    _currentIndex--;
                                }
                                UpdateGameInfo();
                            }
                            else if (mapping.Right == keyCode)
                            {
                                _waitForRelease = true;
                                _currentIndex   = (_currentIndex + 1) % _recentGames.Count;
                                UpdateGameInfo();
                            }
                            else if (mapping.Down == keyCode)
                            {
                                _waitForRelease = true;
                                if (_currentIndex + _elementsPerRow < _recentGames.Count)
                                {
                                    _currentIndex += _elementsPerRow;
                                }
                                else
                                {
                                    _currentIndex = IsOnLastPage ? 0 : (_recentGames.Count - 1);
                                }
                                UpdateGameInfo();
                            }
                            else if (mapping.Up == keyCode)
                            {
                                _waitForRelease = true;
                                if (_currentIndex < _elementsPerRow)
                                {
                                    _currentIndex = _recentGames.Count - 1;
                                }
                                else
                                {
                                    _currentIndex -= _elementsPerRow;
                                }
                                UpdateGameInfo();
                            }
                            else if (mapping.L == keyCode)
                            {
                                _waitForRelease = true;
                                if (_currentIndex < _elementsPerPage)
                                {
                                    _currentIndex = _recentGames.Count - 1;
                                }
                                else
                                {
                                    _currentIndex -= _elementsPerPage;
                                }
                                UpdateGameInfo();
                            }
                            else if (mapping.R == keyCode)
                            {
                                _waitForRelease = true;
                                if (_currentIndex + _elementsPerPage < _recentGames.Count)
                                {
                                    _currentIndex += _elementsPerPage;
                                }
                                else
                                {
                                    _currentIndex = IsOnLastPage ? 0 : (_recentGames.Count - 1);
                                }
                                UpdateGameInfo();
                            }
                            else if (mapping.A == keyCode || mapping.B == keyCode || mapping.X == keyCode || mapping.Y == keyCode || mapping.Select == keyCode || mapping.Start == keyCode)
                            {
                                _waitForRelease = true;
                                EmuRunner.LoadRecentGame(_recentGames[_currentIndex].FileName);
                            }
                        }
                    }
                }
                else
                {
                    _waitForRelease = false;
                }
            }
        }