TwiceAsNice  2019-02-18
Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Attributes | List of all members
INDI::Controller Class Reference

The Controller class provides functionality to access a controller (e.g. More...

#include <indicontroller.h>

Collaboration diagram for INDI::Controller:
Collaboration graph

Public Types

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

Private Attributes

ISwitchVectorProperty UseJoystickSP
 
ISwitch UseJoystickS [2]
 
ITextVectorProperty JoystickSettingTP
 
ITextJoystickSettingT = nullptr
 

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

Member Typedef Documentation

◆ axisFunc [1/2]

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

axisFunc Axis callback function signature.

◆ axisFunc [2/2]

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

axisFunc Axis callback function signature.

◆ buttonFunc [1/2]

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

buttonFunc Button callback function signature.

◆ buttonFunc [2/2]

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

buttonFunc Button callback function signature.

◆ joystickFunc [1/2]

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

joystickFunc Joystick callback function signature.

◆ joystickFunc [2/2]

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

joystickFunc Joystick callback function signature.

Member Enumeration Documentation

◆ ControllerType [1/2]

Enumerator
CONTROLLER_JOYSTICK 
CONTROLLER_AXIS 
CONTROLLER_BUTTON 
CONTROLLER_UNKNOWN 
CONTROLLER_JOYSTICK 
CONTROLLER_AXIS 
CONTROLLER_BUTTON 
CONTROLLER_UNKNOWN 

◆ ControllerType [2/2]

Enumerator
CONTROLLER_JOYSTICK 
CONTROLLER_AXIS 
CONTROLLER_BUTTON 
CONTROLLER_UNKNOWN 
CONTROLLER_JOYSTICK 
CONTROLLER_AXIS 
CONTROLLER_BUTTON 
CONTROLLER_UNKNOWN 

Constructor & Destructor Documentation

◆ Controller() [1/2]

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

Controller Default ctor.

Parameters
cdeviceINDI::DefaultDevice device

◆ ~Controller() [1/2]

INDI::Controller::~Controller ( )
virtual

◆ Controller() [2/2]

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

Controller Default ctor.

Parameters
cdeviceINDI::DefaultDevice device

◆ ~Controller() [2/2]

virtual INDI::Controller::~Controller ( )
virtual

Member Function Documentation

◆ axisEvent() [1/2]

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

◆ axisEvent() [2/2]

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

◆ buttonEvent() [1/2]

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

◆ buttonEvent() [2/2]

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

◆ clearMap() [1/2]

void INDI::Controller::clearMap ( )

clearMap clears all properties added previously by mapController()

◆ clearMap() [2/2]

void INDI::Controller::clearMap ( )

clearMap clears all properties added previously by mapController()

◆ disableJoystick() [1/2]

void INDI::Controller::disableJoystick ( )
protected

◆ disableJoystick() [2/2]

void INDI::Controller::disableJoystick ( )
protected

◆ enableJoystick() [1/2]

void INDI::Controller::enableJoystick ( )
protected

◆ enableJoystick() [2/2]

void INDI::Controller::enableJoystick ( )
protected

◆ getControllerSetting() [1/2]

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

◆ getControllerSetting() [2/2]

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

◆ getControllerType() [1/2]

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

◆ getControllerType() [2/2]

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

◆ initProperties() [1/2]

bool INDI::Controller::initProperties ( )
virtual

◆ initProperties() [2/2]

virtual bool INDI::Controller::initProperties ( )
virtual

◆ ISGetProperties() [1/2]

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

◆ ISGetProperties() [2/2]

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

◆ ISNewSwitch() [1/2]

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

◆ ISNewSwitch() [2/2]

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

◆ ISNewText() [1/2]

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

◆ ISNewText() [2/2]

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

◆ ISSnoopDevice() [1/2]

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

◆ ISSnoopDevice() [2/2]

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

◆ joystickEvent() [1/2]

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

◆ joystickEvent() [2/2]

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

◆ mapController() [1/2]

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.

◆ mapController() [2/2]

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.

◆ saveConfigItems() [1/2]

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

◆ saveConfigItems() [2/2]

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

◆ setAxisCallback() [1/2]

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

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

Parameters
axisCallbackthe callback function.

◆ setAxisCallback() [2/2]

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

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

Parameters
axisCallbackthe callback function.

◆ setButtonCallback() [1/2]

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

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

Parameters
buttonCallbackthe callback function.

◆ setButtonCallback() [2/2]

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

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

Parameters
buttonCallbackthe callback function.

◆ setJoystickCallback() [1/2]

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

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

Parameters
joystickCallbackthe callback function.

◆ setJoystickCallback() [2/2]

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

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

Parameters
joystickCallbackthe callback function.

◆ updateProperties() [1/2]

bool INDI::Controller::updateProperties ( )
virtual

◆ updateProperties() [2/2]

virtual bool INDI::Controller::updateProperties ( )
virtual

Member Data Documentation

◆ axisCallbackFunc

axisFunc INDI::Controller::axisCallbackFunc
protected

◆ buttonCallbackFunc

buttonFunc INDI::Controller::buttonCallbackFunc
protected

◆ device

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

◆ joystickCallbackFunc

joystickFunc INDI::Controller::joystickCallbackFunc
protected

◆ JoystickSettingT

IText * INDI::Controller::JoystickSettingT = nullptr
private

◆ JoystickSettingTP

ITextVectorProperty INDI::Controller::JoystickSettingTP
private

◆ UseJoystickS

ISwitch INDI::Controller::UseJoystickS
private

◆ UseJoystickSP

ISwitchVectorProperty INDI::Controller::UseJoystickSP
private

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