diff options
Diffstat (limited to 'wiimote.c')
-rw-r--r-- | wiimote.c | 40 |
1 files changed, 39 insertions, 1 deletions
@@ -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); |