Reading input is extremely simple in DreamBox. All the functions you need are in the gamepad moduleh
You first construct a new Gamepad with one of four slots:
let gamepad = Gamepad::new(GamepadSlot::SlotA);
To check if the gamepad in that slot is connected:
let is_connected = gamepad.is_connected();
To actually read the current state of the gamepad:
let gamepad_state = gamepad.read_state();
The state of all the gamepad buttons are stored in state.button_mask - each button state occupies a single bit of the mask.
To query a specific button, use .contains:
if gamepad_state.button_mask.contains(GamepadButton::A) { // A button is pressed }
Additionally, the position of the left and right sticks are stored as state.lStickX, state.lStickY, state.rStickX, and state.lStickY.
Each of these ranges between -32767 to +32767, representing the full range of motion on that axis.
Controllers with vibration are also supported. You can enable or disable vibration like this:
// enable rumble on gamepad connected to this slot gamepad.set_rumble(true);