#include <class_gamepad.h>
Classes | |
struct | t_button |
Public Types | |
enum | e_type { AXIS, BUTTON } |
Public Member Functions | |
class_gamepad () | |
Class constructor. | |
int | CloseComm (void) |
int | Dispatch (bool debug=false) |
This function checks the gamepad status and calls the respective callback. | |
void | plerr (int ret) |
Print local error function This function prints the error present in the err variable (this is a private variable of the gamepad class). The ret number specifies what kind of error is this, -1 is a error that raises a SIGINT signal, -2 is an warning that allows the program to continue and -3 is a error that prints perror and raises SIGINT. | |
int | RegisterCallback (e_type type, int id, void(*callback)(int value, void *data), void *data) |
Register a callback for a specific button or axis. | |
int | StartComm (const char *device) |
Initialize comm with the gamepad. | |
int | UnRegisterCallback (e_type type, int id) |
~class_gamepad () | |
Class destructor. | |
Private Member Functions | |
int | GetButtonMapping (void) |
Get the button mapping from the device. | |
int | SetButtonMapping (void) |
Set the button mapping to the device. | |
Private Attributes | |
t_button * | axes |
t_button * | buttons |
char | err [1024] |
int | fd |
__u8 | m_axes [ABS_CNT] |
__u16 | m_buttons [KEY_MAX-BTN_MISC+1] |
int | n_axes |
int | n_buttons |
char | name [1024] |
int | ret |
char | text [1024] |
Definition at line 43 of file class_gamepad.h.
Definition at line 47 of file class_gamepad.h.
class_gamepad::class_gamepad | ( | ) |
Class constructor.
Definition at line 34 of file class_gamepad.cpp.
class_gamepad::~class_gamepad | ( | ) |
Class destructor.
Definition at line 42 of file class_gamepad.cpp.
int class_gamepad::CloseComm | ( | void | ) |
int class_gamepad::Dispatch | ( | bool | debug = false |
) |
This function checks the gamepad status and calls the respective callback.
debug | if set to true this function will print all events |
Definition at line 156 of file class_gamepad.cpp.
int class_gamepad::GetButtonMapping | ( | void | ) | [private] |
Get the button mapping from the device.
Definition at line 89 of file class_gamepad.cpp.
void class_gamepad::plerr | ( | int | ret | ) |
Print local error function This function prints the error present in the err variable (this is a private variable of the gamepad class). The ret number specifies what kind of error is this, -1 is a error that raises a SIGINT signal, -2 is an warning that allows the program to continue and -3 is a error that prints perror and raises SIGINT.
ret | error code |
Definition at line 188 of file class_gamepad.cpp.
int class_gamepad::RegisterCallback | ( | e_type | type, | |
int | id, | |||
void(*)(int value, void *data) | callback, | |||
void * | data | |||
) |
Register a callback for a specific button or axis.
type | AXIS or BUTTON (these enums are present in the gamepad class) | |
id | number of the button or axis * | |
callback | function to be called prototype is void (*callback)(int value,void*data), where the value is the button or axis value and data is the user data | |
data | user data to pass to the callback |
Definition at line 127 of file class_gamepad.cpp.
int class_gamepad::SetButtonMapping | ( | void | ) | [private] |
Set the button mapping to the device.
Definition at line 108 of file class_gamepad.cpp.
int class_gamepad::StartComm | ( | const char * | device | ) |
Initialize comm with the gamepad.
device | Name of the device to use |
Definition at line 47 of file class_gamepad.cpp.
int class_gamepad::UnRegisterCallback | ( | e_type | type, | |
int | id | |||
) |
t_button* class_gamepad::axes [private] |
Definition at line 117 of file class_gamepad.h.
t_button* class_gamepad::buttons [private] |
Definition at line 116 of file class_gamepad.h.
char class_gamepad::err[1024] [private] |
Definition at line 123 of file class_gamepad.h.
int class_gamepad::fd [private] |
Definition at line 113 of file class_gamepad.h.
__u8 class_gamepad::m_axes[ABS_CNT] [private] |
Definition at line 119 of file class_gamepad.h.
__u16 class_gamepad::m_buttons[KEY_MAX-BTN_MISC+1] [private] |
Definition at line 120 of file class_gamepad.h.
int class_gamepad::n_axes [private] |
Definition at line 115 of file class_gamepad.h.
int class_gamepad::n_buttons [private] |
Definition at line 114 of file class_gamepad.h.
char class_gamepad::name[1024] [private] |
Definition at line 122 of file class_gamepad.h.
int class_gamepad::ret [private] |
Definition at line 112 of file class_gamepad.h.
char class_gamepad::text[1024] [private] |
Definition at line 124 of file class_gamepad.h.