WiiFlash(mac) で BalanceBoard をさっそくつなげていじってみた

By admin | 2009年2月11日

id:yuma_flughafen に11日が祝日だと言われて気づいたので土日まで待てずにいじってみました。
ちなみに これw
で、つなげるまでの方法をまたも忘れていたのでそれとできることを少し書いときます。

できること

  • バランスボードの4点の圧力がとれる
  • 圧力の中心の座標がとれる
  • 体重がとれる

ライブラリの使い方は基本的に wii リモコンと同じ。
コネクトエラーとかの処理を省き、ただ動作させるだけなら flash 側はこれだけで動作します。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import org.wiiflash.Wiimote;
import org.wiiflash.events.WiimoteEvent;
import flash.events.Event;
 
var wiimote:Wiimote = new Wiimote();
myWiimote.connect ();
myWiimote.addEventListener( WiimoteEvent.UPDATE, onUpdated );
 
function onUpdated ( e:WiimoteEvent ):void {
        //全体の圧力(体重はこれ)
	total:Number = e.target.balanceBoard.totalKg;
 
        //4点の圧力
	topLeft:Number = e.target.balanceBoard.topLeftKg;
	topRight:Number = e.target.balanceBoard.topRightKg;
	bottomLeft:Number = e.target.balanceBoard.bottomLeftKg;
	bottomRight:Number = e.target.balanceBoard.bottomRightKg;
 
        //中心の圧力の座標
        center:Point = e.target.balanceBoard.centerOfGravity;
}

WiimoteEvent.UPDATE で登録したメソッドで処理するだけですね。

BalanceBoard の繋げ方

で、地味にはなまったのがこっち。
認識しないことがよくあって困った。

  • WiiFlashServerJ を起動。
  • Bluetooth で BalanceBoard を接続。

これで接続がうまくいった際は WiiFlashServerJ の画面にアイコンが表示されます。
うまくいかない時は WiiFlashServerJ を再起動したり BalanceBoard を
つなげなおしたりをひたすらしてればいつかつながりますwwww


BalaceBoard のつなげかたは以前書いた日記を参考にしてもらえれば大丈夫かと。
WiiFlashを使ってflashでwiiリモコンを使ってみる(1)

ちなみにつながった画面はこんな感じ。

付属のサンプル
BalanceBoard 認識した画面

BalanceBoard で iphone のアプリの入力デバイスにできたらおもしろそうだと思った。
ちょっとがんばってみるかな。

WordPress Themes