diff --git a/readme.md b/readme.md index 66cf980..9441118 100644 --- a/readme.md +++ b/readme.md @@ -12,6 +12,11 @@ as it's notoriously crippled. It aims to offer a solid, documented, performant A understand and pick up. With this library, you can have up to 4 Wii-motes interacting with your webpage at once, a dynamic not found in other web browsing mediums. +You can find a built source file and a _minified_ source file for production use in the **/js/** directory. +To play with a live example, load up the demo (_index.html_) on your own server, or feel free to use mine: + + **wii-js Demo: [http://venodesigns.net/wii/](http://venodesigns.net/wii/ + Questions, comments, criticism and praise can be directed to me at the following outlets: - You can email me at **ryan [at] venodesigns (dot) net**. @@ -19,6 +24,7 @@ Questions, comments, criticism and praise can be directed to me at the following - Contact me through **[my website](http://venodesigns.net)** - **Technical issues can be filed on the [wii-js GitHub Issues Tracker](https://github.com/ryanmcgrath/wii-js/issues)** + Example Usage ---------------------------------------------------------------------------------------------- ``` javascript @@ -34,6 +40,7 @@ wiimote2.when('pressed_a', function() { }); ``` + Technical Documentation ---------------------------------------------------------------------------------------------- The largest issue with making interactive pages that work with the Wii has been that the API has @@ -86,6 +93,37 @@ isn't able to see the TV/sensor bar, so be sure to check this! - **y** - The y coordinate where the Wii Remote is pointing to on the screen. Odd one; can be found as low as -48, as high as the height of the current webpage + toolbar height, if enabled. Tinker with this one for your purposes. + +Extra Tips and Tricks +------------------------------------------------------------------------------------------------------------------ +One semi-useful trick to point out about this library is that each of your callback functions get passed two +arguments by default - a reference to the Wiimote you're working with, and the raw Wiimote status object that the +Wii reports back to the library. You get this in a normalized fashion, instead of having to deal with the odd polling +issues present in the browser. + +``` javascript +var wiimote = new Wii.Remote(1, {horizontal: false}); + +wiimote.when('pressed_a', function(wii_remote, wii_remote_status) { + /* Alert an internal confidence level provided by the Wii. */ + alert(wii_remote_status.dpdValidity); +}); +``` + +Debugging Javascript on the Wii is also nothing short of incredibly annoying, so I've included a convenience function +for running through error messages. My typical debugging strategy with any Wii-related code would always start with +the following: + +``` javascript +try { + // Whatever function I execute +} catch(e) { Wii.util.debug(e); } +``` + +The rate at which this function will improve is commensurate with how much more time and effort I can afford to put +into this project. Feel free to fork/patch/enhance if you need more. ;) + + Why the button limitations? ------------------------------------------------------------------------------------------------------------------ The Nintendo Wii treats the primary controller differently than the other ones, and doesn't report any action @@ -98,6 +136,34 @@ It's a work in progress to see what can be done about these, but it's impossible of it unless Nintendo and/or Opera can come out with something new. +Known Issues +------------------------------------------------------------------------------------------------------------------ +**Primary Wiimote is a bit more responsive than the extra 3** +This library works by polling the status of the three extra Wii-remotes in 100ms intervals and dispatching events +based on this. Anything lower than 100ms causes the Wii to run into memory limitations, and the single-threaded +nature of the browser doesn't really help this issue. + +The primary Wii-remote uses an odd combination of DOM-esque callbacks; due to this, it reports _more frequently_ than +the other Wii-remotes. It's not a showstopper by any means, but for small games it would in theory give a weighted advantage. +I'll probably end up throttling this through the library by means of a flag, e.g "game_mode": true in the initial options. + + +Building and Developing +------------------------------------------------------------------------------------------------------------------ +If you'd like to help with this library, you're more than welcome to. Simply fork it on GitHub, work away, then +issue me a pull request. I generally respond within 24 hours. + +The build system here is pretty simple - edits and changes go into the /js/src/ files, and you can run + + python build.py + +from the main directory to build a new version. The minifier here is YUI; Closure/UglifyJS are more aggressive, and +for some reason throw ridiculous issues in the Wii's browser that I've been unable to track down (and I don't have +more time to throw at it). + +In short, the builds require Python/Java, but once you've got them all installed you should only need the command above. + + Licensing, etc ------------------------------------------------------------------------------------------------------------------- wii-js is released under an MIT license. Just provide credit where need be if you choose to use this, it's taken quite