コード例 #1
0
        //wiimoteのステータスが変わったのを検知して起動するイベント
        void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs e)
        {
            //表示系(Form)の情報更新
            WiimoteInfo wi = mWiimoteMap[((Wiimote)sender).ID];

            wi.UpdateState(e);

            //WiimoteStateの値を取得
            wiimoteState = e.WiimoteState;

            switch (wiimoteState.ExtensionType)
            {
            //接続相手がbalanceboardであれば
            case ExtensionType.BalanceBoard:

                //デバッグ表示用
                //重さ(Kg)
                string weight = wiimoteState.BalanceBoardState.WeightKg + "kg";
                //重心のX座標
                string posX = "X:" +
                              wiimoteState.BalanceBoardState.CenterOfGravity.X;
                //重心のY座標
                string posY = "Y:" +
                              wiimoteState.BalanceBoardState.CenterOfGravity.Y;

                //送信用データリストを更新する
                //ここで横流しするデータを更新している
                WiimoteMessage message = new WiimoteMessage();                                                          //データ用意
                message.index   = wi.index;
                message.weight  = wiimoteState.BalanceBoardState.WeightKg;
                message.copPosX = wiimoteState.BalanceBoardState.CenterOfGravity.X;
                message.copPosY = wiimoteState.BalanceBoardState.CenterOfGravity.Y;

                message.loadTopRight    = wiimoteState.BalanceBoardState.SensorValuesKg.TopRight;
                message.loadTopLeft     = wiimoteState.BalanceBoardState.SensorValuesKg.TopLeft;
                message.loadBottomRight = wiimoteState.BalanceBoardState.SensorValuesKg.BottomRight;
                message.loadBottomLeft  = wiimoteState.BalanceBoardState.SensorValuesKg.BottomLeft;

                server.UpdateMessage(wi.index, message);                                                                //更新

                break;
            }
        }
コード例 #2
0
        //wiimoteのステータスが変わったのを検知して起動するイベント
        void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs e)
        {
            //表示系(Form)の情報更新
            WiimoteInfo wi = mWiimoteMap[((Wiimote)sender).ID];

            wi.UpdateState(e);

            //WiimoteStateの値を取得
            wiimoteState = e.WiimoteState;

            //デバッグ表示用

            //string xacc = wiimoteState.AccelState.Values.X + "kg";

            //string yacc = "X:" +
            //wiimoteState.AccelState.Values.Y;

            //string zacc = "Y:" +
            //wiimoteState.AccelState.Values.Z;

            //送信用データリストを更新する
            //ここで横流しするデータを更新している

            /*WiimoteMessage message = new WiimoteMessage();                                                      //データ用意
             * message.index = wi.index;
             * message.xacc = wiimoteState.AccelState.Values.X;
             * message.yacc = wiimoteState.AccelState.Values.Y;
             * message.zacc = wiimoteState.AccelState.Values.Z;
             * message.up = wiimoteState.ButtonState.Up;
             * message.down = wiimoteState.ButtonState.Down;
             * message.right = wiimoteState.ButtonState.Right;
             * message.left = wiimoteState.ButtonState.Left;
             * message.a = wiimoteState.ButtonState.A;
             * message.b = wiimoteState.ButtonState.B;
             * message.home = wiimoteState.ButtonState.Home;
             *
             * server.UpdateMessage(wi.index, message);
             */


            switch (wiimoteState.ExtensionType)
            {
            //接続相手がbalanceboardであれば
            case ExtensionType.MotionPlus:



                //デバッグ表示用
                //重さ(Kg)
                //string weight = wiimoteState.BalanceBoardState.WeightKg + "kg";
                //重心のX座標
                //string posX = "X:" +
                //  wiimoteState.BalanceBoardState.CenterOfGravity.X;
                //重心のY座標
                //string posY = "Y:" +
                //    wiimoteState.BalanceBoardState.CenterOfGravity.Y;

                //送信用データリストを更新する
                //ここで横流しするデータを更新している
                WiimoteMessage message = new WiimoteMessage();
                message.index = wi.index;
                message.xacc  = wiimoteState.AccelState.Values.X;
                message.yacc  = wiimoteState.AccelState.Values.Y;
                message.zacc  = wiimoteState.AccelState.Values.Z;
                message.yaw   = wiimoteState.MotionPlusState.RawValues.X;
                message.pitch = wiimoteState.MotionPlusState.RawValues.Z;
                message.roll  = wiimoteState.MotionPlusState.RawValues.Y;
                message.up    = wiimoteState.ButtonState.Up;
                message.down  = wiimoteState.ButtonState.Down;
                message.right = wiimoteState.ButtonState.Right;
                message.left  = wiimoteState.ButtonState.Left;
                message.a     = wiimoteState.ButtonState.A;
                message.b     = wiimoteState.ButtonState.B;
                message.home  = wiimoteState.ButtonState.Home;


                server.UpdateMessage(wi.index, message);                  //更新



                break;
            }
        }