Give access to the state of the joysticks. More...
#include <Joystick.h>
Classes | |
struct | Identification |
Stores a joystick's identification. More... | |
Public Types | |
enum | { Count = 8 , ButtonCount = 32 , AxisCount = 8 } |
Joystick related constants. More... | |
enum class | Axis { X , Y , Z , R , U , V , PovX , PovY } |
Axes supported by IME joysticks. More... | |
Public Member Functions | |
Joystick (unsigned int index) | |
bool | isConnected () const |
Check if the joystick is connected or not. More... | |
void | setEnable (bool enable) |
Enable or disable the joystick. More... | |
bool | isEnabled () const |
Check if the joystick is enabled or not. More... | |
unsigned int | getIndex () const |
Get the id of the joystick. More... | |
unsigned int | getButtonCount () const |
Get the number of buttons supported by the joystick. More... | |
bool | hasAxis (Axis axis) const |
Check if a joystick supports a given axis. More... | |
bool | isButtonPressed (unsigned int button) const |
Check if a button is pressed or not. More... | |
float | getAxisPosition (Axis axis) const |
Get the current position of an axis. More... | |
Identification | getIdentification () const |
Get the joystick's identification information. More... | |
int | onConnect (const Callback<> &callback) |
Add an event listener to a connection event. More... | |
int | onDisconnect (const Callback<> &callback) |
Add an event listener to a disconnection event. More... | |
int | onButtonPress (const Callback< unsigned int > &callback) |
Add an event listener to a button press event. More... | |
int | onButtonRelease (const Callback< unsigned int > &callback) |
Add an event listener to button release event. More... | |
int | onButtonHeld (const Callback< unsigned int > &callback) |
Add an event listener to button held event. More... | |
int | onAxisMove (const Callback< Axis, float > &callback) |
Add an event listener to an axis move event. More... | |
bool | unsubscribe (JoystickEvent event, int id) |
Remove an event listener from a joystick event. More... | |
void | handleEvent (Event event) |
void | update () |
Give access to the state of the joysticks.
This class is not meant to be instantiated directly, use ime::Scene::getInput or ime::Engine::getInputManager
Definition at line 53 of file Joystick.h.
anonymous enum |
Joystick related constants.
Enumerator | |
---|---|
Count | Maximum number of supported joysticks. |
ButtonCount | Maximum number of supported buttons. |
AxisCount | Maximum number of supported axes. |
Definition at line 58 of file Joystick.h.
|
strong |
Axes supported by IME joysticks.
Enumerator | |
---|---|
X | The X axis. |
Y | The Y axis. |
Z | The Z axis. |
R | The R axis. |
U | The U axis. |
V | The V axis. |
PovX | The X axis of the point-of-view hat. |
PovY | The Y axis of the point-of-view hat. |
Definition at line 67 of file Joystick.h.
float ime::input::Joystick::getAxisPosition | ( | Axis | axis | ) | const |
Get the current position of an axis.
axis | The axis to get the position of |
If the joystick is not connected, this function returns 0
This function checks the position in real time, unlike all the other function which are event-based
unsigned int ime::input::Joystick::getButtonCount | ( | ) | const |
Get the number of buttons supported by the joystick.
If the joystick is not connected, this function returns 0.
Identification ime::input::Joystick::getIdentification | ( | ) | const |
Get the joystick's identification information.
joystick | Index of the joystick |
unsigned int ime::input::Joystick::getIndex | ( | ) | const |
Get the id of the joystick.
bool ime::input::Joystick::hasAxis | ( | Axis | axis | ) | const |
Check if a joystick supports a given axis.
axis | The axis to be checked |
If the joystick is not connected, this function returns false
bool ime::input::Joystick::isButtonPressed | ( | unsigned int | button | ) | const |
Check if a button is pressed or not.
button | Button to be checked |
If the joystick is not connected, this function returns false
This function checks the state of a button in real time, unlike all the other function which are event-based
bool ime::input::Joystick::isConnected | ( | ) | const |
Check if the joystick is connected or not.
This function checks the state of the joystick in real time, unlike all the other function which are event-based
bool ime::input::Joystick::isEnabled | ( | ) | const |
Check if the joystick is enabled or not.
Add an event listener to an axis move event.
callback | The function to be executed when an axis is moved |
The callback is passed the axis that was moved and its new position respectively
int ime::input::Joystick::onButtonHeld | ( | const Callback< unsigned int > & | callback | ) |
Add an event listener to button held event.
callback | The function to be executed when a button is held |
The callback is passed the button that is held
int ime::input::Joystick::onButtonPress | ( | const Callback< unsigned int > & | callback | ) |
Add an event listener to a button press event.
callback | The function to be executed when a button is pressed |
A button press event does not fire while the button is held down
The callback is passed the button that was pressed
int ime::input::Joystick::onButtonRelease | ( | const Callback< unsigned int > & | callback | ) |
Add an event listener to button release event.
callback | The function to be executed when a button is released |
The callback is passed the button that was released
int ime::input::Joystick::onConnect | ( | const Callback<> & | callback | ) |
Add an event listener to a connection event.
callback | Function to be executed when the joystick is connected |
int ime::input::Joystick::onDisconnect | ( | const Callback<> & | callback | ) |
Add an event listener to a disconnection event.
callback | Function to be executed when a joystick is disconnected |
void ime::input::Joystick::setEnable | ( | bool | enable | ) |
Enable or disable the joystick.
enable | True to enabled or false to disable |
When disabled, the joystick will no longer generate button press, button release and axis move events. Connect and disconnect events are dispatched regardless of the 'enable' state of the joystick
By default the joystick is enabled
bool ime::input::Joystick::unsubscribe | ( | JoystickEvent | event, |
int | id | ||
) |
Remove an event listener from a joystick event.
event | The event to remove the event listener from |
id | The event listeners identification number |