Introduction
Features
Examples
Download
Libwiimote is a C-library that provides a simple API for communicating with the Nintendo Wii Remote (aka. wiimote) on a Linux system. The goal of this library is to be a complete and easy to use framework for interfacing applications with the wiimote.
Currently, this library provides the following features:
Inputs:
Outputs:
// print wiimote accelerometer data to stdout. // replace xx:xx:xx:xx:xx:xx with the correct bluetooth address. #include <stdio.h> #include "wiimote_api.h" int main() { wiimote_t wi; wiimote_connect(&wi, "xx:xx:xx:xx:xx"); wi.mode.acc = 1; // enable accelerometer while (wiimote_is_open(&wi)) { wiimote_update(&wi); // synchronize with wiimote if (wi.keys.home) { // check if home key is pressed wiimote_disconnect(&wi); } printf("x=%d y=%d z=%d\n", wi.axis.x, wi.axis.y, wi.axis.z); } } // print ir-sensor and nunchuk joystick states. #include <stdio.h> #include "wiimote_api.h" int main() { wiimote_t wi; wiimote_connect(&wi, "xx:xx:xx:xx:xx"); wi.mode.ir = 1; // enable ir-sensor wi.mode.ext = 1; // enable nunchuk (not necessary) while (wiimote_is_open(&wi)) { wiimote_update(&wi); if (wi.keys.home) { wiimote_disconnect(&wi); } printf("joyx=%d joyy=%d\n", wi.ext.nunchuk.joyx, wi.ext.nunchuk.joyy); printf("irx=%d iry=%d size=%d\n", wi.ir1.x, wi.ir1.y, wi.ir1.size); } } // disable all leds at once wi.leds.bits = 0; // activate leds 1 and 2 wi.leds.one = 1; wi.leds.two = 1; // play a short sound sample uint8_t tone[20] = { 0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c, 0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c }; wiimote_speaker_init(&wiimote, WIIMOTE_FMT_S4, WIIMOTE_SPK_44800HZ); wiimote_speaker_play(&wiimote, tone, 20);
The latest version of libwiimote is 0.4 and can be downloaded from the download section.