Ejemplo n.º 1
0
        private void tmrCheckKey_Tick(object sender, EventArgs e)
        {
            List <UInt32> scanCodes = InputApi.GetPressedKeys();

            if (_singleKeyMode)
            {
                if (scanCodes.Count >= 1)
                {
                    //Always use the largest scancode (when multiple buttons are pressed at once)
                    scanCodes = new List <UInt32> {
                        scanCodes.OrderBy(code => - code).First()
                    };
                    this.SelectKeyCombination(new KeyCombination(scanCodes));
                }
            }
            else
            {
                KeyCombination key = new KeyCombination(_prevScanCodes);
                lblCurrentKeys.Text = key.ToString();

                if (scanCodes.Count < _prevScanCodes.Count)
                {
                    //Confirm key selection when the user releases a key
                    this.SelectKeyCombination(key);
                }

                _prevScanCodes = scanCodes;
            }
        }
Ejemplo n.º 2
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 && !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;
                                GoToPreviousGame();
                            }
                            else if (mapping.Right == keyCode)
                            {
                                _waitForRelease = true;
                                GoToNextGame();
                            }
                            else if (mapping.A == keyCode || mapping.B == keyCode)
                            {
                                _waitForRelease = true;
                                LoadSelectedGame();
                            }
                        }
                    }
                }
                else
                {
                    _waitForRelease = false;
                }
            }
        }
Ejemplo n.º 3
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;
                }
            }
        }
Ejemplo n.º 4
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;
                }
            }
        }