ZuneのPAD制御

■PADの操作に関して、調べてみました、まずはデジタル入力に関しての制御です。

namespace ZuneGame2
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        private SpriteBatch sprite;
        private Texture2D texture;
        private Vector2 myPos;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            TargetElapsedTime = TimeSpan.FromSeconds(1 / 30.0);
        }

        protected override void Initialize()
        {
            base.Initialize();
        }

        protected override void LoadContent()
        {
            sprite = new SpriteBatch(graphics.GraphicsDevice);
            texture = Content.Load<Texture2D>("mimi");
            myPos = new Vector2(0, 0);
        }

        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();
            inputTest();
            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
            sprite.Begin();
            sprite.Draw(texture, myPos, Color.White);
            sprite.End();
            base.Draw(gameTime);
        }

        private void inputTest()
        {
            var dpad = GamePad.GetState(PlayerIndex.One).DPad;
            if (dpad.Left == ButtonState.Pressed)
                myPos.X -= 1.0f;
            if (dpad.Right == ButtonState.Pressed)
                myPos.X += 1.0f;
            if (dpad.Up == ButtonState.Pressed)
                myPos.Y -= 1.0f;
            if (dpad.Down == ButtonState.Pressed)
                myPos.Y += 1.0f;

            var buttons = GamePad.GetState(PlayerIndex.One).Buttons;
            if (buttons.A == ButtonState.Pressed)
                myPos = new Vector2(0, 0);
            if (buttons.B == ButtonState.Pressed)
                myPos = new Vector2(0, 0);
        }
    }
}


■アナログ関係の入力ですが、PADのどこに接触しているのかをアナログ値で取得ができます。

        private void inputTest()
        {
            var touchPad = GamePad.GetState(PlayerIndex.One).ThumbSticks.Left;
            myPos.X += touchPad.X;
            myPos.Y -= touchPad.Y;
        }