29#ifndef NOMLIB_SYSTEM_JOYSTICK_HPP
30#define NOMLIB_SYSTEM_JOYSTICK_HPP
36#include "nomlib/config.hpp"
39typedef struct _SDL_Joystick SDL_Joystick;
43typedef int32 JoystickIndex;
46typedef int32 JoystickID;
52const nom::size_type GUID_MAX_LENGTH = 16;
60 uint8 data[GUID_MAX_LENGTH];
66const int16 JOYSTICK_LEFT_THUMB_DEAD_ZONE = 7849;
67const int16 JOYSTICK_RIGHT_THUMB_DEAD_ZONE = 8689;
68const int16 JOYSTICK_TRIGGER_THRESHOLD = 30;
75NOM_EXPORT
bool init_joystick_subsystem();
78NOM_EXPORT
void shutdown_joystick_subsystem();
81NOM_EXPORT
void JoystickDeleter(SDL_Joystick* dev);
84class NOM_EXPORT Joystick
143 HAT_RIGHTUP = (HAT_RIGHT | HAT_UP),
144 HAT_RIGHTDOWN = (HAT_RIGHT | HAT_DOWN),
145 HAT_LEFTUP = (HAT_LEFT | HAT_UP),
146 HAT_LEFTDOWN = (HAT_LEFT | HAT_DOWN),
187 bool open(JoystickIndex device_index);
266 static std::string
name(JoystickIndex device_index);
322 static JoystickID
device_id(JoystickIndex device_index);
325 typedef std::unique_ptr<SDL_Joystick, void (*)(SDL_Joystick*)> joystick_dev;
327 joystick_dev device_;
330NOM_EXPORT std::unique_ptr<Joystick> make_unique_joystick();
331NOM_EXPORT std::shared_ptr<Joystick> make_shared_joystick();
333NOM_EXPORT
JoystickGUID convert_SDL_JoystickGUID(SDL_JoystickGUID dev_guid);
334NOM_EXPORT SDL_JoystickGUID convert_SDL_JoystickGUID(
JoystickGUID dev_guid);
bool open(JoystickIndex device_index)
Open a joystick for use.
Button
Joystick button definitions.
static JoystickID device_id(JoystickIndex device_index)
Get the instance ID of a joystick device.
Hat
Joystick hat definitions.
JoystickID device_id() const
Get the instance ID of an opened joystick.
JoystickGUID device_guid() const
Get the implementation-dependent GUID for this joystick instance.
HatPosition
Joystick hat position definitions.
Axis
Joystick axis definitions.
static int set_event_state(int state)
Toggle the joystick event polling state.
void close()
Close an opened joystick.
static std::string device_guid_string(JoystickGUID guid)
Get the ASCII string representation of a joystick GUID.
bool attached() const
Get the status of the joystick.
SDL_Joystick * device() const
Get the underlying implementation pointer.
int num_buttons()
Get the number of buttons for this joystick.
static std::string name(JoystickIndex device_index)
Get the implementation-dependent name of the joystick.
int num_hats()
Get the number of POV hats for this joystick.
int num_axes()
Get the number of axes for this joystick.
static JoystickGUID device_guid(JoystickIndex device_index)
Get the implementation-dependent GUID for a joystick.
static void update()
Update the current state of the opened joysticks.
int num_track_balls()
Get the number of track balls for this joystick.
std::string name() const
Get the implementation-dependent name of the joystick.
std::string device_guid_string() const
Get the ASCII string representation of this joystick instance GUID.
static int num_joysticks()
Get the number of joysticks attached to the system.
Internal representation of a stable, fixed identifier – 128 bits wide – for a joystick device....