development:csdk:2.0:controllers
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 (player1_buttons & ~player1_old_buttons & INPUT_MASK_A) { ... } // players_new_buttons is also provided for convenience if (player1_new_buttons & INPUT_MASK_B) { ... }
Testing in the Emulator
- The first controller is using the arrow key for directions and ZXC for the buttons
- The second controller is using TFGH for directions and Tab QW for the buttons
development/csdk/2.0/controllers.txt · Last modified: 2024/11/20 21:49 by clyde