Overview |
Code samples |
API |
wii.js
Source code |
Test Page (display in Wii)
Code samples
Add the input event listeners to the page
<body onload="wii.setupHandlers()">
Create a wii.Controller
to handle input events
var wiimote = new Wiimote();
wiimote.handleA = function() { // override the handleA() method
alert('A button pressed!');
return true; // also let this event propagate to the browser
}
wii.addController(wiimote);
Create a subclass of wii.Wiimote
/** @constructor */
function MyWiimote() {
wii.Wiimote.call(null); // this is like super() in Java
}
MyWiimote.prototype = new wii.Wiimote(); // inherit Wiimote prototype
MyWiimote.prototype.handleA = function() { // override Wiimote.prototype.handleA()
alert('My A button pressed!');
return true;
}
Select a wii.Controller
class based on the browser type
// use this to develop your web site on a PC
var controller = (wii.isWiiOperaBrowser())
? new wii.Wiimote()
: new wii.KeyboardController();
wii.addController(controller);