|
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...
|
|
|
| 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) |
|
The Controller class provides functionality to access a controller (e.g.
joystick) input and send it to the requesting driver.
- To use the class in an INDI::DefaultDevice based driver:
- Set the callback functions for each of input type requested.
- Map the properties you wish to /e listen to from the joystick driver by specifying the type of input requested and the initial default value. For example: After mapping all the desired controls, call the class initProperties() function. If the user enables joystick support in the driver and presses a button on the joystick, the button callback function will be invoked with the name & state of the button.
- Call the Controller's ISGetProperties(), initProperties(), updateProperties(), saveConfigItems(), and ISNewXXX functions from the same standard functions in your driver.
The class communicates with INDI joystick driver which in turn enumerates the game pad and provides three types of constrcuts:
-
Joysticks: Each joystick displays a normalized magnitude [0 to 1] and an angle. The angle is measured counter clock wise starting from the right/east direction [0 to 360]. They are defined as JOYSTICK_# where # is the joystick number.
-
Axes: Each joystick has two or more axes. Each axis has a raw value and angle. The raw value ranges from -32767.0 to 32767.0 They are defined as AXIS_# where # is the axis number.
-
Buttons: Buttons are either on or off. They are defined as BUTTON_# where # is the button number.
- 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