User Tools

Site Tools


development:csdk:1.0:headers:input

input.h

Functions

update_inputs

This should be called once per frame, ideally right after a v-sync so that the timing is consistent. It updates the controller state variables for both players.

void update_inputs();
extern int player1_buttons, player1_old_buttons;
extern int player2_buttons, player2_old_buttons;

player1_buttons and player2_buttons show the current state of all buttons and directions.

player1_old_buttons and player2_old buttons show the last frame's state of all buttons and directions

Mask Macros

These macros are used for checking the state of a particular button in the _buttons variables.

#define INPUT_MASK_UP		2056
#define INPUT_MASK_DOWN		1028
#define INPUT_MASK_LEFT		512
#define INPUT_MASK_RIGHT	256
#define INPUT_MASK_A		16
#define INPUT_MASK_B		4096
#define INPUT_MASK_C		8192
#define INPUT_MASK_START	32

Example of how to check the state of a button

if (player1_new_buttons & INPUT_MASK_A) {
//do something, idk jump
}
development/csdk/1.0/headers/input.txt · Last modified: 2024/11/08 02:54 by clyde