Using the Wiimote buttons in Flash has posted a list of key codes that the various buttons on the Wiimote generate, stating that they work in Flash and JavaScript. Well, that's half accurate: They do work in JavaScript but not in Flash. Adding a Key listener in Flash doesn't register anything when the buttons on the Wiimote are pressed.

My first thought was to use the Flash/JavaScript Integration Kit (since the player in the Wii is version 7, we can't use ExternalInterface) to relay the key events that the buttons generate from JavaScript to Flash. Easier said than done.

After some fiddling, I got the key codes to transfer to Flash but there are three show stoppers with this method:

First and foremost, it doesn't work when the Flash movie has focus. I tried every method I know of capturing events in JavaScript and none of them results in the JavaScript event handler being called when the Flash movie has focus and a key is pressed.)

Secondly, you cannot have a full screen Flash movie and use this method due to the way Flashjs works (it creates embeds a new SWF every time you call a method in Flash and passes the uid, method to call and its arguments as FlashVars to it. This SWF then uses the uid and LocalConnection to talk to your actual SWF.) So if your actual SWF takes up the whole screen, this additional SWF will result in a vertical scroll arrow displaying on the Wii.

Finally, even if the first two show stoppers could somehow be resolved, when the Flash/JS communication does work (i.e., when the page has focus), there is lag that would probably be unacceptable for games and even for interface items.

Also, the list of key codes given in the article has two typos. The A button has a key code of 13, not 170 and the 2 button has a key code of 173, not 17. So the actual list of key codes for the Wiimote is:

↑ 175 ↓ 176 → 177 ← 178 A 13 B 171 - 170 + 174 1 172 2 173

The next thing I'm going to try is plain old SetVariable. But first a bout of tennis on the Wii with Dave! :) If anyone has other ideas, I'm all ears. Please leave a note in the comments.

Update: So the tennis game can wait: SetVariable doesn't work on the Wii. Damn.

OK, so maybe I can use FSCommand to poll the JavaScript instead... *Doh!* Of course, I can't because functions called from FSCommand can't return values.

OK, so that's it from me. Ideas?

How about: Nintendo, please implement Key events for the Wiimote controller buttons like there are in JavaScript. Pretty please?