class_gamepad Class Reference

#include <class_gamepad.h>

List of all members.

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_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:
debug if 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:
ret error 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:
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
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:
device Name 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

Definition at line 117 of file class_gamepad.h.

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:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


atlasmv_base
Author(s): David Gameiro, Jorge Almeida
autogenerated on Wed Jul 23 04:34:43 2014