KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
Querying Inputs

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.
 

Detailed Description

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.")

Macro Definition Documentation

◆ CONT_RESET_BUTTONS

#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 Documentation

◆ cont_btn_callback_t

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.

Parameters
addrMaple BUS address to poll for the button mask on, or 0 for all ports.
btnsMask of all buttons which should be pressed to trigger the callback.
See also
cont_btn_callback

Function Documentation

◆ cont_btn_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.

Note
The callback gets invoked for the given maple port; however, providing an address of '0' will cause it to be invoked for any port with a device pressing the given buttons. Since you are passed back the address of this device, You are free to implement your own filtering logic within your callback. Any callback with addr==0 will be installed to the end of the list of callbacks and will run after callbacks with the same btns but a specified address.
Parameters
addrThe controller to listen on (or 0 for all ports). This value can be obtained by using maple_addr().
btnsThe buttons bitmask to match.
cbThe callback to call when the buttons are pressed. Passing NULL will uninstall all callbacks on the addr/btns combination.