summaryrefslogtreecommitdiff
path: root/option.c
diff options
context:
space:
mode:
Diffstat (limited to 'option.c')
-rw-r--r--option.c228
1 files changed, 126 insertions, 102 deletions
diff --git a/option.c b/option.c
index f03e003..44de87d 100644
--- a/option.c
+++ b/option.c
@@ -24,57 +24,8 @@
/* Option Initialisation --------------------------------------------------- */
void
-reloadWiimoteGestures (CompDisplay *d)
-{
- CompListValue *cWiimoteNumber = wiimoteGetGestureWiimoteNumber (d);
- CompListValue *cGestureType = wiimoteGetGestureType (d);
- CompListValue *cPluginName = wiimoteGetGesturePluginName (d);
- CompListValue *cActionName = wiimoteGetGestureActionName (d);
- CompListValue *cGestureSensitivity = wiimoteGetGestureSensitivity (d);
-
- int nGesture;
- int iGesture = 0;
- int i = 0;
-
- if ((cWiimoteNumber->nValue != cGestureType->nValue) ||
- (cWiimoteNumber->nValue != cPluginName->nValue) ||
- (cWiimoteNumber->nValue != cGestureSensitivity->nValue) ||
- (cWiimoteNumber->nValue != cActionName->nValue))
- {
- /* Options have not been set correctly */
- return;
- }
-
- WIIMOTE_DISPLAY (d);
-
- for (i = 0; i < MAX_WIIMOTES; i++)
- {
- nGesture = cWiimoteNumber->nValue;
- iGesture = 0;
- int k = 0;
- ad->cWiimote[i].nGesture = 0;
-
- while (nGesture-- && iGesture < MAX_GESTURES)
- {
- if (cWiimoteNumber->value[iGesture].i == i)
- {
- ad->cWiimote[i].gesture[iGesture].set = TRUE;
- ad->cWiimote[i].gesture[iGesture].pluginName = strdup(cPluginName->value[iGesture].s);
- ad->cWiimote[i].gesture[iGesture].actionName = strdup(cActionName->value[iGesture].s);
- ad->cWiimote[i].gesture[iGesture].sensitivity = cGestureSensitivity->value[iGesture].i;
-
- ad->cWiimote[i].gesture[k].type = cGestureType->value[iGesture].i;
- k++;
- ad->cWiimote[i].nGesture++;
-
- }
- iGesture++;
- }
- }
-}
-
-void
-reloadWiimoteReporters(CompDisplay *d)
+reloadReportersForWiimote (CompDisplay *d,
+ CompWiimote *wiimote)
{
CompListValue *cWiimoteNumber = wiimoteGetReportWiimoteNumber (d);
CompListValue *cReportType = wiimoteGetReportType (d);
@@ -90,9 +41,6 @@ reloadWiimoteReporters(CompDisplay *d)
int nReport;
int iReport = 0;
- int i = 0;
-
- WIIMOTE_DISPLAY (d);
if ((cWiimoteNumber->nValue != cReportType->nValue) ||
(cWiimoteNumber->nValue != cPluginName->nValue) ||
@@ -108,53 +56,120 @@ reloadWiimoteReporters(CompDisplay *d)
return;
}
- for (i = 0; i < MAX_WIIMOTES; i++)
+
+ nReport = cWiimoteNumber->nValue;
+ iReport = 0;
+ wiimote->nReport = 0;
+
+ while (nReport-- && iReport < MAX_REPORTS - 1)
+ {
+ if (cWiimoteNumber->value[iReport].i == wiimote->id)
+ {
+ /* And set them */
+ wiimote->report[wiimote->nReport].set = TRUE;
+ wiimote->report[wiimote->nReport].pluginName = strdup(cPluginName->value[iReport].s);
+ wiimote->report[wiimote->nReport].actionName = strdup(cActionName->value[iReport].s);
+ wiimote->report[wiimote->nReport].sensitivity = cReportSensitivity->value[iReport].i;
+
+ wiimote->report[wiimote->nReport].xarg = strdup(cXArgument->value[iReport].s);
+ wiimote->report[wiimote->nReport].yarg = strdup(cYArgument->value[iReport].s);
+ wiimote->report[wiimote->nReport].zarg = strdup(cZArgument->value[iReport].s);
+
+ wiimote->report[wiimote->nReport].type = cReportType->value[iReport].i;
+ wiimote->report[wiimote->nReport].dataType = cDataType->value[iReport].i;
+
+ wiimote->nReport++;
+ }
+
+ iReport++;
+ }
+}
+
+void
+reloadReportersForWiimoteNumber (CompDisplay *d,
+ int wiimoteNumber)
+{
+ CompWiimote *wiimote;
+ WIIMOTE_DISPLAY (d);
+
+ for (wiimote = ad->wiimotes; wiimote; wiimote = wiimote->next)
+ {
+ if (wiimote->id == wiimoteNumber)
+ {
+ reloadReportersForWiimote (d, wiimote);
+ break;
+ }
+ }
+}
+
+void
+reloadGesturesForWiimote (CompDisplay *d,
+ CompWiimote *wiimote)
+{
+ CompListValue *cWiimoteNumber = wiimoteGetGestureWiimoteNumber (d);
+ CompListValue *cGestureType = wiimoteGetGestureType (d);
+ CompListValue *cPluginName = wiimoteGetGesturePluginName (d);
+ CompListValue *cActionName = wiimoteGetGestureActionName (d);
+ CompListValue *cGestureSensitivity = wiimoteGetGestureSensitivity (d);
+
+ int nGesture;
+ int iGesture = 0;
+
+ if ((cWiimoteNumber->nValue != cGestureType->nValue) ||
+ (cWiimoteNumber->nValue != cPluginName->nValue) ||
+ (cWiimoteNumber->nValue != cGestureSensitivity->nValue) ||
+ (cWiimoteNumber->nValue != cActionName->nValue))
{
- nReport = cWiimoteNumber->nValue;
- iReport = 0;
- ad->cWiimote[i].nReport = 0;
- int k = 0;
+ /* Options have not been set correctly */
+ return;
+ }
- while (nReport-- && iReport < MAX_REPORTS - 1)
+ nGesture = cWiimoteNumber->nValue;
+ iGesture = 0;
+ wiimote->nGesture = 0;
+
+ while (nGesture-- && iGesture < MAX_GESTURES)
+ {
+ if (cWiimoteNumber->value[iGesture].i == wiimote->id)
{
- if (cWiimoteNumber->value[iReport].i == i)
- {
- /* And set them */
- ad->cWiimote[i].nReport++;
- ad->cWiimote[i].report[k].set = TRUE;
- ad->cWiimote[i].report[k].pluginName = strdup(cPluginName->value[iReport].s);
- ad->cWiimote[i].report[k].actionName = strdup(cActionName->value[iReport].s);
- ad->cWiimote[i].report[k].sensitivity = cReportSensitivity->value[iReport].i;
-
- ad->cWiimote[i].report[k].xarg = strdup(cXArgument->value[iReport].s);
- ad->cWiimote[i].report[k].yarg = strdup(cYArgument->value[iReport].s);
- ad->cWiimote[i].report[k].zarg = strdup(cZArgument->value[iReport].s);
-
- ad->cWiimote[i].report[k].type = cReportType->value[iReport].i;
- ad->cWiimote[i].report[k].dataType = cDataType->value[iReport].i;
-
- k++; /* Set next availiable option */
- }
-
- iReport++;
+ wiimote->gesture[wiimote->nGesture].set = TRUE;
+ wiimote->gesture[wiimote->nGesture].pluginName = strdup(cPluginName->value[iGesture].s);
+ wiimote->gesture[wiimote->nGesture].actionName = strdup(cActionName->value[iGesture].s);
+ wiimote->gesture[wiimote->nGesture].sensitivity = cGestureSensitivity->value[iGesture].i;
+ wiimote->gesture[wiimote->nGesture].type = cGestureType->value[iGesture].i;
+ wiimote->nGesture++;
+
}
+ iGesture++;
}
}
void
-reloadWiimoteOptions (CompDisplay *d)
+reloadGesturesForWiimoteNumber (CompDisplay *d,
+ int wiimoteNumber)
+{
+ CompWiimote *wiimote;
+ WIIMOTE_DISPLAY (d);
+
+ for (wiimote = ad->wiimotes; wiimote; wiimote = wiimote->next)
+ {
+ if (wiimote->id == wiimoteNumber)
+ {
+ reloadGesturesForWiimote (d, wiimote);
+ break;
+ }
+ }
+}
+
+void
+reloadOptionsForWiimote (CompDisplay *d,
+ CompWiimote *wiimote)
{
CompListValue *cXCal = wiimoteGetXCalibrationMul (d);
CompListValue *cYCal = wiimoteGetYCalibrationMul (d);
CompListValue *cXAdj = wiimoteGetXAdjust (d);
CompListValue *cYAdj = wiimoteGetYAdjust (d);
- int nWiimote;
- int iWiimote = 0;
- int i = 0;
-
- WIIMOTE_DISPLAY (d);
-
if ((cXCal->nValue != cYCal->nValue) ||
(cXCal->nValue != cXAdj->nValue) ||
(cXCal->nValue != cYAdj->nValue))
@@ -163,21 +178,30 @@ reloadWiimoteOptions (CompDisplay *d)
return;
}
- for (i = 0; i < MAX_WIIMOTES; i++)
+ if (wiimote->id < cXCal->nValue)
{
- nWiimote = cXCal->nValue;
- iWiimote = 0;
- while (nWiimote-- && iWiimote < MAX_REPORTS)
- {
- if (iWiimote == i)
- {
- ad->cWiimote[i].irMulX = cXCal->value[iWiimote].f;
- ad->cWiimote[i].irMulY = cYCal->value[iWiimote].f;
- ad->cWiimote[i].irSubX = cXAdj->value[iWiimote].f;
- ad->cWiimote[i].irSubY = cYAdj->value[iWiimote].f;
- }
-
- iWiimote++;
- }
+ wiimote->irMulX = cXCal->value[wiimote->id].f;
+ wiimote->irMulY = cYCal->value[wiimote->id].f;
+ wiimote->irSubX = cXAdj->value[wiimote->id].f;
+ wiimote->irSubY = cYAdj->value[wiimote->id].f;
}
}
+
+void
+reloadOptionsForWiimoteNumber (CompDisplay *d,
+ int wiimoteNumber)
+{
+ CompWiimote *wiimote;
+ WIIMOTE_DISPLAY (d);
+
+ for (wiimote = ad->wiimotes; wiimote; wiimote = wiimote->next)
+ {
+ if (wiimote->id == wiimoteNumber)
+ {
+ reloadOptionsForWiimote (d, wiimote);
+ break;
+ }
+ }
+}
+
+