summaryrefslogtreecommitdiff
path: root/wiimote.c
diff options
context:
space:
mode:
Diffstat (limited to 'wiimote.c')
-rw-r--r--wiimote.c40
1 files changed, 39 insertions, 1 deletions
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);