Ejemplo n.º 1
0
 static InputHelper()
 {
     LastGamePadState = new GamePadState [ 4 ];
     CurrentGamePadState = new GamePadState [ 4 ];
 }
Ejemplo n.º 2
0
        protected override GamePadState GenerateState( PlayerIndex playerIndex )
        {
            device.Poll ();
            var state = device.GetCurrentState ();
            GamePadButton pressedButtons = GamePadButton.None;
            if ( state.Buttons [ 0 ] ) pressedButtons |= GamePadButton.A;
            if ( state.Buttons [ 1 ] ) pressedButtons |= GamePadButton.B;
            if ( state.Buttons [ 2 ] ) pressedButtons |= GamePadButton.X;
            if ( state.Buttons [ 3 ] ) pressedButtons |= GamePadButton.Y;
            if ( state.Buttons [ 4 ] ) pressedButtons |= GamePadButton.LeftBumper;
            if ( state.Buttons [ 5 ] ) pressedButtons |= GamePadButton.RightBumper;
            if ( state.Buttons [ 6 ] ) pressedButtons |= GamePadButton.Back;
            if ( state.Buttons [ 7 ] ) pressedButtons |= GamePadButton.Start;
            if ( state.Buttons [ 8 ] ) pressedButtons |= GamePadButton.LeftThumbStick;
            if ( state.Buttons [ 9 ] ) pressedButtons |= GamePadButton.RightThumbStick;

            if ( state.PointOfViewControllers [ 0 ] == 0 ) pressedButtons |= GamePadButton.DPadUp;
            if ( state.PointOfViewControllers [ 0 ] == 9000 ) pressedButtons |= GamePadButton.DPadRight;
            if ( state.PointOfViewControllers [ 0 ] == 13500 ) pressedButtons |= GamePadButton.DPadDown;
            if ( state.PointOfViewControllers [ 0 ] == 22500 ) pressedButtons |= GamePadButton.DPadLeft;

            if ( state.PointOfViewControllers [ 0 ] == 4500 ) pressedButtons |= GamePadButton.DPadUp | GamePadButton.DPadRight;
            if ( state.PointOfViewControllers [ 0 ] == 13500 ) pressedButtons |= GamePadButton.DPadDown | GamePadButton.DPadRight;
            if ( state.PointOfViewControllers [ 0 ] == 22500 ) pressedButtons |= GamePadButton.DPadDown | GamePadButton.DPadLeft;
            if ( state.PointOfViewControllers [ 0 ] == 31500 ) pressedButtons |= GamePadButton.DPadUp | GamePadButton.DPadLeft;

            GamePadState gamePadState = new GamePadState ( new Vector2 ( state.X / 32767.0f, state.Y / 32767.0f ),
                new Vector2 ( state.RotationX / 32767.0f, state.RotationY / 32767.0f ),
                ( state.Z - 32767 ) / 32767.0f, ( 32767 - state.Z ) / 32767.0f, pressedButtons );
            return gamePadState;
        }