Beispiel #1
0
 public Controller()
 {
     reading            = new ControllerReading();
     reading.keep_time  = new int[0];
     reading.keep_atime = new int[0];
     reading.last_atime = new int[0];
     reading.last_time  = new int[0];
 }
    public override void UpdateControllerReading(ref ControllerReading reading)
    {
        var state = Keyboard.GetState();

        if (state.IsKeyDown(Keys.Up))
        {
            reading.direction |= ControllerConsts.UP;
        }
        if (state.IsKeyDown(Keys.Down))
        {
            reading.direction |= ControllerConsts.DOWN;
        }
        if (state.IsKeyDown(Keys.Left))
        {
            reading.direction |= ControllerConsts.LEFT;
        }
        if (state.IsKeyDown(Keys.Right))
        {
            reading.direction |= ControllerConsts.RIGHT;
        }
        if (state.IsKeyDown(Keys.A))
        {
            reading.direction |= ControllerConsts.JUMP_BUTTON | ControllerConsts.A;
        }
        if (state.IsKeyDown(Keys.S))
        {
            reading.direction |= ControllerConsts.JUMP_BUTTON | ControllerConsts.B;
        }
        if (state.IsKeyDown(Keys.D))
        {
            reading.direction |= ControllerConsts.JUMP_BUTTON | ControllerConsts.X;
        }
        if (state.IsKeyDown(Keys.Q))
        {
            reading.direction |= ControllerConsts.L;
        }
        if (state.IsKeyDown(Keys.W))
        {
            reading.direction |= (ControllerConsts.SUPER_SONIC | ControllerConsts.Y);
        }
        if (state.IsKeyDown(Keys.E))
        {
            reading.direction |= ControllerConsts.R;
        }
        if (state.IsKeyDown(Keys.Escape))
        {
            reading.direction |= ControllerConsts.START;
        }
    }
Beispiel #3
0
 public abstract void UpdateControllerReading(ref ControllerReading reading);
Beispiel #4
0
    public override void UpdateControllerReading(ref ControllerReading reading)
    {
        var state = GamePad.GetState(index, GamePadDeadZone.Circular);

        if (this.keyboardController != null)
        {
            keyboardController.UpdateControllerReading(ref reading);
        }

        reading.alx = (short)(state.ThumbSticks.Left.X * short.MaxValue);
        reading.aly = (short)(state.ThumbSticks.Left.Y * short.MaxValue);

        reading.arx = (short)(state.ThumbSticks.Right.X * short.MaxValue);
        reading.ary = (short)(state.ThumbSticks.Right.Y * short.MaxValue);

        if (state.Buttons.A == ButtonState.Pressed)
        {
            reading.direction |= (ControllerConsts.JUMP_BUTTON | ControllerConsts.CONFIRM | ControllerConsts.A);
        }
        if (state.Buttons.B == ButtonState.Pressed)
        {
            reading.direction |= (ControllerConsts.JUMP_BUTTON | ControllerConsts.CANCEL | ControllerConsts.B);
        }

        if (state.Buttons.Y == ButtonState.Pressed)
        {
            reading.direction |= (ControllerConsts.SUPER_SONIC | ControllerConsts.Y);
        }
        if (state.Buttons.X == ButtonState.Pressed)
        {
            reading.direction |= (ControllerConsts.SUPER_SONIC | ControllerConsts.X);
        }

        if (state.Buttons.LeftShoulder == ButtonState.Pressed)
        {
            reading.direction |= ControllerConsts.L;
        }

        if (state.Buttons.LeftShoulder == ButtonState.Pressed)
        {
            reading.direction |= ControllerConsts.R;
        }

        if (state.Buttons.Start == ButtonState.Pressed)
        {
            reading.direction |= ControllerConsts.START;
        }

        if (state.DPad.Left == ButtonState.Pressed)
        {
            reading.direction |= ControllerConsts.LEFT;
        }
        if (state.DPad.Up == ButtonState.Pressed)
        {
            reading.direction |= ControllerConsts.UP;
        }
        if (state.DPad.Down == ButtonState.Pressed)
        {
            reading.direction |= ControllerConsts.DOWN;
        }
        if (state.DPad.Right == ButtonState.Pressed)
        {
            reading.direction |= ControllerConsts.RIGHT;
        }
    }