summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <Sam@ACER-SUSE.SUSE>2008-03-08 17:44:07 +0900
committerSam Spilsbury <Sam@ACER-SUSE.SUSE>2008-03-08 17:44:07 +0900
commit80e8ae13fc1ef7e47413603253f059f2137cb391 (patch)
treefb424adb1f5dbea1816619eadd510932132c9732
parentdc291f47dddac9d3393cbcb6caaa54adc4496586 (diff)
downloadwiimote-80e8ae13fc1ef7e47413603253f059f2137cb391.tar.gz
wiimote-80e8ae13fc1ef7e47413603253f059f2137cb391.tar.bz2
* Remove more redundant code and clean up functions
-rw-r--r--compiz-wiimote.h20
-rw-r--r--wiimote.c28
2 files changed, 17 insertions, 31 deletions
diff --git a/compiz-wiimote.h b/compiz-wiimote.h
index 0c722d5..74df4f7 100644
--- a/compiz-wiimote.h
+++ b/compiz-wiimote.h
@@ -318,20 +318,9 @@ typedef struct _CompWiimote
/* Core / Display / Screen structs */
-typedef struct _WiimoteCore {
- int data;
-} WiimoteCore;
-
typedef struct _WiimoteDisplay
{
int screenPrivateIndex;
-
- float accX;
- float accY;
- float accZ;
-
- Bool isIR[4];
-
int count;
CompWiimote cWiimote[MAX_WIIMOTES];
@@ -345,7 +334,6 @@ typedef struct _WiimoteDisplay
Bool CallbackSet;
- HandleEventProc handleEvent;
CompTimeoutHandle infoTimeoutHandle;
CompTimeoutHandle gestureTimeoutHandle;
CompTimeoutHandle checkingTimeoutHandle;
@@ -364,14 +352,10 @@ cwiid_err_t err;
/* Function Prototypes */
-static int findMin (CompDisplay *, int, int, int, int); // No you can't have fminf
-static int findMax (CompDisplay *, int, int, int, int); // Or fmaxf
+static int findMinIR (CompDisplay *, int, int, int, int, int); // No you can't have fminf
+static int findMaxIR (CompDisplay *, int, int, int, int, int); // Or fmaxf
static Bool sendInfoToPlugin (CompDisplay *, CompOption *, int, char *, char *);
-#define GET_WIIMOTE_CORE(c) \
- ((WiimoteCore *) (c)->base.privates[corePrivateIndex].ptr)
-#define WIIMOTE_CORE(c) \
- WiimoteCore *wc = GET_WIIMOTE_CORE (c)
#define GET_WIIMOTE_DISPLAY(d) \
((WiimoteDisplay *) (d)->base.privates[wiimoteDisplayPrivateIndex].ptr)
#define WIIMOTE_DISPLAY(d) \
diff --git a/wiimote.c b/wiimote.c
index be7598a..fe57b63 100644
--- a/wiimote.c
+++ b/wiimote.c
@@ -855,33 +855,33 @@ wiimoteCheckForGestures (void *vs)
/* Utility */
-static int findMin (CompDisplay *d, int ir1, int ir2, int ir3, int ir4)
+static int findMinIR (CompDisplay *d, int wiimoteNumber, int ir1, int ir2, int ir3, int ir4)
{
WIIMOTE_DISPLAY (d);
int min = ir1;
- if ((ir2 < min) && ad->isIR[1])
+ if ((ir2 < min) && ad->cWiimote[wiimoteNumber].ir[1].valid)
min = ir2;
- if ((ir3 < min) && ad->isIR[2])
+ if ((ir3 < min) && ad->cWiimote[wiimoteNumber].ir[2].valid)
min = ir3;
- if ((ir4 < min) && ad->isIR[3])
+ if ((ir4 < min) && ad->cWiimote[wiimoteNumber].ir[3].valid)
min = ir4;
return min;
}
-static int findMax (CompDisplay *d, int ir1, int ir2, int ir3, int ir4)
+static int findMaxIR (CompDisplay *d, int wiimoteNumber, int ir1, int ir2, int ir3, int ir4)
{
WIIMOTE_DISPLAY (d);
int max = ir1;
- if ((ir2 > max) && ad->isIR[1])
+ if ((ir2 > max) && ad->cWiimote[wiimoteNumber].ir[1].valid)
max = ir2;
- if ((ir3 > max) && ad->isIR[2])
+ if ((ir3 > max) && ad->cWiimote[wiimoteNumber].ir[2].valid)
max = ir3;
- if ((ir4 > max) && ad->isIR[3])
+ if ((ir4 > max) && ad->cWiimote[wiimoteNumber].ir[3].valid)
max = ir4;
return max;
@@ -1055,15 +1055,17 @@ void cwiid_callback(cwiid_wiimote_t *wiimote, int mesg_count,
}
if (ad->cWiimote[wiimoteNumber].ir[0].valid && ad->cWiimote[wiimoteNumber].ir[1].valid)
{
- min = findMin (firstDisplay, ad->cWiimote[wiimoteNumber].ir[0].x,
+ min = findMinIR (firstDisplay, wiimoteNumber,
+ ad->cWiimote[wiimoteNumber].ir[0].x,
ad->cWiimote[wiimoteNumber].ir[1].x,
ad->cWiimote[wiimoteNumber].ir[2].x,
ad->cWiimote[wiimoteNumber].ir[3].x);
- max = findMax (firstDisplay, ad->cWiimote[wiimoteNumber].ir[0].y,
- ad->cWiimote[wiimoteNumber].ir[1].y,
- ad->cWiimote[wiimoteNumber].ir[2].y,
- ad->cWiimote[wiimoteNumber].ir[3].y);
+ max = findMaxIR (firstDisplay, wiimoteNumber,
+ ad->cWiimote[wiimoteNumber].ir[0].x,
+ ad->cWiimote[wiimoteNumber].ir[1].x,
+ ad->cWiimote[wiimoteNumber].ir[2].x,
+ ad->cWiimote[wiimoteNumber].ir[3].x);
xRange = max - min;
}