FPLBase
An open source project by
FPL.
|
Represents the state of a Joystick. More...
#include <input.h>
Represents the state of a Joystick.
Public Member Functions | |
Button & | GetButton (size_t button_index) |
Get the current state of a button. More... | |
float | GetAxis (size_t axis_index) |
Get the current state of a joystick axis control. More... | |
mathfu::vec2 | GetHat (size_t hat_index) |
Get the current state of a joystick hat control. More... | |
void | SetAxis (size_t axis_index, float axis) |
Sets the value of an axis. More... | |
void | SetHat (size_t hat_index, const mathfu::vec2 &hat) |
Sets the position of a hat. More... | |
void | AdvanceFrame () |
Updates the internal state of the joystick by one frame. More... | |
JoystickData | joystick_data () |
Returns the pointer to the raw joystick data. More... | |
void | set_joystick_data (JoystickData joy) |
Sets the pointer to the raw joystick data. More... | |
JoystickId | GetJoystickId () const |
Gets the ID of the joystick. More... | |
int | GetNumButtons () const |
Returns the number of buttons available on the joystick. | |
int | GetNumAxes () const |
Returns the number of control axes available on the joystick. | |
int | GetNumHats () const |
Returns the number of hats available on the joystick. | |
void fplbase::Joystick::AdvanceFrame | ( | ) |
Updates the internal state of the joystick by one frame.
This function ensures that the joystick readings are up-to-date, and that buttons have their change-bits set correctly. Normally called automatically by InputSystem::AdvanceFrame().
float fplbase::Joystick::GetAxis | ( | size_t | axis_index | ) |
Get the current state of a joystick axis control.
axis_index | The index of the axis to querry. |
Button& fplbase::Joystick::GetButton | ( | size_t | button_index | ) |
Get the current state of a button.
button_index | The index of the button to querry. |
mathfu::vec2 fplbase::Joystick::GetHat | ( | size_t | hat_index | ) |
Get the current state of a joystick hat control.
hat_index | The index of the hat to querry. |
The returned vector will always have an X, Y component of -1, 0, or 1. (And thus will always be pointing in one of 8 possible directions, or in the neutral position.)
JoystickId fplbase::Joystick::GetJoystickId | ( | ) | const |
|
inline |
Returns the pointer to the raw joystick data.
The type and layout of the joystick_data are implementation specific, and should not generally be used by code outside of the FPLBase library.
|
inline |
Sets the pointer to the raw joystick data.
joy | A pointer to the joystick data. |
The type and layout of the joystick_data are implementation specific, and should not generally be used by code outside of the FPLBase library.
void fplbase::Joystick::SetAxis | ( | size_t | axis_index, |
float | axis | ||
) |
Sets the value of an axis.
axis_index | The index of the axis to modify. |
axis | The new value to record for the axis. |
Normally only called by input handlers in the Input class.
void fplbase::Joystick::SetHat | ( | size_t | hat_index, |
const mathfu::vec2 & | hat | ||
) |
Sets the position of a hat.
hat_index | The index of the hat to modify. |
hat | The new value to record for the hat. |
Normally only called by input handlers in the Input class.