I wanted to build a little setup to control my Phillips hHue lights with a wii remote and stumbled on Dan Yocom's node-wii project. I have nodejs v6.2.0 installed on my laptop and node-wii only worked with versions <0.12.0 at which point some breaking changes were introduced to the V8 api.
I started off thinking this would be a good opportunity to learn how to write my own C++ addons for node and that I would rewrite wii-node from scratch to be compatible with newer versions of node. However, by the time I was done I realized I had copied a ton of the old code and really only updated it to work with the new V8 api. So having said all that, I have attempted to include the original license, readme, etc... and will obviously leave all the attributions to the original authors who made this little project possible!
Created by Tim Branyen @tbranyen
Modified by Andrew Brampton @TheBramp
Modified by Dan Yocom
Updated for node 6.2.0 by Lucas Tetreault
node-wii provides asynchronous native bindings to the libcwiid C API.
To run node-wii you need Node.js (v6.2.0 - was not tested with any other versions), bluez, and libcwiid installed. To run unit tests you will need to have git installed and accessible from your PATH to fetch any vendor/ addons.
It is sufficient enough to rely on the system package manager to install libcwiid and bluez. Refer to your distros repository search to find the correct module names and installation procedure.
Ensure you have the dependancies installed
$ sudo apt-get install libbluetooth-dev libcwiid-dev
$ sudo npm install -g node-gyp
Install node-wii by cloning source from GitHub and use npm to build and install:
$ git clone git://github.com/danyocom/node-wii.git
$ cd node-wii
$ npm -d install
A demo applicaton can be run like so:
$ node example/simple/server.js
node-wii currently does not run on either Mac OS X or Windows machines. This
is a problem with libcwiid
. A future plan is to fork libcwiid
and write
support for at least Apple OS X.
var wii = require("node-wii");
var wiimote = new wii.WiiMote();
// You may specify a mac address to your wiimote, or use 00:00:00:00:00
wiimote.connect("00:00:00:00:00", function(err) {
if( err ) {
console.log( 'Could not establish connection' );
return;
}
// Enable rumble
wiimote.rumble(true);
// Turn on led"s 1 and 3
wiimote.led(1, true);
wiimote.led(3, true);
// Turn off led 3
wiimote.led(3, false);
// Get IR Data
wiimote.ir(true);
wiimote.on("ir", function(points) {
for (var p in points)
console.log("Point", p['x'], p['y'], p['size']);
});
});
- connect
- disconnect
- accelerometer
- button
- ir
- status
- Cleaned Up Readme File
- Disabled console debug output
- Renamed project to node-wii for publishing on npmjs.org
- Fixed pacakge.json to point to the node-wii.js stub instead of erronusly trying to load the binary directly
- Upgraded to support node 0.10.0
- Change build system to node-gyp
- Change event framework from EIO to UV
- Added a new example using socket.io
- Changed the use of cwiid to be truely async
- Some useful methods implemented
- Partial examples in example directory
If you find this project of interest, please document all issues and fork if you feel you can provide a patch.