SDL2 game controller interface.
More...
#include <GameController.hpp>
|
| enum | Axis : int8 {
AXIS_INVALID = -1
, AXIS_LEFT_X
, AXIS_LEFT_Y
, AXIS_RIGHT_X
,
AXIS_RIGHT_Y
, AXIS_TRIGGER_LEFT
, AXIS_TRIGGER_RIGHT
, AXIS_MAX
} |
| | Game controller axis definitions. More...
|
| enum | Button : int8 {
BUTTON_INVALID = -1
, BUTTON_A
, BUTTON_B
, BUTTON_X
,
BUTTON_Y
, BUTTON_BACK
, BUTTON_GUIDE
, BUTTON_START
,
BUTTON_LEFT_STICK
, BUTTON_RIGHT_STICK
, BUTTON_LEFT_SHOULDER
, BUTTON_RIGHT_SHOULDER
,
BUTTON_DPAD_UP
, BUTTON_DPAD_DOWN
, BUTTON_DPAD_LEFT
, BUTTON_DPAD_RIGHT
,
BUTTON_MAX = SDL_CONTROLLER_BUTTON_MAX
} |
| | Game controller button definitions. More...
|
| typedef GameController | self_type |
|
| SDL_Joystick * | device () const |
| | Get the underlying implementation pointer.
|
| bool | attached () const |
| | Get the status of the joystick.
|
| JoystickID | device_id () const |
| | Get the instance ID of an opened game controller.
|
| std::string | name () const |
| | Get the implementation-dependent name of the joystick.
|
| bool | open (JoystickIndex device_index) |
| | Open a joystick for use.
|
| void | close () |
| | Close an opened joystick.
|
|
std::string | mapping_string () |
|
| static std::string | name (JoystickIndex device_index) |
| | Get the implementation-dependent name of the joystick.
|
| static int | set_event_state (int state) |
| | Toggle the game controller's event polling state.
|
| static void | update () |
| | Update the current state of the opened game controllers.
|
| static std::string | mapping_string (JoystickGUID guid) |
| static int | load_mapping_memory (const char *buffer, int buffer_size) |
| static int | load_mapping_file (const std::string &filename) |
|
static int | load_mapping_string (const std::string &mapping) |
| static JoystickID | device_id (JoystickIndex device_index) |
| | Get the instance ID of a joystick device.
|
|
static bool | compatible_joystick (JoystickIndex device_index) |
| | Check to see if the joystick is supported by SDL's game controller interface.
|
|
| typedef std::unique_ptr< SDL_GameController, void(*)(SDL_GameController *)> | joystick_dev |
SDL2 game controller interface.
[DESCRIPTION STUB]
Definition at line 55 of file GameController.hpp.
◆ joystick_dev
| typedef std::unique_ptr<SDL_GameController, void (*)(SDL_GameController*)> nom::GameController::joystick_dev |
|
private |
◆ self_type
| typedef GameController nom::GameController::self_type |
◆ Axis
◆ Button
◆ attached()
| bool nom::GameController::attached |
( |
| ) |
const |
Get the status of the joystick.
- Returns
- Boolean TRUE if the joystick has been opened, and boolean FALSE if it has not been opened.
◆ close()
| void nom::GameController::close |
( |
| ) |
|
Close an opened joystick.
◆ device()
| SDL_Joystick * nom::GameController::device |
( |
| ) |
const |
Get the underlying implementation pointer.
- Returns
- A non-owned pointer to the underlying implementation.
◆ device_id() [1/2]
| JoystickID nom::GameController::device_id |
( |
| ) |
const |
Get the instance ID of an opened game controller.
- Returns
- The device instance ID for the game controller device on success, and a negative error code on failure.
◆ device_id() [2/2]
| JoystickID nom::GameController::device_id |
( |
JoystickIndex | device_index | ) |
|
|
static |
Get the instance ID of a joystick device.
- Parameters
-
| device_index | The index of the joystick device, as recognized by SDL. |
- Returns
- The device instance ID for the joystick device on success, and a negative error code on failure.
- See also
- Joystick::num_joysticks
◆ load_mapping_file()
| int nom::GameController::load_mapping_file |
( |
const std::string & | filename | ) |
|
|
static |
- Todo
- This function call leaks memory from within SDL!
◆ load_mapping_memory()
| int nom::GameController::load_mapping_memory |
( |
const char * | buffer, |
|
|
int | buffer_size ) |
|
static |
- Todo
- Implement this function
◆ mapping_string()
| std::string nom::GameController::mapping_string |
( |
JoystickGUID | guid | ) |
|
|
static |
◆ name() [1/2]
| std::string nom::GameController::name |
( |
| ) |
const |
Get the implementation-dependent name of the joystick.
- Returns
- The name of the joystick on success, and a null-terminated string on failure, such as an invalid device state.
◆ name() [2/2]
| std::string nom::GameController::name |
( |
JoystickIndex | device_index | ) |
|
|
static |
Get the implementation-dependent name of the joystick.
- Parameters
-
| device_index | The index of the joystick device, as recognized by SDL. |
- Returns
- The name of the indexed joystick on success, and a zero-length string on failure, such as when no name for the device index can be found.
- See also
- Joystick::num_joysticks
◆ open()
| bool nom::GameController::open |
( |
JoystickIndex | device_index | ) |
|
Open a joystick for use.
- Parameters
-
| device_index | The device index of the joystick as recognized by SDL. |
- See also
- Joystick::num_joysticks
◆ set_event_state()
| int nom::GameController::set_event_state |
( |
int | state | ) |
|
|
static |
Toggle the game controller's event polling state.
- Parameters
-
| state | One of the following: SDL_QUERY, SDL_IGNORE or SDL_ENABLE. |
- Returns
- One (1) if enabled, zero (0) if disabled or a negative error code on failure. If the state was SDL_QUERY, then the current state is returned, otherwise the new processing state is returned.
- Note
- This does not disable the underlying joystick events.
- See also
- Joystick::set_event_state
◆ update()
| void nom::GameController::update |
( |
| ) |
|
|
static |
Update the current state of the opened game controllers.
◆ device_
| joystick_dev nom::GameController::device_ |
|
private |
◆ device_closed_
| bool nom::GameController::device_closed_ |
|
static |
The documentation for this class was generated from the following file: