Wii Remote emulator

Navigation

Skip navigation.

Site search

Site navigation

Details and download

What it does

Attempts to emulate the Wii Remote API and JavaScript events for Wii using a mouse and keyboard. This should allow many games or special pages written for the Internet Channel on Nintendo Wii to work on normal desktop browsers. Simply include this script on a page that is designed to work with a Wii Remote, and it will allow the user to use their keyboard and mouse to perform the functions of the Wii Remote. A mouse with a scroll wheel is required.

The script can also be used as a User JavaScript.

Controls

Wii RemoteMouse/keyboard
Remote cursorMouse cursor
Left/right/up/downLeft/right/up/down
RollMouse wheel
DistanceToggle between roll and distance by pressing T, then mouse wheel
ALeft click or Enter/Return
BB
+P
-M
11
22

The script displays a small status icon in the top-right corner, showing the current roll and distance. This can be clicked to make it swap to the left side, to prevent it obscuring something important.

What the script provides

The script emulates the opera.wiiremote API provided by the Internet Channel on Wii. It emulates only a single remote; index 0. For consistency with the real API, this is emulated as if it were the isBrowsing remote. As a result, the hold property always contains the value 0, and any button detection must be done using JavaScript key and mouse event listeners, just like with a real isBrowsing Wii Remote.

The script emulates these buttons (which have different key codes to their desktop counterparts) by capturing the key events for the replacement keys in the desktop browser, preventing those events from being detected by the page (in most cases), and firing them again with the new key code that matches the codes produced by the Wii Remote. It also detects mousewheel scrolling, and uses that to manipulate roll and distance. The normal function of the mousewheel is cancelled, and the event is then prevented from being detected by the page (in most cases).

It is not perfect. A real Wii Remote would be able to manipulate distance, roll, and cursor position at the same time. This script makes distance and roll mutually exclusive. Even though both can be manipulated, they cannot be manipulated simultaneously.

Using the script

Just like with a real Wii Remote, the replacement keys have their own functions in the browser. In some cases (the arrows and Enter/Return keys), the function of the keys matches those of the Wii Remote. If the function of that key has undesirable effects on the page, make sure that you prevent the default action of that key (using preventDefault or one of its alternatives). The script will detect that you have cancelled the event, and will cancel the original key events from the user's keyboard as well.

When these events are cancelled, the user will not be able to use any of the remapped keys in any forms on the pages where you use this script. Any script that attempts to see desktop keyboard events will not be able to see the events for those keys (even if you do not cancel the events). It is up to you to make sure this is not a problem.

The script cannot work correctly on pages that use frames or inline frames. When it is over a frame contained by the current document, events and values will not update correctly. If it is used on a page inside a frame, the cursor position values will relate to the individual frame, and not the position on the screen. The script can work over plugin content, but only if the plugin does not prevent the mouse events from being detected by the page. Once a plugin has been focused (by clicking on it, etc.), the key remapping will no longer work, until the page (and not the plugin) is focused again.

Note that as well as displaying the status icon on every page where it is used, the script also prevents the mouse wheel from working normally, so it should only be included on pages where it is actually needed.

Note also that since the Wii Remote API is provided on the window.opera object, this script creates that object in browsers that do not provide it. Any JavaScript-based browser detects later on in the page may incorrectly identify these browsers as Opera. If this will cause a problem, make sure that you do not have any scripts on the page after this script, if they detect specific browsers.

Compatibility notes

How well a page written for the Wii's Internet Channel works on desktop browsers depends on many things, but in most cases, if it works on Wii, it works in Opera on Desktop (since they are the same browser under the chrome). It may or may not work in Firefox and Safari/Chrome as well, but that depends on whether or not it uses some part of CSS or JavaScript that they do not support. This script cannot change that, and it is up to the individual page to use something that will work in these browsers if needed.

This script needs to be able to re-map key events, to convert them from one key code to another. This requires capturing event listeners and the ability to manually fire events. It also needs to be able to display the status icon using canvas. Neither of these are possible in Internet Explorer 8-, so this script cannot work there. It also needs to be able to detect scrolling with the mouse wheel. This currently narrows it down to; Opera 9+, Mozilla/Firefox 1.5+, Chrome/Safari 2+, IE 9+ (standards mode only).

Demo

The following list is a readout of all of the Wii Remote API variables that the script is emulating:

This demonstration requires JavaScript support
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.