Input¶
engine/input.hpp, engine/api.hpp
See the input tutorial for examples.
buttons¶
extern ButtonState &buttons;
struct ButtonState {
uint32_t state; // buttons held now
uint32_t pressed; // buttons that went down since the previous update
uint32_t released; // buttons that went up since the previous update
operator uint32_t() const; // same as state
};
Each field is a set of Button bits.
state(orbuttonsitself)- The buttons held right now. Test with
buttons & Button::A. pressed,released- The buttons that changed since the previous call to
update(). They are worked out once per update, so read them inupdate(): there you see every press and release exactly once.
true if any of the given buttons is held: the same as buttons.state & button. Despite the name, it reports held buttons, not new presses; use buttons.pressed for those.
Button¶
enum Button : unsigned int {
DPAD_LEFT = 1,
DPAD_RIGHT = 2,
DPAD_UP = 4,
DPAD_DOWN = 8,
A = 16,
B = 32,
X = 64,
Y = 128,
MENU = 256,
HOME = 512,
JOYSTICK = 1024, // pressing the analog stick, on hardware that has one
};
On the VGC Zero:
| Button | Notes |
|---|---|
| D-pad, A, B, X, Y | yours to use |
| MENU | yours to use; a good pause button |
| HOME | reserved by ChiliChip OS for the system menu and quitting. It shows in buttons while held, but don't use it. |
| JOYSTICK | never set: the console has no analog stick |
Buttons are debounced by the firmware, so one physical press gives one pressed event.
Desktop key mappings are listed in Run on your computer.
Analog input¶
joystick- The analog stick,
xandyfrom -1 to 1. Always zero on the VGC Zero; on the desktop it follows a game controller's left stick. tilt- An accelerometer reading. Always zero on the VGC Zero.
hack_left,hack_right- Readings from the 32blit handheld's hack header. Not used on the VGC Zero.
Outputs¶
LED-
The status LED's colour. The VGC Zero has a single-colour LED on GPIO 16: it lights whenever any of
r,gorbis above 0, and alpha is ignored. vibration- Rumble strength from 0 to 1, on hardware with a vibration motor. The VGC Zero has none.