Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
class_gamepad Class Reference

#include <class_gamepad.h>

Classes

struct  t_button
 

Public Types

enum  e_type { AXIS, BUTTON }
 

Public Member Functions

 class_gamepad ()
 Class constructor. More...
 
int CloseComm (void)
 
int Dispatch (bool debug=false)
 This function checks the gamepad status and calls the respective callback. More...
 
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. More...
 
int RegisterCallback (e_type type, int id, void(*callback)(int value, void *data), void *data)
 Register a callback for a specific button or axis. More...
 
int StartComm (const char *device)
 Initialize comm with the gamepad. More...
 
int UnRegisterCallback (e_type type, int id)
 
 ~class_gamepad ()
 Class destructor. More...
 

Private Member Functions

int GetButtonMapping (void)
 Get the button mapping from the device. More...
 
int SetButtonMapping (void)
 Set the button mapping to the device. More...
 

Private Attributes

t_buttonaxes
 
t_buttonbuttons
 
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]
 

Detailed Description

Definition at line 43 of file class_gamepad.h.

Member Enumeration Documentation

Enumerator
AXIS 
BUTTON 

Definition at line 47 of file class_gamepad.h.

Constructor & Destructor Documentation

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.

Member Function Documentation

int class_gamepad::CloseComm ( void  )
int class_gamepad::Dispatch ( bool  debug = false)

This function checks the gamepad status and calls the respective callback.

Parameters
debugif set to true this function will print all events
Returns
error code that can be analyzed with the function plerr

Definition at line 156 of file class_gamepad.cpp.

int class_gamepad::GetButtonMapping ( void  )
private

Get the button mapping from the device.

Returns
error code that can be analyzed with the function plerr

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.

Parameters
reterror code
Returns
void

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.

Parameters
typeAXIS or BUTTON (these enums are present in the gamepad class)
idnumber of the button or axis *
callbackfunction 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
datauser data to pass to the callback
Returns
error code that can be analyzed with the function plerr

Definition at line 127 of file class_gamepad.cpp.

int class_gamepad::SetButtonMapping ( void  )
private

Set the button mapping to the device.

Returns
error code that can be analyzed with the function plerr

Definition at line 108 of file class_gamepad.cpp.

int class_gamepad::StartComm ( const char *  device)

Initialize comm with the gamepad.

Parameters
deviceName of the device to use
Returns
error code that can be analyzed with the function plerr

Definition at line 47 of file class_gamepad.cpp.

int class_gamepad::UnRegisterCallback ( e_type  type,
int  id 
)

Member Data Documentation

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.


The documentation for this class was generated from the following files:


atlasmv_base
Author(s): David Gameiro, Jorge Almeida
autogenerated on Mon Mar 2 2015 01:31:28