29 JoystickSettingT =
nullptr;
30 JoystickSettingTP.
ntp = 0;
39 for (
int i = 0; i < JoystickSettingTP.
ntp; i++)
40 free(JoystickSettingT[i].aux0);
42 free(JoystickSettingT);
46 const char *initialValue)
48 if (JoystickSettingT ==
nullptr)
49 JoystickSettingT =
static_cast<IText *
>(malloc(
sizeof(
IText)));
52 for (
int i = 0; i < JoystickSettingTP.
ntp; i++)
54 if (!strcmp(propertyName, JoystickSettingT[i].name))
58 IText *buf =
static_cast<IText *
>(realloc(JoystickSettingT, (JoystickSettingTP.
ntp + 1) *
sizeof(
IText)));
61 free (JoystickSettingT);
62 perror(
"Failed to allocate memory for joystick controls.");
66 JoystickSettingT = buf;
71 memset(JoystickSettingT + JoystickSettingTP.
ntp, 0,
sizeof(
IText));
72 IUFillText(&JoystickSettingT[JoystickSettingTP.
ntp], propertyName, propertyLabel, initialValue);
74 JoystickSettingT[JoystickSettingTP.
ntp++].aux0 = ctype;
77 "JOYSTICKSETTINGS",
"Settings",
"Joystick",
IP_RW, 0,
IPS_IDLE);
82 for (
int i = 0; i < JoystickSettingTP.
ntp; i++)
84 free(JoystickSettingT[i].aux0);
85 free(JoystickSettingT[i].text);
88 JoystickSettingTP.
ntp = 0;
89 free(JoystickSettingT);
90 JoystickSettingT =
nullptr;
100 IUFillText(&JoystickDeviceT[0],
"SNOOP_JOYSTICK_DEVICE",
"Device",
"Joystick");
117 if (JoystickSettingT && UseJoystickS[0].s ==
ISS_ON)
129 if (JoystickSettingT && UseJoystickS[0].s ==
ISS_ON)
147 if (!strcmp(name, UseJoystickSP.
name))
153 if (UseJoystickSP.
sp[0].s ==
ISS_ON)
171 if (!strcmp(name,
"SNOOP_JOYSTICK"))
178 if (UseJoystickSP.
sp[0].s ==
ISS_ON)
187 if (!strcmp(name,
"JOYSTICKSETTINGS") && n <= JoystickSettingTP.
ntp)
189 for (
int i = 0; i < JoystickSettingTP.
ntp; i++)
208 for (
int i = 0; i < n; i++)
210 if (strstr(JoystickSettingT[i].text,
"JOYSTICK_"))
211 IDSnoopDevice(JoystickDeviceT[0].text, JoystickSettingT[i].text);
226 double mag = 0, angle = 0;
235 if (!strcmp(
"JOYSTICK_AXES", propName))
241 if (setting ==
nullptr)
250 else if (!strcmp(
"JOYSTICK_BUTTONS", propName))
257 if (setting ==
nullptr)
264 else if (strstr(propName,
"JOYSTICK_"))
269 if (setting ==
nullptr)
299 for (
int i = 0; i < JoystickSettingTP.
ntp; i++)
301 if (strstr(JoystickSettingTP.
tp[i].text,
"JOYSTICK_"))
355 if (strstr(name,
"JOYSTICK_"))
357 else if (strstr(name,
"AXIS_"))
359 else if (strstr(name,
"BUTTON_"))
367 for (
int i = 0; i < JoystickSettingTP.
ntp; i++)
368 if (!strcmp(JoystickSettingT[i].text, name))
369 return JoystickSettingT[i].name;
const char * getDeviceName() const
void setButtonCallback(buttonFunc buttonCallback)
setButtonCallback Sets the callback function when a new button input is detected.
static void joystickEvent(const char *joystick_n, double mag, double angle, void *context)
virtual bool ISSnoopDevice(XMLEle *root)
const char * getControllerSetting(const char *name)
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
void clearMap()
clearMap clears all properties added previously by mapController()
void mapController(const char *propertyName, const char *propertyLabel, ControllerType type, const char *initialValue)
mapController adds a new property to the joystick's settings.
virtual bool initProperties()
void setAxisCallback(axisFunc axisCallback)
setAxisCallback Sets the callback function when a new axis input is detected.
INDI::DefaultDevice * device
virtual bool saveConfigItems(FILE *fp)
virtual void ISGetProperties(const char *dev)
std::function< void(const char *button_n, ISState state, void *context)> buttonFunc
buttonFunc Button callback function signature.
axisFunc axisCallbackFunc
virtual bool updateProperties()
void setJoystickCallback(joystickFunc joystickCallback)
setJoystickCallback Sets the callback function when a new joystick input is detected.
joystickFunc joystickCallbackFunc
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
static void buttonEvent(const char *button_n, int value, void *context)
std::function< void(const char *axis_n, double value, void *context)> axisFunc
axisFunc Axis callback function signature.
Controller(INDI::DefaultDevice *cdevice)
Controller Default ctor.
ControllerType getControllerType(const char *name)
std::function< void(const char *joystick_n, double mag, double angle, void *context)> joystickFunc
joystickFunc Joystick callback function signature.
buttonFunc buttonCallbackFunc
static void axisEvent(const char *axis_n, int value, void *context)
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
const char * OPTIONS_TAB
OPTIONS_TAB Where all the driver's options are located. Those may include auxiliary controls,...
void IUSaveConfigSwitch(FILE *fp, const ISwitchVectorProperty *svp)
Add a switch vector property value to the configuration file.
void IUFillTextVector(ITextVectorProperty *tvp, IText *tp, int ntp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a text vector property. The vector's auxiliary elements will be set to NULL.
void IUFillSwitch(ISwitch *sp, const char *name, const char *label, ISState s)
Assign attributes for a switch property. The switch's auxiliary elements will be set to NULL.
void IUFillText(IText *tp, const char *name, const char *label, const char *initialText)
Assign attributes for a text property. The text's auxiliary elements will be set to NULL.
void IUSaveConfigText(FILE *fp, const ITextVectorProperty *tvp)
Add a text vector property value to the configuration file.
void IUFillSwitchVector(ISwitchVectorProperty *svp, ISwitch *sp, int nsp, const char *dev, const char *name, const char *label, const char *group, IPerm p, ISRule r, double timeout, IPState s)
Assign attributes for a switch vector property. The vector's auxiliary elements will be set to NULL.
IText * IUFindText(const ITextVectorProperty *tvp, const char *name)
Find an IText member in a vector text property.
int IUUpdateSwitch(ISwitchVectorProperty *svp, ISState *states, char *names[], int n)
Update all switches in a switch vector property.
void IDSetSwitch(const ISwitchVectorProperty *svp, const char *fmt,...)
int IUUpdateText(ITextVectorProperty *tvp, char *texts[], char *names[], int n)
Update all text members in a text vector property.
void IDSnoopDevice(const char *snooped_device, const char *snooped_property)
Function a Driver calls to snoop on another Device. Snooped messages will then arrive via ISSnoopDevi...
void IDSetText(const ITextVectorProperty *tvp, const char *fmt,...)
#define DEBUGFDEVICE(device, priority, msg,...)
const char * findXMLAttValu(XMLEle *ep, const char *name)
Find an XML element's attribute value.
char * pcdataXMLEle(XMLEle *ep)
Return the pcdata of an XML element.
XMLEle * nextXMLEle(XMLEle *ep, int init)
Iterate an XML element for a list of nesetd XML elements.
Namespace to encapsulate INDI client, drivers, and mediator classes.