summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spillaz <smspillaz@gmail.com>2008-04-26 21:11:16 +0800
committerSam Spillaz <smspillaz@gmail.com>2008-04-26 21:11:16 +0800
commit416d9a4ad1a0d78edb18153b329851581a3b13c8 (patch)
treeea21184e890decc31f1654e7ae4b7f7df4d7c07f
parent2af1f4289c359d2d5e90bd9ed2ac84883d41a73e (diff)
downloadwiimote-416d9a4ad1a0d78edb18153b329851581a3b13c8.tar.gz
wiimote-416d9a4ad1a0d78edb18153b329851581a3b13c8.tar.bz2
* Part 7: Split options code into option.c
-rw-r--r--compiz-wiimote.h9
-rw-r--r--wiimote.c161
2 files changed, 9 insertions, 161 deletions
diff --git a/compiz-wiimote.h b/compiz-wiimote.h
index 12f8e34..e5652bc 100644
--- a/compiz-wiimote.h
+++ b/compiz-wiimote.h
@@ -381,6 +381,15 @@ Bool checkConnected (void *vd);
Bool wiimoteCheckForGestures (void *vs);
Bool sendReports(void *vs);
+void
+reloadWiimoteGestures (CompDisplay *d);
+
+void
+reloadWiimoteReporters(CompDisplay *d);
+
+void
+reloadWiimoteOptions (CompDisplay *d);
+
/* Shortcut Macros --------------------------------------------------- */
#define toggle_bit(bf,b) \
diff --git a/wiimote.c b/wiimote.c
index 2052a61..8d63abf 100644
--- a/wiimote.c
+++ b/wiimote.c
@@ -240,167 +240,6 @@ wiimoteSendInfo (CompDisplay *d,
return TRUE;
}
-/* Option Initialisation --------------------------------------------------- */
-
-static 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++;
- }
- }
-}
-
-static void
-reloadWiimoteReporters(CompDisplay *d)
-{
- CompListValue *cWiimoteNumber = wiimoteGetReportWiimoteNumber (d);
- CompListValue *cReportType = wiimoteGetReportType (d);
- CompListValue *cPluginName = wiimoteGetReportPluginName (d);
- CompListValue *cActionName = wiimoteGetReportActionName (d);
- CompListValue *cReportSensitivity = wiimoteGetReportSensitivity (d);
-
- CompListValue *cXArgument = wiimoteGetReportXArgument (d);
- CompListValue *cYArgument = wiimoteGetReportYArgument (d);
- CompListValue *cZArgument = wiimoteGetReportZArgument (d);
-
- CompListValue *cDataType = wiimoteGetReportDataType (d);
-
- int nReport;
- int iReport = 0;
- int i = 0;
-
- WIIMOTE_DISPLAY (d);
-
- if ((cWiimoteNumber->nValue != cReportType->nValue) ||
- (cWiimoteNumber->nValue != cPluginName->nValue) ||
- (cWiimoteNumber->nValue != cActionName->nValue) ||
- (cWiimoteNumber->nValue != cXArgument->nValue) ||
- (cWiimoteNumber->nValue != cYArgument->nValue) ||
- (cWiimoteNumber->nValue != cZArgument->nValue) ||
- (cWiimoteNumber->nValue != cDataType->nValue) ||
- (cWiimoteNumber->nValue != cReportSensitivity->nValue))
- {
- compLogMessage (d, "wiimote", CompLogLevelError,
- "Options are not set correctly. Please revisit them and make sure each option in the list is set\n");
- return;
- }
-
- for (i = 0; i < MAX_WIIMOTES; i++)
- {
- nReport = cWiimoteNumber->nValue;
- iReport = 0;
- ad->cWiimote[i].nReport = 0;
- int k = 0;
-
- while (nReport-- && iReport < MAX_REPORTS - 1)
- {
- 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++;
- }
- }
-}
-
-static void
-reloadWiimoteOptions (CompDisplay *d)
-{
- 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))
- {
- /* Options have not been set correctly */
- return;
- }
-
- for (i = 0; i < MAX_WIIMOTES; i++)
- {
- 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++;
- }
- }
-}
-
static void
wiimoteDisplayOptionChanged (CompDisplay *d,
CompOption *opt,