KallistiOS git master
Independent SDK for the Sega Dreamcast
|
API used to query for input state More...
Topics | |
Inputs | |
Collection of all status masks for checking input | |
Data Structures | |
struct | cont_state_t |
Controller state structure. More... | |
Macros | |
#define | CONT_RESET_BUTTONS (CONT_A | CONT_B | CONT_X | CONT_Y | CONT_START) |
Controller buttons for standard reset action. | |
Typedefs | |
typedef void(* | cont_btn_callback_t) (uint8_t addr, uint32_t btns) |
Controller automatic callback type. | |
Functions | |
int | cont_btn_callback (uint8_t addr, uint32_t btns, cont_btn_callback_t cb) |
Set an automatic button press callback. | |
API used to query for input state
The following API is used to check for a controller's input state.
You can grab a controller's state structure, containing the state of all of its inputs by using:
cont_state_t *state = (cont_state_t *)maple_dev_status(device);
Next you can check for the state of a particular button with:
if(state->a) // Check via bitfield printf("Pressed A".);
or
if(state->buttons & CONT_A) // Check via applying bitmask printf("Pressed A.")
#define CONT_RESET_BUTTONS (CONT_A | CONT_B | CONT_X | CONT_Y | CONT_START) |
Controller buttons for standard reset action.
Convenience macro providing the standard button combination used as a reset mechanism by most retail games.
typedef void(* cont_btn_callback_t) (uint8_t addr, uint32_t btns) |
Controller automatic callback type.
Functions of this type can be set with cont_btn_callback() to respond automatically to the specified set of buttons being pressed. This can be used, for instance, to implement the standard A+B+X+Y+Start method of ending the program running.
addr | Maple BUS address to poll for the button mask on, or 0 for all ports. |
btns | Mask of all buttons which should be pressed to trigger the callback. |
int cont_btn_callback | ( | uint8_t | addr, |
uint32_t | btns, | ||
cont_btn_callback_t | cb ) |
Set an automatic button press callback.
This function sets a callback function to be called when the specified controller has the set of buttons given pressed.
addr | The controller to listen on (or 0 for all ports). This value can be obtained by using maple_addr(). |
btns | The buttons bitmask to match. |
cb | The callback to call when the buttons are pressed. Passing NULL will uninstall all callbacks on the addr/btns combination. |