Access to joysticks and gamepads (read buttons and position), and request number of joysticks in the system.
Definition at line 25 of file CJoystick.h.
#include <mrpt/hwdrivers/CJoystick.h>
Public Member Functions | |
CJoystick () | |
Constructor. More... | |
virtual | ~CJoystick () |
Destructor. More... | |
bool | getJoystickPosition (int nJoy, float &x, float &y, float &z, std::vector< bool > &buttons, int *raw_x_pos=NULL, int *raw_y_pos=NULL, int *raw_z_pos=NULL) |
Gets joystick information. More... | |
void | setLimits (int x_min=-32767, int x_max=32767, int y_min=-32767, int y_max=32767, int z_min=-32767, int z_max=32767) |
Set the axis limit values, for computing a [-1,1] position index easily (Only required to calibrate analog joystick). More... | |
Static Public Member Functions | |
static int | getJoysticksCount () |
Returns the number of Joysticks in the computer. More... | |
Private Attributes | |
int | m_x_min |
The axis limits: More... | |
int | m_x_max |
int | m_y_min |
int | m_y_max |
int | m_z_min |
int | m_z_max |
CJoystick::CJoystick | ( | ) |
Constructor.
Definition at line 51 of file CJoystick.cpp.
|
virtual |
Destructor.
Definition at line 64 of file CJoystick.cpp.
bool CJoystick::getJoystickPosition | ( | int | nJoy, |
float & | x, | ||
float & | y, | ||
float & | z, | ||
std::vector< bool > & | buttons, | ||
int * | raw_x_pos = NULL , |
||
int * | raw_y_pos = NULL , |
||
int * | raw_z_pos = NULL |
||
) |
Gets joystick information.
This method will try first to open the joystick, so you can safely call it while the joystick is plugged and removed arbitrarly.
nJoy | The index of the joystick to query: The first one is 0, the second 1, etc... See CJoystick::getJoysticksCount to discover the number of joysticks in the system. |
x | The x axis position, range [-1,1] |
y | The y axis position, range [-1,1] |
z | The z axis position, range [-1,1] |
buttons | Each element will hold true if buttons are pressed. The size of the vector will be set automatically to the number of buttons. |
raw_x_pos | If it is desired the raw integer measurement from JoyStick, set this pointer to a desired placeholder. |
raw_y_pos | If it is desired the raw integer measurement from JoyStick, set this pointer to a desired placeholder. |
raw_z_pos | If it is desired the raw integer measurement from JoyStick, set this pointer to a desired placeholder. |
Definition at line 113 of file CJoystick.cpp.
References mrpt::format(), m_x_max, m_x_min, m_y_max, m_y_min, m_z_max, m_z_min, MRPT_END, and MRPT_START.
|
static |
Returns the number of Joysticks in the computer.
Definition at line 80 of file CJoystick.cpp.
References mrpt::format(), MRPT_END, and MRPT_START.
void CJoystick::setLimits | ( | int | x_min = -32767 , |
int | x_max = 32767 , |
||
int | y_min = -32767 , |
||
int | y_max = 32767 , |
||
int | z_min = -32767 , |
||
int | z_max = 32767 |
||
) |
Set the axis limit values, for computing a [-1,1] position index easily (Only required to calibrate analog joystick).
Set the axis limit values, for computing a [-1,1] position index easily.
It seems that these values must been calibrated for each joystick model.
Definition at line 246 of file CJoystick.cpp.
References m_x_max, m_x_min, m_y_max, m_y_min, m_z_max, and m_z_min.
|
private |
Definition at line 30 of file CJoystick.h.
Referenced by getJoystickPosition(), and setLimits().
|
private |
The axis limits:
Definition at line 30 of file CJoystick.h.
Referenced by getJoystickPosition(), and setLimits().
|
private |
Definition at line 30 of file CJoystick.h.
Referenced by getJoystickPosition(), and setLimits().
|
private |
Definition at line 30 of file CJoystick.h.
Referenced by getJoystickPosition(), and setLimits().
|
private |
Definition at line 30 of file CJoystick.h.
Referenced by getJoystickPosition(), and setLimits().
|
private |
Definition at line 30 of file CJoystick.h.
Referenced by getJoystickPosition(), and setLimits().
Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019 |