
Wii Remote Communication API
C++ API for Windows
Wiim (
"whim" or "wheem", if you prefer) is a simple set of C++ classes that allow you to connect
to your Wii remote through Windows' HID interface to send and receive commands.
Right now you can receive button presses and motion data as
well as set rumble and LED status. There's no support for IR or any extension devices yet. Miis are another possibility, but they're already well supported elsewhere.
Demo
Disclaimer: This is barely "alpha" software. If you choose to download and use it, I am not responsible for anything that happens
to your computer as a result. I don't offer any support but the code is available for your edification.
This demo is an homage to
Lunar Lander. It only has one level, so I wouldn't really call it a game. It's only playable with a Wii remote.
Instructions
Roll left and right to tip your lander. Press 'A' to fire the thruster. 'Q' quits and 'R' resets. Try to set down gently on the landing pad in yellow. Don't touch the edges of the screen or the terrain or you'll explode. (By explode I mean turn
your lander red.)
Running / Building
I've only been able to test this on my setup using the BlueSoleil Bluetooth Stack and a cheap Zonet Bluetooth adapter. If you're able to use GlovePIE, you should be able to run this program. Make sure the Wii remote's connected and you're able to connect to the "Bluetooth Human Interface Device" Service. If you have success, let
me know!
If you're interesting in using the library for development there are a few prerequsities you need to have. The demo also uses SDL, so you'll need to have a
copy of the latest
SDL DLL and the set of headers. I've included an
SDL_gfx project with the files slightly modified to build a DLL with Visual Studio.
- HID.LIB
- HIDPI.H
- HIDSDI.H
- HIDUSAGE.H
- SetupAPI.H
- SetupAPI.LIB
You can get these
here. Put them in the same folder as the rest of the source code. (I would include them in the source package but I'm not sure about their redistributability.) This code is free to reuse/modify
so long as the message in the source file is left intact.
SVN
The source is publicly accessible here:
http://wiim.googlecode.com/svn/trunk/. If you want write access to it, send me a note. The google page for this project is
here.
Example Usage
vector<Wiimote> wiimotes = HIDDevice::ConnectToHIDDevices<Wiimote>();
if (wiimotes.size() < 1) return; // Didn't find any remotes
Wiimote & wiim = wiimotes[0];
wiim.SetLEDs(0, 1, 1, 0); // Set the LEDs to show we've connected
wiim.StartListening(); // Start listening to input reports
wiim.RequestMotionData(); // Request the remote start sending back motion data
while (..game loop..)
{
Position p = wiim.GetLastMotionData();
// Handle motion input
Button a = wiim.GetButtonState("A");
// Handle button input
}
wiim.StopListening();
wiim.Disconnect();
In addition to this polling mode, there is another event-driven mode which is still in development that will let you subclass
the Wiimote class to receive event notifications liked ButtonPressed(Button) and ReceivedMotionData(MotionData).
Download
Download Lunar Lander Demo
Download Demo Source Code - Include Wiimote interface class. This is a Visual Studio 2005 solution.Thanks
Thanks to WiiLi.org for the technical information and LiquidIce's Wii Hacks for the inspiration. The HID Page also provided some essential code to get started.
Other Stuff
Contact me - Ideas, contributions, scathing criticisms welcome!
Some other projects of mine:
BlogLib
-- XML-RPC library for Movable Type/MetaWeblog/Blogger APIs.
WallMonster
-- Desktop wallpaper rotator.
EnblendGUI
-- Interface for panoramic image blending utility.
Back to digitalretrograde.com