Game Development Reference
In-Depth Information
public void Update()
{
byte buttonState = Sdl.SDL_JoystickGetButton(_joystick,
_buttonId);
Held = (buttonState == 1);
}
}
}
The Update function of the button updates the Held variable. The controller
class can now have its buttons added.
public ControllerButton ButtonA { get; private set; }
public ControllerButton ButtonB { get; private set; }
public ControllerButton ButtonX { get; private set; }
public ControllerButton ButtonY { get; private set; }
// Front shoulder buttons
public ControllerButton ButtonLB { get; private set; }
public ControllerButton ButtonRB { get; private set; }
public ControllerButton ButtonBack { get; private set; }
public ControllerButton ButtonStart { get; private set; }
// If you press the control stick in
public ControllerButton ButtonL3 { get; private set; }
public ControllerButton ButtonR3 { get; private set; }
public XboxController(int player)
{
_joystick = Sdl.SDL_JoystickOpen(player);
LeftControlStick = new ControlStick(_joystick, 0, 1);
RightControlStick = new ControlStick(_joystick, 4, 3);
ButtonA = new ControllerButton(_joystick, 0);
ButtonB = new ControllerButton(_joystick, 1);
ButtonX = new ControllerButton(_joystick, 2);
ButtonY = new ControllerButton(_joystick, 3);
ButtonLB = new ControllerButton(_joystick, 4);
ButtonRB = new ControllerButton(_joystick, 5);
ButtonBack = new ControllerButton(_joystick, 6);
ButtonStart = new ControllerButton(_joystick, 7);
ButtonL3 = new ControllerButton(_joystick, 8);
Search WWH ::




Custom Search