Manages and handles gamepads.
More...
#include <gamepad.h>
|
| | Gamepad (unsigned int device_id) |
| void | set_button_state (int button, bool state) |
| | Sets the state of a button.
|
| 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.
|
| void | play_rumble (float magnitude, unsigned int duration) |
| | Plays a rumble effect.
|
| void | stop_rumble () |
| | Stops the rumble effect.
|
|
| unsigned int | id |
| | The gamepad id. When a new gamepad 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.
|
| unsigned int | num_axes |
| | The number of axes the gamepad has.
|
| unsigned int | num_buttons |
| | The number of buttons the gamepad has.
|
| unsigned int | deadzone |
| | The axis deadzone.
|
| std::vector< int > | buttons_pressed |
| | A list of all buttons currently pressed.
|
Manages and handles gamepads.
- Note
- You should never have to create or delete objects of this class directly
Definition at line 14 of file gamepad.h.
◆ Gamepad()
| Gamepad::Gamepad |
( |
unsigned int | device_id | ) |
|
- Parameters
-
| device_id | The device id as provided by the SDL_CONTROLLERDEVICEADDED event |
Definition at line 8 of file gamepad.cpp.
◆ ~Gamepad()
◆ get_axis_value()
| int Gamepad::get_axis_value |
( |
unsigned int | axis | ) |
|
Call this function to get the current value of an axis.
- Parameters
-
| axis | The axis the value of which to get |
- Returns
- The current value of the axis in the range from 0 to 32767 for a trigger and -32768 to 32767 for an analog stick
Definition at line 76 of file gamepad.cpp.
◆ play_rumble()
| void Gamepad::play_rumble |
( |
float | magnitude, |
|
|
unsigned int | duration ) |
Plays a rumble effect.
- Parameters
-
| magnitude | The strength of the rumble on a scale from 0 to 1 |
| duration | The duration of the effect in milliseconds |
Definition at line 83 of file gamepad.cpp.
◆ set_button_state()
| void Gamepad::set_button_state |
( |
int | button, |
|
|
bool | state ) |
Sets the state of a button.
- Parameters
-
| button | The button the state of which is to be set |
| state | The new state of the button |
Definition at line 60 of file gamepad.cpp.
◆ set_deadzone()
| void Gamepad::set_deadzone |
( |
unsigned int | deadzone | ) |
|
Sets a dedzone for all axes.
- Parameters
-
Definition at line 72 of file gamepad.cpp.
◆ stop_rumble()
| void Gamepad::stop_rumble |
( |
| ) |
|
Stops the rumble effect.
Definition at line 89 of file gamepad.cpp.
◆ buttons_pressed
| std::vector<int> sgltk::Gamepad::buttons_pressed |
A list of all buttons currently pressed.
Definition at line 48 of file gamepad.h.
◆ deadzone
| unsigned int sgltk::Gamepad::deadzone |
The axis deadzone.
Definition at line 44 of file gamepad.h.
◆ id
| unsigned int sgltk::Gamepad::id |
The gamepad id. When a new gamepad is attached it is assigned the first free ID starting at 0.
Definition at line 27 of file gamepad.h.
◆ instance_id
| unsigned int sgltk::Gamepad::instance_id |
The instance ID of the gamepad as provided by an SDL2 event.
Definition at line 32 of file gamepad.h.
◆ num_axes
| unsigned int sgltk::Gamepad::num_axes |
The number of axes the gamepad has.
Definition at line 36 of file gamepad.h.
◆ num_buttons
| unsigned int sgltk::Gamepad::num_buttons |
The number of buttons the gamepad has.
Definition at line 40 of file gamepad.h.
The documentation for this class was generated from the following files:
- /home/fstdb/proj/sgltk_example/sgltk/src/gamepad.h
- /home/fstdb/proj/sgltk_example/sgltk/src/gamepad.cpp