29#ifndef NOMLIB_SYSTEM_GAME_CONTROLLER_HPP
30#define NOMLIB_SYSTEM_GAME_CONTROLLER_HPP
33#include "nomlib/config.hpp"
34#include "nomlib/system/Joystick.hpp"
37typedef struct _SDL_Joystick SDL_Joystick;
38typedef struct _SDL_GameController SDL_GameController;
47NOM_EXPORT
bool init_game_controller_subsystem();
50NOM_EXPORT
void shutdown_game_controller_subsystem();
53NOM_EXPORT
void GameControllerDeleter(SDL_GameController* dev);
56class NOM_EXPORT GameController
86 BUTTON_RIGHT_SHOULDER,
91 BUTTON_MAX = SDL_CONTROLLER_BUTTON_MAX,
99 NOM_EXPORT
static bool device_closed_;
139 bool open(JoystickIndex device_index);
157 NOM_EXPORT
static std::string
name(JoystickIndex device_index);
182 std::string mapping_string();
194 NOM_EXPORT
static int load_mapping_string(
const std::string& mapping);
207 NOM_EXPORT
static JoystickID
device_id(JoystickIndex device_index);
214 typedef std::unique_ptr<SDL_GameController, void (*)(SDL_GameController*)>
217 joystick_dev device_;
220NOM_EXPORT std::unique_ptr<GameController> make_unique_game_controller();
221NOM_EXPORT std::shared_ptr<GameController> make_shared_game_controller();
SDL2 game controller interface.
static NOM_EXPORT std::string name(JoystickIndex device_index)
Get the implementation-dependent name of the joystick.
static NOM_EXPORT JoystickID device_id(JoystickIndex device_index)
Get the instance ID of a joystick device.
JoystickID device_id() const
Get the instance ID of an opened game controller.
bool open(JoystickIndex device_index)
Open a joystick for use.
static NOM_EXPORT std::string mapping_string(JoystickGUID guid)
SDL_Joystick * device() const
Get the underlying implementation pointer.
Button
Game controller button definitions.
std::string name() const
Get the implementation-dependent name of the joystick.
static NOM_EXPORT int load_mapping_memory(const char *buffer, int buffer_size)
static NOM_EXPORT void update()
Update the current state of the opened game controllers.
static NOM_EXPORT int load_mapping_file(const std::string &filename)
Axis
Game controller axis definitions.
bool attached() const
Get the status of the joystick.
void close()
Close an opened joystick.
static NOM_EXPORT bool compatible_joystick(JoystickIndex device_index)
Check to see if the joystick is supported by SDL's game controller interface.
static NOM_EXPORT int set_event_state(int state)
Toggle the game controller's event polling state.
Internal representation of a stable, fixed identifier – 128 bits wide – for a joystick device....