input.h

This header contains all functions to read gamepad inputs


General gamepad functions

Function: select_gamepad
Prototype: void select_gamepad( int gamepad_id )
Description: Sets the selected gamepad to the given gamepad ID. All gamepad functions will apply to that gamepad from that moment.
Arguments:
int gamepad_id ID of the gamepad to select
Function: get_selected_gamepad
Prototype: int get_selected_gamepad()
Description: Gets ID of the currently selected gamepad
Returns:
int ID of selected gamepad (from 0 to 3)
Function: gamepad_is_connected
Prototype: bool gamepad_is_connected()
Description: Determines if the currently selected gamepad is connected to the console
Returns:
bool True when connected, false if not

Reading D-Pad direction

Function: gamepad_left
Prototype: int gamepad_left()
Description: Obtains the state of the left direction in the currently selected gamepad
Returns:
int An integer value guaranteed to never be 0. Its sign indicates: positive = pressed, negative = not pressed. Its value is the number of frames it has been in that state
Function: gamepad_right
Prototype: int gamepad_right()
Description: Obtains the state of the right direction in the currently selected gamepad
Returns:
int An integer value guaranteed to never be 0. Its sign indicates: positive = pressed, negative = not pressed. Its value is the number of frames it has been in that state
Function: gamepad_up
Prototype: int gamepad_up()
Description: Obtains the state of the up direction in the currently selected gamepad
Returns:
int An integer value guaranteed to never be 0. Its sign indicates: positive = pressed, negative = not pressed. Its value is the number of frames it has been in that state
Function: gamepad_down
Prototype: int gamepad_down()
Description: Obtains the state of the down direction in the currently selected gamepad
Returns:
int An integer value guaranteed to never be 0. Its sign indicates: positive = pressed, negative = not pressed. Its value is the number of frames it has been in that state
Function: gamepad_direction
Prototype: void gamepad_direction( int* delta_x, int* delta_y )
Description: Obtains the pressed D-Pad direction in the currently selected gamepad. The result is stored in a pair of variables that form a 2D vector (X and Y)
Arguments:
int* delta_x Direction along X axis. Either -1 (left), 0 (center) or 1 (right)
int* delta_y Direction along Y axis. Either -1 (up), 0 (center) or 1 (down)
Function: gamepad_direction_normalized
Prototype: void gamepad_direction_normalized( float* delta_x, float* delta_y )
Description: Similar to gamepad_direction, but when a diagonal is pressed the result vector is normalized to have length of 1
Arguments:
float* delta_x Direction along X axis. It is in range -1 (left) to 1 (right)
float* delta_y Direction along Y axis. It is in range -1 (up) to 1 (down)

Reading gamepad buttons

Function: gamepad_button_a
Prototype: int gamepad_button_a()
Description: Obtains the state of the button A in the currently selected gamepad
Returns:
int An integer value guaranteed to never be 0. Its sign indicates: positive = pressed, negative = not pressed. Its value is the number of frames it has been in that state
Function: gamepad_button_b
Prototype: int gamepad_button_b()
Description: Obtains the state of the button B in the currently selected gamepad
Returns:
int An integer value guaranteed to never be 0. Its sign indicates: positive = pressed, negative = not pressed. Its value is the number of frames it has been in that state
Function: gamepad_button_x
Prototype: int gamepad_button_x()
Description: Obtains the state of the button X in the currently selected gamepad
Returns:
int An integer value guaranteed to never be 0. Its sign indicates: positive = pressed, negative = not pressed. Its value is the number of frames it has been in that state
Function: gamepad_button_y
Prototype: int gamepad_button_y()
Description: Obtains the state of the button Y in the currently selected gamepad
Returns:
int An integer value guaranteed to never be 0. Its sign indicates: positive = pressed, negative = not pressed. Its value is the number of frames it has been in that state
Function: gamepad_button_l
Prototype: int gamepad_button_l()
Description: Obtains the state of the button L in the currently selected gamepad
Returns:
int An integer value guaranteed to never be 0. Its sign indicates: positive = pressed, negative = not pressed. Its value is the number of frames it has been in that state
Function: gamepad_button_r
Prototype: int gamepad_button_r()
Description: Obtains the state of the button R in the currently selected gamepad
Returns:
int An integer value guaranteed to never be 0. Its sign indicates: positive = pressed, negative = not pressed. Its value is the number of frames it has been in that state
Function: gamepad_button_start
Prototype: int gamepad_button_start()
Description: Obtains the state of the button Start in the currently selected gamepad
Returns:
int An integer value guaranteed to never be 0. Its sign indicates: positive = pressed, negative = not pressed. Its value is the number of frames it has been in that state