development:csdk:1.0:headers:input
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
development:csdk:1.0:headers:input [2024/11/08 01:57] – ↷ Page moved from development:csdk:headers:input to development:csdk:1.0:headers:input clyde | development:csdk:1.0:headers:input [2024/11/08 02:54] (current) – clyde | ||
---|---|---|---|
Line 2: | Line 2: | ||
===== Functions ===== | ===== Functions ===== | ||
==== update_inputs ==== | ==== 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> | <code C> | ||
void update_inputs(); | 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 | ||
+ | } | ||
+ | </ |
development/csdk/1.0/headers/input.1731031056.txt.gz · Last modified: 2024/11/08 01:57 by clyde