development:csdk:1.0:headers:input
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
development:csdk:1.0:headers:input [2024/11/08 01:57] – removed - external edit (Unknown date) 127.0.0.1 | development:csdk:1.0:headers:input [2024/11/08 02:54] (current) – clyde | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== 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. | ||
+ | <code C> | ||
+ | void update_inputs(); | ||
+ | </ | ||
+ | ==== Input-related Variables ==== | ||
+ | <code C> | ||
+ | extern int player1_buttons, | ||
+ | extern int player2_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' | ||
+ | |||
+ | ==== Mask Macros ==== | ||
+ | These macros are used for checking the state of a particular button in the _buttons variables. | ||
+ | |||
+ | <code C> | ||
+ | #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 | ||
+ | |||
+ | <code C> | ||
+ | if (player1_new_buttons & INPUT_MASK_A) { | ||
+ | //do something, idk jump | ||
+ | } | ||
+ | </ |