예제 #1
0
        private static void UpdateButtons()
        {
            _kb    = GetActualKeyboard();
            _mouse = GetActualMouse();

            for (int i = 0; i < 4; i++)
            {
                PlayerIndex p = (PlayerIndex)i;
                PadCache[p]?.Clear();

                // Apply deadzone to allow combining of more frames in input file
                // Using a smaller deadzone than commonly used in game (0.3) to be on the safe side
                // I would use one of the XNA deadzones but the game doesn't do this either
                GamePadState   state = GetActualGamePad(p, GamePadDeadZone.None);
                XINPUT_GAMEPAD pad   = state.GetInternalState();

                if (Math.Abs(state.Triggers.Left) < 0.2f)
                {
                    pad.LeftTrigger = 0;
                }

                if (Math.Abs(state.Triggers.Right) < 0.2f)
                {
                    pad.RightTrigger = 0;
                }

                if (Math.Abs(state.ThumbSticks.Left.X) < 0.2f)
                {
                    pad.ThumbLX = 0;
                }

                if (Math.Abs(state.ThumbSticks.Left.Y) < 0.2f)
                {
                    pad.ThumbLY = 0;
                }

                if (Math.Abs(state.ThumbSticks.Right.X) < 0.2f)
                {
                    pad.ThumbRX = 0;
                }

                if (Math.Abs(state.ThumbSticks.Right.Y) < 0.2f)
                {
                    pad.ThumbRY = 0;
                }

                _pads[i] = pad;
            }
        }