Beispiel #1
0
        public static Microsoft.Xna.Framework.Input.GamePadState GetState(Microsoft.Xna.Framework.PlayerIndex index)
        {
            if (instance == null)
            {
                instance = new FizzyoInput();
            }

            SharpDX.DirectInput.JoystickState joyState = new SharpDX.DirectInput.JoystickState();
            if ((int)index < joysticks.Length)
            {
                joysticks[(int)index].GetCurrentState(ref joyState);
                joyState.X -= joysticksDeadzoneX[(int)index];
                return(joyState.ToXNAGamePadState());
            }

            return(new Microsoft.Xna.Framework.Input.GamePadState());
        }
Beispiel #2
0
        /// <summary>
        /// Reads the latest state of the keyboard and gamepad.
        /// </summary>
        public override void Update(GameTime gameTime)
        {
            LastKeyboardState    = CurrentKeyboardState;
            CurrentKeyboardState = Keyboard.GetState();
            for (int i = 0; i < MaxGamePadInputs; i++)
            {
                LastGamePadStates[i] = CurrentGamePadStates[i];
                LastFizzyoStates[i]  = CurrentFizzyoStates[i];

                CurrentGamePadStates[i] = GamePad.GetState((PlayerIndex)i);
                CurrentFizzyoStates[i]  = FizzyoInput.GetState((PlayerIndex)i);

                GamePadsAvailable = false;

                // Keep track of whether a gamepad has ever been
                // connected, so we can detect if it is unplugged.
                if (CurrentGamePadStates[i].IsConnected)
                {
                    GamePadsAvailable      = true;
                    GamePadWasConnected[i] = true;
                }
                if (CurrentFizzyoStates[i].IsConnected)
                {
                    GamePadsAvailable     = true;
                    FizzyoWasConnected[i] = true;
                }
            }

            TouchState = TouchPanel.GetState();

            Gestures.Clear();
            while (TouchPanel.IsGestureAvailable)
            {
                Gestures.Add(TouchPanel.ReadGesture());
            }

            base.Update(gameTime);
        }