Instrument Neutral Distributed Interface INDI  1.5.0
Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
INDI::Controller Class Reference

The Controller class provides functionality to access a controller (e.g. joystick) input and send it to the requesting driver. More...

#include <indicontroller.h>

Public Types

typedef std::function< void(const char *joystick_n, double mag, double angle, void *context)> joystickFunc
 joystickFunc Joystick callback function signature. More...
 
typedef std::function< void(const char *axis_n, double value, void *context)> axisFunc
 axisFunc Axis callback function signature. More...
 
typedef std::function< void(const char *button_n, ISState state, void *context)> buttonFunc
 buttonFunc Button callback function signature. More...
 

Public Member Functions

 Controller (INDI::DefaultDevice *cdevice)
 Controller Default ctor. More...
 
virtual ~Controller ()
 
virtual void ISGetProperties (const char *dev)
 
virtual bool initProperties ()
 
virtual bool updateProperties ()
 
virtual bool ISSnoopDevice (XMLEle *root)
 
virtual bool ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
 
virtual bool ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n)
 
virtual bool saveConfigItems (FILE *fp)
 
void mapController (const char *propertyName, const char *propertyLabel, ControllerType type, const char *initialValue)
 mapController adds a new property to the joystick's settings. More...
 
void clearMap ()
 clearMap clears all properties added previously by mapController() More...
 
void setJoystickCallback (joystickFunc joystickCallback)
 setJoystickCallback Sets the callback function when a new joystick input is detected. More...
 
void setAxisCallback (axisFunc axisCallback)
 setAxisCallback Sets the callback function when a new axis input is detected. More...
 
void setButtonCallback (buttonFunc buttonCallback)
 setButtonCallback Sets the callback function when a new button input is detected. More...
 
ControllerType getControllerType (const char *name)
 
const char * getControllerSetting (const char *name)
 

Protected Member Functions

void enableJoystick ()
 
void disableJoystick ()
 

Static Protected Member Functions

static void joystickEvent (const char *joystick_n, double mag, double angle, void *context)
 
static void axisEvent (const char *axis_n, int value, void *context)
 
static void buttonEvent (const char *button_n, int value, void *context)
 

Protected Attributes

joystickFunc joystickCallbackFunc
 
buttonFunc buttonCallbackFunc
 
axisFunc axisCallbackFunc
 
INDI::DefaultDevicedevice
 

Detailed Description

The Controller class provides functionality to access a controller (e.g. joystick) input and send it to the requesting driver.

The class communicates with INDI joystick driver which in turn enumerates the game pad and provides three types of constrcuts:

Note
All indexes start from 1. i.e. There is no BUTTON_0 or JOYSTICK_0.
See also
See the LX200 Generic & Celestron GPS drivers for an example implementation.
Warning
Both the indi_joystick driver and the driver using this class must be running in the same INDI server (or chained INDI servers) in order for it to work as it depends on snooping among drivers.
Author
Jasem Multaq

Definition at line 65 of file indicontroller.h.

Member Typedef Documentation

typedef std::function<void(const char *axis_n, double value, void *context)> INDI::Controller::axisFunc

axisFunc Axis callback function signature.

Definition at line 78 of file indicontroller.h.

typedef std::function<void(const char *button_n, ISState state, void *context)> INDI::Controller::buttonFunc

buttonFunc Button callback function signature.

Definition at line 83 of file indicontroller.h.

typedef std::function<void(const char *joystick_n, double mag, double angle, void *context)> INDI::Controller::joystickFunc

joystickFunc Joystick callback function signature.

Definition at line 73 of file indicontroller.h.

Member Enumeration Documentation

Enumerator
CONTROLLER_JOYSTICK 
CONTROLLER_AXIS 
CONTROLLER_BUTTON 
CONTROLLER_UNKNOWN 

Definition at line 68 of file indicontroller.h.

Constructor & Destructor Documentation

INDI::Controller::Controller ( INDI::DefaultDevice cdevice)

Controller Default ctor.

Parameters
cdeviceINDI::DefaultDevice device

Definition at line 25 of file indicontroller.cpp.

INDI::Controller::~Controller ( )
virtual

Definition at line 37 of file indicontroller.cpp.

Member Function Documentation

void INDI::Controller::axisEvent ( const char *  axis_n,
int  value,
void *  context 
)
staticprotected

Definition at line 304 of file indicontroller.cpp.

void INDI::Controller::buttonEvent ( const char *  button_n,
int  value,
void *  context 
)
staticprotected

Definition at line 311 of file indicontroller.cpp.

void INDI::Controller::clearMap ( )

clearMap clears all properties added previously by mapController()

Definition at line 71 of file indicontroller.cpp.

void INDI::Controller::disableJoystick ( )
protected

Definition at line 276 of file indicontroller.cpp.

void INDI::Controller::enableJoystick ( )
protected

Definition at line 262 of file indicontroller.cpp.

const char * INDI::Controller::getControllerSetting ( const char *  name)

Definition at line 332 of file indicontroller.cpp.

Controller::ControllerType INDI::Controller::getControllerType ( const char *  name)

Definition at line 318 of file indicontroller.cpp.

bool INDI::Controller::initProperties ( )
virtual

Definition at line 84 of file indicontroller.cpp.

void INDI::Controller::ISGetProperties ( const char *  dev)
virtual

Definition at line 94 of file indicontroller.cpp.

bool INDI::Controller::ISNewSwitch ( const char *  dev,
const char *  name,
ISState states,
char *  names[],
int  n 
)
virtual

Definition at line 126 of file indicontroller.cpp.

bool INDI::Controller::ISNewText ( const char *  dev,
const char *  name,
char *  texts[],
char *  names[],
int  n 
)
virtual

Definition at line 151 of file indicontroller.cpp.

bool INDI::Controller::ISSnoopDevice ( XMLEle root)
virtual

Definition at line 191 of file indicontroller.cpp.

void INDI::Controller::joystickEvent ( const char *  joystick_n,
double  mag,
double  angle,
void *  context 
)
staticprotected

Definition at line 296 of file indicontroller.cpp.

void INDI::Controller::mapController ( const char *  propertyName,
const char *  propertyLabel,
ControllerType  type,
const char *  initialValue 
)

mapController adds a new property to the joystick's settings.

Parameters
propertyNameName
propertyLabelLabel
typeThe input type of the property. This value cannot be updated.
initialValueInitial value for the property.

Definition at line 45 of file indicontroller.cpp.

bool INDI::Controller::saveConfigItems ( FILE *  fp)
virtual

Definition at line 254 of file indicontroller.cpp.

void INDI::Controller::setAxisCallback ( axisFunc  axisCallback)

setAxisCallback Sets the callback function when a new axis input is detected.

Parameters
axisCallbackthe callback function.

Definition at line 286 of file indicontroller.cpp.

void INDI::Controller::setButtonCallback ( buttonFunc  buttonCallback)

setButtonCallback Sets the callback function when a new button input is detected.

Parameters
buttonCallbackthe callback function.

Definition at line 291 of file indicontroller.cpp.

void INDI::Controller::setJoystickCallback ( joystickFunc  joystickCallback)

setJoystickCallback Sets the callback function when a new joystick input is detected.

Parameters
joystickCallbackthe callback function.

Definition at line 281 of file indicontroller.cpp.

bool INDI::Controller::updateProperties ( )
virtual

Definition at line 108 of file indicontroller.cpp.

Member Data Documentation

axisFunc INDI::Controller::axisCallbackFunc
protected

Definition at line 146 of file indicontroller.h.

buttonFunc INDI::Controller::buttonCallbackFunc
protected

Definition at line 145 of file indicontroller.h.

INDI::DefaultDevice* INDI::Controller::device
protected

Definition at line 148 of file indicontroller.h.

joystickFunc INDI::Controller::joystickCallbackFunc
protected

Definition at line 144 of file indicontroller.h.


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