コード例 #1
0
        protected override PadState GetState(int index)
        {
            GamePadState state    = GamePad.GetState((PlayerIndex)index, GamePadDeadZone.Circular);
            PadState     padState = new PadState();

            foreach (object obj in Enum.GetValues(typeof(PadButton)))
            {
                if (state.IsButtonDown((Buttons)obj))
                {
                    padState.buttons |= (PadButton)obj;
                }
            }
            padState.sticks.left    = (Vec2)state.ThumbSticks.Left;
            padState.sticks.right   = (Vec2)state.ThumbSticks.Right;
            padState.triggers.left  = state.Triggers.Left;
            padState.triggers.right = state.Triggers.Right;
            return(padState);
        }
コード例 #2
0
        private PadState ConvertDInputState(DInputState state)
        {
            PadState padState = new PadState();

            if (state == null)
            {
                return(padState);
            }
            if (state.buttons[0])
            {
                padState.buttons |= PadButton.X;
            }
            if (state.buttons[3])
            {
                padState.buttons |= PadButton.Y;
            }
            if (state.buttons[1])
            {
                padState.buttons |= PadButton.A;
            }
            if (state.buttons[2])
            {
                padState.buttons |= PadButton.B;
            }
            if (state.buttons[4])
            {
                padState.buttons |= PadButton.LeftShoulder;
            }
            if (state.buttons[5])
            {
                padState.buttons |= PadButton.RightShoulder;
            }
            if (state.buttons[6])
            {
                padState.buttons      |= PadButton.LeftTrigger;
                padState.triggers.left = 1f;
            }
            if (state.buttons[7])
            {
                padState.buttons       |= PadButton.RightTrigger;
                padState.triggers.right = 1f;
            }
            if (state.buttons[8])
            {
                padState.buttons |= PadButton.Back;
            }
            if (state.buttons[9])
            {
                padState.buttons |= PadButton.Start;
            }
            if (state.buttons[11])
            {
                padState.buttons |= PadButton.LeftStick;
            }
            if (state.buttons[12])
            {
                padState.buttons |= PadButton.RightStick;
            }
            if (state.left)
            {
                padState.buttons |= PadButton.DPadLeft;
            }
            if (state.right)
            {
                padState.buttons |= PadButton.DPadRight;
            }
            if (state.up)
            {
                padState.buttons |= PadButton.DPadUp;
            }
            if (state.down)
            {
                padState.buttons |= PadButton.DPadDown;
            }
            padState.sticks.left  = new Vec2(state.leftX, state.leftY * -1f);
            padState.sticks.right = new Vec2(state.leftZ, -state.rightX);
            if ((double)padState.sticks.left.Length() < 0.100000001490116)
            {
                padState.sticks.left = Vec2.Zero;
            }
            if ((double)padState.sticks.right.Length() < 0.100000001490116)
            {
                padState.sticks.right = Vec2.Zero;
            }
            return(padState);
        }