Instrument Neutral Distributed Interface INDI  2.0.2
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

enum  ControllerType { CONTROLLER_JOYSTICK , CONTROLLER_AXIS , CONTROLLER_BUTTON , CONTROLLER_UNKNOWN }
 
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

◆ axisFunc

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.

◆ buttonFunc

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.

◆ joystickFunc

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

◆ ControllerType

Enumerator
CONTROLLER_JOYSTICK 
CONTROLLER_AXIS 
CONTROLLER_BUTTON 
CONTROLLER_UNKNOWN 

Definition at line 68 of file indicontroller.h.

Constructor & Destructor Documentation

◆ Controller()

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

Controller Default ctor.

Parameters
cdeviceINDI::DefaultDevice device

Definition at line 25 of file indicontroller.cpp.

◆ ~Controller()

INDI::Controller::~Controller ( )
virtual

Definition at line 37 of file indicontroller.cpp.

Member Function Documentation

◆ axisEvent()

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

Definition at line 337 of file indicontroller.cpp.

◆ buttonEvent()

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

Definition at line 344 of file indicontroller.cpp.

◆ clearMap()

void INDI::Controller::clearMap ( )

clearMap clears all properties added previously by mapController()

Definition at line 80 of file indicontroller.cpp.

◆ disableJoystick()

void INDI::Controller::disableJoystick ( )
protected

Definition at line 309 of file indicontroller.cpp.

◆ enableJoystick()

void INDI::Controller::enableJoystick ( )
protected

Definition at line 295 of file indicontroller.cpp.

◆ getControllerSetting()

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

Definition at line 365 of file indicontroller.cpp.

◆ getControllerType()

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

Definition at line 351 of file indicontroller.cpp.

◆ initProperties()

bool INDI::Controller::initProperties ( )
virtual

Definition at line 93 of file indicontroller.cpp.

◆ ISGetProperties()

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

Definition at line 107 of file indicontroller.cpp.

◆ ISNewSwitch()

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

Definition at line 142 of file indicontroller.cpp.

◆ ISNewText()

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

Definition at line 167 of file indicontroller.cpp.

◆ ISSnoopDevice()

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

Definition at line 223 of file indicontroller.cpp.

◆ joystickEvent()

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

Definition at line 329 of file indicontroller.cpp.

◆ mapController()

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.

◆ saveConfigItems()

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

Definition at line 286 of file indicontroller.cpp.

◆ setAxisCallback()

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 319 of file indicontroller.cpp.

◆ setButtonCallback()

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 324 of file indicontroller.cpp.

◆ setJoystickCallback()

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 314 of file indicontroller.cpp.

◆ updateProperties()

bool INDI::Controller::updateProperties ( )
virtual

Definition at line 122 of file indicontroller.cpp.

Member Data Documentation

◆ axisCallbackFunc

axisFunc INDI::Controller::axisCallbackFunc
protected

Definition at line 146 of file indicontroller.h.

◆ buttonCallbackFunc

buttonFunc INDI::Controller::buttonCallbackFunc
protected

Definition at line 145 of file indicontroller.h.

◆ device

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

Definition at line 148 of file indicontroller.h.

◆ joystickCallbackFunc

joystickFunc INDI::Controller::joystickCallbackFunc
protected

Definition at line 144 of file indicontroller.h.


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