summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <Sam@XPS-SUSE.site>2008-12-15 20:08:36 +0900
committerSam Spilsbury <Sam@XPS-SUSE.site>2008-12-15 20:08:36 +0900
commit281e7e9957df2b7db75b136dc0e1f80ce5f76943 (patch)
tree447cf014f36e06c7e060aecfb3ca9149ffbc5805
parente9dd7190b38bcc3c0ab61f1e187aea06f24fef4c (diff)
downloadwiimote-master.tar.gz
wiimote-master.tar.bz2
* Added base functions, ABI set and Index setHEADmaster
-rw-r--r--compiz-wiimote.h12
-rw-r--r--wiimote.c40
-rw-r--r--wiimote.xml.in2
3 files changed, 52 insertions, 2 deletions
diff --git a/compiz-wiimote.h b/compiz-wiimote.h
index ec507fe..fa06e20 100644
--- a/compiz-wiimote.h
+++ b/compiz-wiimote.h
@@ -320,10 +320,20 @@ typedef struct _CompWiimote
int count;
pthread_t connectWiimote; /* Threading Handler */
- struct _CompWiimote *next; // The future $$$$$$ =)
+ struct _CompWiimote *next;
} CompWiimote;
+typedef struct _WiimoteBaseFunctions
+{
+ CompWiimote * (*wiimoteForIter) (CompDisplay *d,
+ int iter);
+} WiimoteBaseFunctions;
+
+CompWiimote *
+wiimoteForIter (CompDisplay *d,
+ int iter);
+
/* Shortcut Macros --------------------------------------------------- */
#define toggle_bit(bf,b) \
diff --git a/wiimote.c b/wiimote.c
index ffc382a..43db5a2 100644
--- a/wiimote.c
+++ b/wiimote.c
@@ -24,6 +24,24 @@
static int corePrivateIndex;
int wiimoteDisplayPrivateIndex;
+int functionsPrivateIndex;
+
+CompWiimote *
+wiimoteForIter (CompDisplay *d,
+ int iter)
+{
+ WIIMOTE_DISPLAY (d);
+
+ CompWiimote *wiimote;
+
+ for (wiimote = ad->wiimotes; wiimote; wiimote = wiimote->next)
+ {
+ if (wiimote->id == iter)
+ return wiimote;
+ }
+ return NULL;
+}
+
/* Wrappable Functions --------------------------------------------------- */
static void
@@ -139,7 +157,11 @@ wiimoteRemoveWiimote (CompDisplay *d,
}
}
}
-
+
+static WiimoteBaseFunctions wiimoteFunctions =
+{
+ .wiimoteForIter = wiimoteForIter
+};
/* Core Initialization --------------------------------------------------- */
@@ -157,6 +179,13 @@ wiimoteInitCore (CompPlugin *p,
{
return FALSE;
}
+
+ functionsPrivateIndex = allocateDisplayPrivateIndex ();
+ if (functionsPrivateIndex < 0)
+ {
+ freeDisplayPrivateIndex (wiimoteDisplayPrivateIndex);
+ return FALSE;
+ }
firstDisplay = c->displays;
@@ -168,6 +197,7 @@ wiimoteFiniCore (CompPlugin *p,
CompCore *c)
{
freeDisplayPrivateIndex (wiimoteDisplayPrivateIndex);
+ freeDisplayPrivateIndex (functionsPrivateIndex);
}
/* Display Initialization --------------------------------------------------- */
@@ -177,6 +207,7 @@ wiimoteInitDisplay (CompPlugin *p,
CompDisplay *d)
{
WiimoteDisplay *ad;
+ CompOption *abi, *index;
if (!checkPluginABI ("core", CORE_ABIVERSION))
return FALSE;
@@ -196,6 +227,13 @@ wiimoteInitDisplay (CompPlugin *p,
}
d->base.privates[wiimoteDisplayPrivateIndex].ptr = ad;
+ d->base.privates[functionsPrivateIndex].ptr = &wiimoteFunctions;
+
+ abi = wiimoteGetAbiOption (d);
+ abi->value.i = WIIMOTE_ABIVERSION;
+
+ index = wiimoteGetIndexOption (d);
+ index->value.i = functionsPrivateIndex;
wiimoteSetToggleKeyInitiate (d, wiimoteToggle);
wiimoteSetDisableKeyInitiate (d, wiimoteDisable);
diff --git a/wiimote.xml.in b/wiimote.xml.in
index 214e59b..89c234e 100644
--- a/wiimote.xml.in
+++ b/wiimote.xml.in
@@ -5,6 +5,8 @@
<_long>Compiz interface for the Nintendo Wii Remote.</_long>
<category>Utility</category>
<display>
+ <option name="abi" read_only="true"/>
+ <option name="index" read_only="true"/>
<group>
<_short>Bindings</_short>
<option name="toggle_key" type="key">