29#ifndef NOMLIB_SYSTEM_JOYSTICK_HPP
30#define NOMLIB_SYSTEM_JOYSTICK_HPP
35#include "nomlib/config.hpp"
38typedef struct _SDL_Joystick SDL_Joystick;
42typedef int32 JoystickIndex;
45typedef int32 JoystickID;
51const nom::size_type GUID_MAX_LENGTH = 16;
59 uint8 data[GUID_MAX_LENGTH];
65const int16 JOYSTICK_LEFT_THUMB_DEAD_ZONE = 7849;
66const int16 JOYSTICK_RIGHT_THUMB_DEAD_ZONE = 8689;
67const int16 JOYSTICK_TRIGGER_THRESHOLD = 30;
74bool init_joystick_subsystem();
77void shutdown_joystick_subsystem();
80void JoystickDeleter(SDL_Joystick* dev);
142 HAT_RIGHTUP = (HAT_RIGHT | HAT_UP),
143 HAT_RIGHTDOWN = (HAT_RIGHT | HAT_DOWN),
144 HAT_LEFTUP = (HAT_LEFT | HAT_UP),
145 HAT_LEFTDOWN = (HAT_LEFT | HAT_DOWN),
186 bool open(JoystickIndex device_index);
265 static std::string
name(JoystickIndex device_index);
321 static JoystickID
device_id(JoystickIndex device_index);
324 typedef std::unique_ptr<SDL_Joystick, void (*)(SDL_Joystick*)> joystick_dev;
326 joystick_dev device_;
329std::unique_ptr<Joystick> make_unique_joystick();
330std::shared_ptr<Joystick> make_shared_joystick();
332JoystickGUID convert_SDL_JoystickGUID(SDL_JoystickGUID dev_guid);
333SDL_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....