Reading Controllers

Reading controllers on the GameTank requires to add #include “input.h” as an include file. The API is pretty straighforward:

update_inputs();
if (player1_buttons & INPUT_MASK_LEFT) {
  ...
} else if (player1_buttons & INPUT_MASK_RIGHT) {
  ...
}
if (player1_buttons & INPUT_MASK_UP) {
  ...
} else if (player1_buttons & INPUT_MASK_DOWN) {
  ...
}
// players_old_buttons is used to make sure users press and release the button
if (player_buttons & ~player_old_buttons & INPUT_MASK_A) {
   ...
}

Testing in the Emulator