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 WiiNintendo.net 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?
The Using the Wiimote buttons in Flash article by Aral Balkan, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial 2.0 UK: England License.
I don’t get it, why don’t key presses register anything in flash – if nintendo think they do and opera probably has told them or agreed at least at some point and maybe adobe too then what is the issue with the flash player implementation that is causing them not to work? I can only think it has to be a bug, and in which case maybe it will be resolved when the final opera browser ships?
Does both the event listener method and the old skool way of attaching key events fail?
This has to be something that will get fixed – otherwise what is the point?
[...] EDIT: Apparently not, Flash doesn’t get the key events although Javascript does. Still, this is the beta version of the Internet Channel, it’s likely an oversight. Posted in Actionscript / Flash, Gaming, Programming | [...]
Hi Jon,
I’m not sure whether it’s a bug or a feature :) It may just be that Nintendo doesn’t want Flash developers competing too readily with their own games, etc. Of course, it could also just be a bug. I have no inside information either way on the subject.
Using the Key listener doesn’t work and neither does polling Key.isDown on enterFrame. I didn’t try an onClipEvent, but that really shouldn’t make a difference.
Even without the other buttons, there are a world of applications that can be built in Flash for the Wii. Having the other buttons, of course, would make it even better — especially for Flash games.
Perhaps you put a timer to steal focus back to the document to alleviate the Flash focus problem.
Does LocalConnection work? If so how about just writing a new SWF on each keypress? I’m working on a gesture recogniser right now so will post if I have some luck today. p.s. My code is 2764 0630 2609 7929.
Hey Richard,
That’s how the Flash/JS Integration Kit works but, at least in my tests, the browser window needed to have focus for it to work and there was a lag.
Ah sorry :) Ok well “phase one” is complete, it will recognise a backslash, forward slash and circle gesture (across the entire screen/grid only, as I haven’t implemented up/downscaling of gestures due to CPU cost at present).
http://richardleggett.co.uk/wii
Tomorrow I have some things to do like find a new place to live but will have a simple game up using this shortly. It’s not as good as I hoped, but with some refining (and practice for the user) I think it could be used for simple 2-5 gesture games (particularly if I can get upscaling working).
Also you will notice at the moment I have opted for a low-res grid, with the classes I have no you can alter this but onMouseMove on the Wii is not as responsive or frequent as with the desktop, so keeping the resolution nice and low means you get more “hits”, again I’m going to tweak later on.
http://wii.teamxlink.co.uk/
how does this work?
I’ve come up with a method that seems to work quite well (at least I’d say that there is no lag), except for an optical glitch that is caused by Opera treating the navigation cross also as a TAB key in order to switch the keyboard focus: http://www.quasimondo.com/archives/000638.php
[...] Mario has solved the Wiimote problem on the Flash Player in an ingenious way. He sets the scale of one SWF to the keycode captured in JavaScript and uses the resize event of the Stage to capture this value and pass it to the actual movie using LocalConnection. Rock on, as John would say! [...]
[...] Top 10 RIA events in 2006 99 coolest photo in 2006 Using Wii con Flash Using Wii con Flash 2 Flash dentro de Photoshop CS3 Sony Ericsson Store con Flex IFBIN 2.0 App Apollo para 2007 Virus en red de XServe Sistema de refrigeraciòn para XCBox 360 Reloj de superman con proyector de hora Dìa de los inocentes “iPlay” Nintendo y Apple unen fuerzas Phill Harrison y sus declaraciones Edifico iPod Màs de Phill Harrison Una màs El cinturòn de Ferzon PS3 Sucks ? Desarmando PS3 Wii en pantalla de cine [...]
I have a library that does something similar to FlashJS, but might have a little less lag (to my knowledge, FlashJS appends a query string to the swf url every time it sends a message to Flash, which causes the browser to redownload the swf file from the server every time – my version does not).
You can check this out here (the example is broken atm): http://www.unfocus.com/projects/source/
I haven’t updated the communication stuff much recently, since ExternalInterface is becoming the standard, but it should still work. When I get a Wii (probably in the next few weeks) I will certainly see if I can come up with something to help out (although, I’m sure someone will figure out how to do this before I get to it).
Kevin N.
Hi Kevin,
Sounds great — do let me know of your progress. In the meanwhile, have you seen Mario’s solution?
http://aralbalkan.com/828
Hello,
thanks for this interesting search.
Do you believe that is it possible to take a listener of wiimote’s moves in air?
bye,
Matt.
基礎情報…
基礎情報 Wiiで便利なツールを開発する際に気をつけなければならない事等 ▲ ▼全体 フォントサイズは24px程度がいいらしい ▲ ▼html DSブラウザとほとんど一緒? DSBwikiより…
[...] http://aralbalkan.com/825 [...]
Aral,
I’ve been playing with a different solution for the desktop, allowing me to get full two way Wiimote/Flash communication including info from the motion sensors, all buttons, nunchuck etc, and allowing Flash to control the Wiimote’s rumble and lights. It’s not really an end user solution as it relies on a bunch of other apps for communication, but with a bit more refinement could prove handy for demos and installations…
http://www.dustypixels.com/blog/2007/01/29/wiimote-flash-first-two-way-communication-tests/
A
Hey Adam,
That is very cool. I couldn’t find any contact info on your blog — can you email me if you get this (aral at the domain of this site.) Would love to talk to you.
Aral
Hi Aral,
Have you managed to get some info regarding Adam’s demo? From what I can conclude he wrote some application that captures Wii’s movements/clicks and translates them into keyboard presses/mouse movements that flash responces to. My only question is how did he managed to return the data back to Wii (leds switching/ vibration function)? Also, how in the hell is the controller hooked up on the PC?
Quite impressive.
The wiimote is connected using a bluetooth usb adapter. They cost about 10 to 60 bucks. Try bestbuy. The 35 dollar one works for sure. I have it.
[...] The big problem with Flash on the Wii is that the version of Flash 7 that is running in Opera is apparently pretty stripped down and doesn’t work with the Wii-Remote’s directional pad. People like Aral Balkan and Mario Klingemann have been messing around with a few work-arounds. [...]
[...] . wiiplayable.com . aral balkan 1 . aral balkan 2 . wiihacks . wiiNintendo [...]
[...] Es gab auch schon verschiedene Ansätze die Bewegung der WiiMote im Browser der Wii (Opera mit dem Flash Player 7) zu nutzen, was aber nicht ganz unproblematisch ist, mehr dazu in diesen beiden Blogs: Blog von Aral Balkan Blog von Mario Klingemann [...]
[...] Es gab auch schon verschiedene Ansätze die Bewegung der WiiMote im Browser der Wii (Opera mit dem Flash Player 7) zu nutzen, was aber nicht ganz unproblematisch ist, mehr dazu in diesen beiden Blogs: Blog von Aral Balkan Blog von Mario Klingemann [...]
[...] . fwiidom.org . wiiplayable.com . aral balkan 1 . aral balkan 2 . wiihacks . wiiNintendo . freesome.com [...]
I’ve always been trying to make games for comercial game systems, and have found that you can sometimes just find the PC keyboard keys that corospond to the game systems controls. After playing a few games designed for the wii that use the wiimotes buttons, I think I’ve found a few keys.
Wii = PC
D-Pad = arrow keys
1 = a
2 = s
Let me know if I’m wrong, but I think they work. So, wouldn’t it just be as simple as programing the flash to respond to those PC keys instead?
[...] The Wii is capable of running a special version of the Opera browser called "Internet Channel" which if you ask me is a bit of strange name, but anyhow… And on this browser, you can run Adobe Flash 7 player! There are of course limitations which your PC doesn’t have, for example the resolution is limited to 640×480 and under, the wiimote takes some extra effort, sometimes needs Javascript and of course you don’t have a keyboard on the wii, so keyboard actions are out! [...]
基礎情報…
基礎情報 Wiiで便利なツールを開発する際に気をつけなければならない事等 ブラウザ仕様も目に通しておくといいかも ▲ ▼全体 フォントサイズは24px程度がいいらしい。大文字で…
HOWTO use the Wiimote buttons in Flash…
A while back, WiiNintendo posted the keycodes that are detectable by Javascript when the Wii’s buttons are pressed. With this ability, you can create Javascript games that will play on your Wii. Unfortunately, even though the Wii browser ships……
[...] ??????? ???????wiimote?nunchck???! ??linux,mac osx,windows??????? ??flash?,max/msp???dj,vj?????? ????????????????????? [...]
If you want the short answer, no. The problem is that the version of flash on the wii cannot or cannot with typical functions interpret butons from the wiimote. Mabye it would be possible to, as adam has done recieve the wiimotes bluetooth data on a computer. The data could be modified by a program to contain key signatures that flash could interperate. It could then transmit the modified data to the wii and viola, you now have a solution that will have cost you hundreds of hours and dollars, if it works.
@dvanex: Check out Mario’s solution in the trackbacks. He uses a generated SWF and LocalConnection to proxy the key codes from JavaScript to Flash. Works really well. So yes, it can be done :) It would be better if native support was added in the future though.
Checkout wiiflash.org
[...] 提前拉出横幅, 欢迎混世大魔王wiimote和nunchck两兄弟! 大闹linux,mac osx,windows的两兄弟,详情 踢翻flash界,max/msp界以及dj,vj界的两兄弟, 今日从香港启程,预计三日后屈尊于鲸鱼手中。 [...]
I have one php page in that i include few javascript code for auto load purpose of this page but this thing is run on this page when no event fire on screen for few minute then and then only auto page reload otherwise not like a screen saver if our mouse move or click or scroll or any key press user with keyboard then screen saver is not working
This thing you give nice but is it possible this thing in java script.
[...] Player 7) zu nutzen, was aber nicht ganz unproblematisch ist, mehr dazu in diesen beiden Blogs: Blog von Aral Balkan Blog von Mario [...]
[...] Wiimote buttons in Flash – Aral Balkan [...]
[...] Wiimote buttons in Flash – Aral Balkan [...]
Would you maybe explain how you use those keys IN a script?