sgltk 0.6
Simple OpenGL Tool Kit
|
Manages and handles joysticks. More...
#include <joystick.h>
Public Member Functions | |
Joystick (unsigned int device_id) | |
void | set_button_state (int button, bool state) |
Sets the state of a button. | |
void | mark_switch (int button, bool mark=true) |
Marks or unmarks a button as a switch. Switches will not be added to the buttons_pressed list. | |
void | set_deadzone (unsigned int deadzone) |
Sets a dedzone for all axes. | |
int | get_axis_value (unsigned int axis) |
Call this function to get the current value of an axis. | |
unsigned int | get_hat_value (unsigned int hat) |
Call this function to get the current value of a hat. |
Public Attributes | |
unsigned int | id |
The joystick id. When a new joystick is attached it is assigned the first free ID starting at 0. | |
unsigned int | instance_id |
The instance ID of the gamepad as provided by an SDL2 event. | |
std::string | name |
The name of the joystick. | |
unsigned int | num_axes |
The number of axes the joystick has. | |
unsigned int | num_buttons |
The number of buttons the joystick has. | |
unsigned int | num_hats |
The number of hats the joystick has. | |
unsigned int | deadzone |
The axis deadzone. | |
std::vector< int > | buttons_pressed |
A list of all buttons currently pressed. |
Manages and handles joysticks.
Definition at line 14 of file joystick.h.
Joystick::Joystick | ( | unsigned int | device_id | ) |
device_id | The device id as provided by the SDL_JOYDEVICEADDED event |
Definition at line 8 of file joystick.cpp.
Joystick::~Joystick | ( | ) |
Definition at line 38 of file joystick.cpp.
int Joystick::get_axis_value | ( | unsigned int | axis | ) |
Call this function to get the current value of an axis.
axis | The axis to get the value of |
Definition at line 79 of file joystick.cpp.
unsigned int Joystick::get_hat_value | ( | unsigned int | hat | ) |
Call this function to get the current value of a hat.
hat | The hat to get the value of |
Definition at line 86 of file joystick.cpp.
void Joystick::mark_switch | ( | int | button, |
bool | mark = true ) |
Marks or unmarks a button as a switch. Switches will not be added to the buttons_pressed list.
button | The button to mark or unmark |
mark | True to mark, false to unmark |
Definition at line 61 of file joystick.cpp.
void Joystick::set_button_state | ( | int | button, |
bool | state ) |
Sets the state of a button.
button | The button the state of which is to be set |
state | The new state of the button |
Definition at line 46 of file joystick.cpp.
void Joystick::set_deadzone | ( | unsigned int | deadzone | ) |
Sets a dedzone for all axes.
deadzone | The deadzone |
Definition at line 75 of file joystick.cpp.
std::vector<int> sgltk::Joystick::buttons_pressed |
A list of all buttons currently pressed.
Definition at line 55 of file joystick.h.
unsigned int sgltk::Joystick::deadzone |
The axis deadzone.
Definition at line 51 of file joystick.h.
unsigned int sgltk::Joystick::id |
The joystick id. When a new joystick is attached it is assigned the first free ID starting at 0.
Definition at line 26 of file joystick.h.
unsigned int sgltk::Joystick::instance_id |
The instance ID of the gamepad as provided by an SDL2 event.
Definition at line 31 of file joystick.h.
std::string sgltk::Joystick::name |
The name of the joystick.
Definition at line 35 of file joystick.h.
unsigned int sgltk::Joystick::num_axes |
The number of axes the joystick has.
Definition at line 39 of file joystick.h.
unsigned int sgltk::Joystick::num_buttons |
The number of buttons the joystick has.
Definition at line 43 of file joystick.h.
unsigned int sgltk::Joystick::num_hats |
The number of hats the joystick has.
Definition at line 47 of file joystick.h.