Instrument Neutral Distributed Interface INDI  1.9.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 81 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 94 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 99 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 89 of file indicontroller.h.

Member Enumeration Documentation

◆ ControllerType

Enumerator
CONTROLLER_JOYSTICK 
CONTROLLER_AXIS 
CONTROLLER_BUTTON 
CONTROLLER_UNKNOWN 

Definition at line 84 of file indicontroller.h.

Constructor & Destructor Documentation

◆ Controller()

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

Controller Default ctor.

Parameters
cdeviceINDI::DefaultDevice device

Definition at line 41 of file indicontroller.cpp.

◆ ~Controller()

INDI::Controller::~Controller ( )
virtual

Definition at line 53 of file indicontroller.cpp.

Member Function Documentation

◆ axisEvent()

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

Definition at line 353 of file indicontroller.cpp.

◆ buttonEvent()

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

Definition at line 360 of file indicontroller.cpp.

◆ clearMap()

void INDI::Controller::clearMap ( )

clearMap clears all properties added previously by mapController()

Definition at line 96 of file indicontroller.cpp.

◆ disableJoystick()

void INDI::Controller::disableJoystick ( )
protected

Definition at line 325 of file indicontroller.cpp.

◆ enableJoystick()

void INDI::Controller::enableJoystick ( )
protected

Definition at line 311 of file indicontroller.cpp.

◆ getControllerSetting()

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

Definition at line 381 of file indicontroller.cpp.

◆ getControllerType()

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

Definition at line 367 of file indicontroller.cpp.

◆ initProperties()

bool INDI::Controller::initProperties ( )
virtual

Definition at line 109 of file indicontroller.cpp.

◆ ISGetProperties()

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

Definition at line 123 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 158 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 183 of file indicontroller.cpp.

◆ ISSnoopDevice()

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

Definition at line 239 of file indicontroller.cpp.

◆ joystickEvent()

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

Definition at line 345 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 61 of file indicontroller.cpp.

◆ saveConfigItems()

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

Definition at line 302 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 335 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 340 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 330 of file indicontroller.cpp.

◆ updateProperties()

bool INDI::Controller::updateProperties ( )
virtual

Definition at line 138 of file indicontroller.cpp.

Member Data Documentation

◆ axisCallbackFunc

axisFunc INDI::Controller::axisCallbackFunc
protected

Definition at line 162 of file indicontroller.h.

◆ buttonCallbackFunc

buttonFunc INDI::Controller::buttonCallbackFunc
protected

Definition at line 161 of file indicontroller.h.

◆ device

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

Definition at line 164 of file indicontroller.h.

◆ joystickCallbackFunc

joystickFunc INDI::Controller::joystickCallbackFunc
protected

Definition at line 160 of file indicontroller.h.


The documentation for this class was generated from the following files:
INDI::Controller::mapController
void mapController(const char *propertyName, const char *propertyLabel, ControllerType type, const char *initialValue)
mapController adds a new property to the joystick's settings.
Definition: indicontroller.cpp:61
INDI::Controller::CONTROLLER_BUTTON
@ CONTROLLER_BUTTON
Definition: indicontroller.h:84