コード例 #1
0
    private void Update()
    {
        if (!WiimoteManager.HasWiimote())
        {
            return;
        }

        wiimote = WiimoteManager.Wiimotes[0];

        int ret;

        do
        {
            ret = wiimote.ReadWiimoteData();
        } while (ret > 0);

        if (wiimote.Button.b)
        {
            // Retry
            Loader.Load(Loader.Scene.GameScene);
        }
        else if (wiimote.Button.home)
        {
            Loader.Load(Loader.Scene.MainMenu);
        }
    }
コード例 #2
0
    // -----------------------------------

    private bool FindWiimote()
    {
        WiimoteManager.FindWiimotes();

        if (WiimoteManager.HasWiimote())
        {
            wiimote = WiimoteManager.Wiimotes[0];
            wiimote.SendPlayerLED(true, false, false, false);

            // Mode = acceleration + extensions
            wiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL_EXT16);

            // Acceleration
            //wiimote.Accel.CalibrateAccel(AccelCalibrationStep.A_BUTTON_UP);

            // IR
            wiimote.SetupIRCamera(IRDataType.BASIC);

            Debug.Log("Wiimote found and set up");
            return(true);
        }
        else
        {
            wiimote = null;
            return(false);
        }
    }
コード例 #3
0
    void SearchAndInitialize()
    {
        WiimoteManager.FindWiimotes();

        if (!WiimoteManager.HasWiimote())
        {
            return;
        }
        else
        {
            playersActive = WiimoteManager.Wiimotes.Count;
            Debug.Log(playersActive);
            for (var i = 0; i < WiimoteManager.Wiimotes.Count; i++)
            {
                wiimotes.Add(WiimoteManager.Wiimotes[i]);
                wiimotes[i].SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL);
                wiimotes[i].SetupIRCamera(IRDataType.EXTENDED);
                wiimotes[i].SendPlayerLED(i >= 0, i >= 1, i >= 2, i >= 3);

                ir_pointer_list[i].GetComponent <Image>().color = playerColors[i];

                object[] changeColorUI = { i, playerColors[i] };
                SendMessage("SetColorPanel", changeColorUI);
            }

            for (int i = playerColors.Count - 1; i >= playersActive; i--)
            {
                SendMessage("HidePlayerPanel", i);
            }
        }
    }
コード例 #4
0
ファイル: C_Main.cs プロジェクト: AlexandreMagi/ProjetGD3
    public void FixedUpdate()
    {
        if (wiimoteMode && WiimoteManager.HasWiimote())
        {
            Vector2 vals           = wiimoteController.GetIRValues();
            float   distancePoints = Vector2.Distance(followingPosition, vals);

            float newPercentFollow;

            if (distancePoints < distanceToMinFollow)
            {
                newPercentFollow = .01f;
            }
            else if (distancePoints > distanceToMaxFollow)
            {
                newPercentFollow = .5f;
            }
            else
            {
                newPercentFollow = percentFollowFrame;
            }

            float x = followingPosition.x * (1 - newPercentFollow) + vals.x * newPercentFollow;
            float y = followingPosition.y * (1 - newPercentFollow) + vals.y * newPercentFollow;

            followingPosition = new Vector2(x, y);
        }
        else
        {
            followingPosition = Input.mousePosition;
        }
    }
コード例 #5
0
    //Used to connect / disconnect wii
    public void ConnectWii()
    {
        //If Wiimote is detected
        if (wiimote != null)
        {
            //Disconnect wii
            WiimoteManager.Cleanup(wiimote);
            wiimote = null;
        }
        else
        {
            WiimoteManager.FindWiimotes();  //Find for connected Wii Mote

            //Check if Manager has wii mote connected
            if (WiimoteManager.HasWiimote())
            {
                //Assign our variable to the first
                wiimote = WiimoteManager.Wiimotes[0];

                if (wiimote != null)
                {
                    wiimote.SendPlayerLED(true, false, false, false);
                }

                //Setup IR Camera
                bool IRSetUp = wiimote.SetupIRCamera(IRDataType.BASIC);

                print(IRSetUp);
            }
        }
    }
コード例 #6
0
ファイル: Menu.cs プロジェクト: Twifus/HeartHeartRevolution
    private void ConnectWiimotes()
    {
        WiimoteManager.FindWiimotes();

        nPlayers = 0;

        if (!WiimoteManager.HasWiimote())
        {
            readyToPlay = false;
            return;
        }

        readyToPlay = true;

        foreach (Wiimote remote in WiimoteManager.Wiimotes)
        {
            remote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL_EXT16);

            int ret;
            do
            {
                ret = remote.ReadWiimoteData();
            } while (ret > 0);

            remote.SendPlayerLED(nPlayers == 0, nPlayers == 1, nPlayers == 2, nPlayers == 3);
            nPlayers++;
            if (remote.current_ext != ExtensionController.NUNCHUCK)
            {
                readyToPlay = false;
            }
        }
    }
コード例 #7
0
    // Update is called once per frame
    void Update()
    {
        // If no wii remote is found, return
        if (!WiimoteManager.HasWiimote())
        {
            return;
        }


        // Get the currently connected wii remote
        wiiMote = WiimoteManager.Wiimotes[0];

        Debug.Log("Wii Remote Active");

        int ret;

        do
        {
            ret = wiiMote.ReadWiimoteData();

            if (ret > 0 && wiiMote.current_ext == ExtensionController.MOTIONPLUS)
            {
                Vector3 offset = new Vector3(-wiiMote.MotionPlus.PitchSpeed,
                                             wiiMote.MotionPlus.YawSpeed,
                                             wiiMote.MotionPlus.RollSpeed) / 95.0f;
                wiiMotionPlusOffset += offset;

                Debug.Log(wiiMotionPlusOffset.x);
            }
        } while (ret > 0);
    }
コード例 #8
0
 public void Reset()
 {
     if (WiimoteManager.HasWiimote())
     {
         WiimoteManager.Cleanup(_wiimote);
     }
     _wiimote = null;
 }
コード例 #9
0
ファイル: WiiTest.cs プロジェクト: misoten8/Mock
    // 更新処理
    void Update()
    {
        // 接続されていなかったら終了
        if (!WiimoteManager.HasWiimote())
        {
            return;
        }

        // 1Pに保存
        wm = WiimoteManager.Wiimotes[0];
        //int ret;
        //do
        //{
        //	// リモコンの情報を更新
        //	ret = wm.ReadWiimoteData();

        //	if (ret > 0 && wm.current_ext == ExtensionController.MOTIONPLUS)
        //	{
        //		Vector3 offset = new Vector3(-wm.MotionPlus.PitchSpeed,
        //										wm.MotionPlus.YawSpeed,
        //										wm.MotionPlus.RollSpeed) / 95f; // Divide by 95Hz (average updates per second from wiimote)
        //		wmpOffset += offset;

        //		//wmModel.rot.Rotate(offset, Space.Self);
        //	}
        //} while (ret > 0);

        // ボタン降下情報
        //wmModel.a.enabled = wm.Button.a;
        //wmModel.b.enabled = wm.Button.b;
        //wmModel.one.enabled = wm.Button.one;
        //wmModel.two.enabled = wm.Button.two;
        //wmModel.d_up.enabled = wm.Button.d_up;
        //wmModel.d_down.enabled = wm.Button.d_down;
        //wmModel.d_left.enabled = wm.Button.d_left;
        //wmModel.d_right.enabled = wm.Button.d_right;
        //wmModel.plus.enabled = wm.Button.plus;
        //wmModel.minus.enabled = wm.Button.minus;
        //wmModel.home.enabled = wm.Button.home;

        // 加速度取得
        //Debug.Log(wmAccel =wm.Accel.GetAccelVector());

        // 振っているか判定
        //wmSwing = wm.Accel.GetSwing();

        // Wiiリモコンプラスでなければモデルは回転しない
        if (wm.current_ext != ExtensionController.MOTIONPLUS)
        {
            //wmModel.rot.localRotation = initialRotation;
        }

        // モーションプラスがアクティブになっていければ終了
        if (!wm.wmp_attached)
        {
            return;
        }
    }
コード例 #10
0
 public bool isWiiMoteConnected()
 {
     // If no wii remote is found, return
     if (!WiimoteManager.HasWiimote())
     {
         return(false);
     }
     return(true);
 }
コード例 #11
0
 public bool onePressed()
 {
     // If no wii remote is found, return
     if (!WiimoteManager.HasWiimote())
     {
         return(false);
     }
     return(wiiMote.Button.one);
 }
コード例 #12
0
 void OnGUI()
 {
     if (!WiimoteManager.HasWiimote())
     {
         //GUI.Label (new Rect(Screen.width/2-100,20,200,200), "Wiimote Not Found!");
     }
     else
     {
         //GUI.Label (new Rect(Screen.width/2-100,20,200,200), "Wiimote Found!");
     }
 }
コード例 #13
0
    void SearchAndInitialize()
    {
        WiimoteManager.FindWiimotes();

        if (!WiimoteManager.HasWiimote())
        {
            return;
        }

        wiimote = WiimoteManager.Wiimotes[0];
        wiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL);
        wiimote.SetupIRCamera(IRDataType.BASIC);
        wiimote.SendPlayerLED(true, true, true, true);
    }
コード例 #14
0
ファイル: color.cs プロジェクト: tdunglas/Immersion
    // Update is called once per frame
    void Update()
    {
        DetectKeyPressed();
        Debug.Log(direction);
        couleur();
        if (!WiimoteManager.HasWiimote())
        {
            Debug.Log("no mote");
            return;
        }
        else
        {
            wiimote = WiimoteManager.Wiimotes[0];
            int ret;
            do
            {
                ret = wiimote.ReadWiimoteData();
            } while (ret > 0);

            //aDebug.Log(wiimote.Accel);
            keywii();

/*
 *              Debug.Log(wiimote.Ir.GetPointingPosition()[0]);
 *              Debug.Log(wiimote.Ir.GetPointingPosition()[1]);*/

            /*wiimote.Button.b;
             * wiimote.Button.one;
             * wiimote.Button.two;
             * wiimote.Button.d_up;
             * wiimote.Button.d_down;
             * wiimote.Button.d_left;
             * wiimote.Button.d_right;
             * wiimote.Button.plus;
             * wiimote.Button.minus;
             * wiimote.Button.home;*/

            Debug.Log("read data from wii -" + wiimote.ReadWiimoteData());
            string msg_accel = "accel :";

            msg_accel += " x " + wiimote.Accel.GetCalibratedAccelData()[0];
            msg_accel += " y " + wiimote.Accel.GetCalibratedAccelData()[1];
            msg_accel += " z " + wiimote.Accel.GetCalibratedAccelData()[2];

            Debug.Log(msg_accel);

            alternateLed();
        }
    }
コード例 #15
0
 void Update()
 {
     /////////////////////////////////
     //*wiimoteが見つかってない場合*//
     /////////////////////////////////
     if (!WiimoteManager.HasWiimote())
     {
         WiimoteManager.FindWiimotes();
         return;
     }
     /////////////////////////////
     //*wiimoteが見つかった場合*//
     /////////////////////////////
     _wiimote = WiimoteManager.Wiimotes[0];
 }
コード例 #16
0
 void Start()
 {
     if (Singleton != null)
     {
         Debug.LogError("Two WiimoteHandlers in scene at the same time!  Destroying extra WiimoteHandler.");
         Destroy(this);
         return;
     }
     WiimoteManager.FindWiimotes();
     if (WiimoteManager.HasWiimote())
     {
         Wiimote remote = WiimoteManager.Wiimotes[0];
         remote.SendPlayerLED(true, false, false, false);
         remote.SetupIRCamera();
     }
 }
コード例 #17
0
    // Display for player to connect their wiimote to Unity
    void OnGUI()
    {
        GUI.Box(new Rect(0, 0, 235, Screen.height), "");

        GUILayout.BeginVertical(GUILayout.Width(230));
        // Find wiimote
        GUILayout.Label(" Wiimote Found: " + WiimoteManager.HasWiimote());
        if (GUILayout.Button("Find Your Wiimote"))
        {
            WiimoteManager.FindWiimotes();
        }

        // Remove wiimote
        if (GUILayout.Button("Cleanup"))
        {
            WiimoteManager.Cleanup(wiimote);
            wiimote = null;
        }

        if (wiimote == null)
        {
            return;
        }

        GUILayout.Label(" Press A on your wiimote to start!");
        // Finds and activates wii motion plus
        if (GUILayout.Button("Press if Wiimotion Plus attached"))
        {
            wiimote.SetupIRCamera(IRDataType.BASIC);
            wiimote.RequestIdentifyWiiMotionPlus();
        }
        if ((wiimote.wmp_attached || wiimote.Type == WiimoteType.PROCONTROLLER) &&
            GUILayout.Button("Press to activate Wiimotion Plus"))
        {
            wiimote.ActivateWiiMotionPlus();
        }

        // Instructions for player
        if (wiimote.current_ext == ExtensionController.MOTIONPLUS)
        {
            GUILayout.Label(" Wii Motion Plus Activated!");
            GUILayout.Label(" Press A on your wiimote to start!");
            GUILayout.Label(" Press A or shake wiimote upwards to control the flappy bird");
        }

        GUILayout.EndVertical();
    }
コード例 #18
0
    void OnGUI()
    {
        GUILayout.Label("Wiimote Found: " + WiimoteManager.HasWiimote());
        if (GUILayout.Button("Find Wiimote"))
        {
            WiimoteManager.FindWiimotes();
        }

        if (GUILayout.Button("Cleanup"))
        {
            WiimoteManager.Cleanup(wiimote);
            WiimoteStatus.WiiEnabled = false;
            wiimote = null;
        }

        if (wiimote == null)
        {
            return;
        }

        if (GUILayout.Button("Basic", GUILayout.Width(100)))
        {
            nunnormalizer = 123f;
            wiimote.SetupIRCamera(IRDataType.BASIC);
        }

        if (wiimote != null && wiimote.current_ext != ExtensionController.NONE)
        {
            WiimoteStatus.WiiEnabled = true;
            GUIStyle bold = new GUIStyle(GUI.skin.button);
            bold.fontStyle = FontStyle.Bold;
            if (wiimote.current_ext == ExtensionController.NUNCHUCK)
            {
                GUILayout.Label("Wiimote X:" + pointer0);
                GUILayout.Label("Wiimote Y:" + pointer1);
                GUILayout.Label("Nunchuck:", bold);
                NunchuckData data = wiimote.Nunchuck;
                GUILayout.Label("Stick X: " + data.stick[0] + ", Stick Y " + data.stick[1]);
                WiimoteStatus.nunchuckX = data.stick[0] - nunnormalizer;
                WiimoteStatus.nunchuckY = data.stick[1];
                WiimoteStatus.buttonZ   = data.z;

                GUILayout.Label("C: " + data.c);
                GUILayout.Label("Z: " + data.z);
            }
        }
    }
コード例 #19
0
    // Use this for initialization
    void Start()
    {
        // Wiimote Calibration
        WiimoteManager.FindWiimotes( );
        if (WiimoteManager.HasWiimote( ))
        {
            wiimote = WiimoteManager.Wiimotes[0];
            wiimote.SendPlayerLED(true, false, false, false);
            wiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL);
        }

        currentState = State.NONE;
        powerInput   = 0.2f;
        powerMod     = 0.2f;

        movementEnabled = true;
    }
コード例 #20
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.W))
        {
            wiimoteMode = !wiimoteMode;
        }


        if (wiimoteMode && WiimoteManager.HasWiimote())
        {
            Vector2 vals           = wiimoteController.GetIRValues();
            float   distancePoints = Vector2.Distance(followingPosition, vals);

            float newPercentFollow;

            if (distancePoints < distanceToMinFollow)
            {
                newPercentFollow = .01f;
            }
            else if (distancePoints > distanceToMaxFollow)
            {
                newPercentFollow = .5f;
            }
            else
            {
                newPercentFollow = percentFollowFrame;
            }

            float x = followingPosition.x * (1 - newPercentFollow) + vals.x * newPercentFollow;
            float y = followingPosition.y * (1 - newPercentFollow) + vals.y * newPercentFollow;

            followingPosition = new Vector2(x, y);

            MouseOperations.SetCursorPosition((int)followingPosition.x * 2, (Screen.height - (int)followingPosition.y) * 2);

            if (wiimoteController.isBDown)
            {
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp | MouseOperations.MouseEventFlags.LeftDown);
            }
        }
        else
        {
            followingPosition = Input.mousePosition;
        }
    }
コード例 #21
0
    void Update()
    {
        if (ticksSinceLoad < initialDelay)
        {
            ticksSinceLoad++;
        }
        else if (ticksSinceLoad == initialDelay)
        {
            Time.timeScale = 1;
            ticksSinceLoad++;
        }
        else
        {
            if (!WiimoteManager.HasWiimote())
            {
                SearchAndInitialize();
                return;
            }

            var ret = new List <int>();

            if (ret.Count == 0 && playersActive >= 1)
            {
                for (int i = 0; i < playersActive; i++)
                {
                    ret.Add(0);
                }
            }

            for (int i = 0; i < playersActive; i++)
            {
                do
                {
                    ret[i] = wiimotes[i].ReadWiimoteData();
                }while (ret[i] > 0);
            }
            for (int i = 0; i < playersActive; i++)
            {
                UpdateIRPanel(i, wiimotes[i]);
                UpdateControls(i, wiimotes[i]);
            }
        }
    }
コード例 #22
0
    void OnGUI()
    {
        GUI.Box(new Rect(0, 0, 300, Screen.height), "");

        GUILayout.BeginVertical(GUILayout.Width(300));
        GUILayout.Label("Wiimote Found: " + WiimoteManager.HasWiimote());
        if (GUILayout.Button("Find Wiimote"))
        {
            WiimoteManager.FindWiimotes();
        }

        if (GUILayout.Button("Cleanup"))
        {
            WiimoteManager.Cleanup(wiimote);
            wiimote = null;
        }

        GUILayout.Label("LED Test:");
        GUILayout.BeginHorizontal();
        for (int x = 0; x < 4; x++)
        {
            if (GUILayout.Button("" + x, GUILayout.Width(300 / 4)))
            {
                wiimote.SendPlayerLED(x == 0, x == 1, x == 2, x == 3);
            }
        }
        GUILayout.EndHorizontal();

        if (wiimote != null && wiimote.Type == WiimoteType.PROCONTROLLER)
        {
            float[] ls = wiimote.WiiUPro.GetLeftStick01();
            float[] rs = wiimote.WiiUPro.GetRightStick01();
            GUILayout.Label("LS: " + ls[0] + "," + ls[1]);
            GUILayout.Label("RS: " + rs[0] + "," + rs[1]);
        }

        GUILayout.EndVertical();

        if (wiimote != null)
        {
            windowRect = GUI.Window(0, windowRect, DataWindow, "Data");
        }
    }
コード例 #23
0
ファイル: Player.cs プロジェクト: misoten8/Mock
    void Start()
    {
        // wiiリモコン初期化処理
        WiimoteManager.FindWiimotes();
        _wmNum = (int)_type - 1;
        if (WiimoteManager.HasWiimote(_wmNum))
        {
            _wm = WiimoteManager.Wiimotes[_wmNum];
            _wm.InitWiiMotionPlus();
            _wm.Speaker.Init();
            int i = _wmNum + 1;
            _wm.SendPlayerLED(i == 1, i == 2, i == 3, i == 4);
            WiimoteManager.Rumble(_wmNum, false);
        }

        _playerManager.onDanceStart += () =>
        {
            _dance.Begin();
        };
    }
コード例 #24
0
    void Start()
    {
        // store default rotation quaternion
        defaultRotation = transform.rotation;

        WiimoteManager.FindWiimotes();

        if (WiimoteManager.HasWiimote())
        {
            Debug.Log("Wiimote is connected");
            wiimote = WiimoteManager.Wiimotes [0];
            wiimote.SendPlayerLED(true, false, false, false);

            // set output data format
            wiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL_EXT16);

            wiimote.RequestIdentifyWiiMotionPlus();

            wiimote.Accel.accel_calib = accelCalibrationData;
        }
    }
コード例 #25
0
    // Update is called once per frame
    void Update()
    {
        if (!WiimoteManager.HasWiimote())
        {
            return;
        }

        wiimote = WiimoteManager.Wiimotes[0];

        cube = GameObject.Find("Cube");
        cp   = cube.transform.position;

        int ret;

        do
        {
            ret = wiimote.ReadWiimoteData();
        } while (ret > 0);
        float[] pointer = wiimote.Ir.GetPointingPosition();
        cube.transform.position = new Vector3((pointer[0] - 0.5f) * 16f, (pointer[1] - 0.5f) * 3f, cube.transform.position.z);
    }
コード例 #26
0
    void Update()
    {
        if (!WiimoteManager.HasWiimote())
        {
            return;
        }

        int led_tentative = (int)(Time.time * 2) % 4;

        if (led != led_tentative)
        {
            led = led_tentative;
            WiimoteManager.Wiimotes[0].SendPlayerLED(led == 0, led == 1, led == 2, led == 3);
        }

        int ret;

        do
        {
            ret = WiimoteManager.Wiimotes[0].ReadWiimoteData();
        } while (ret > 0);
    }
コード例 #27
0
    void UpdateControls()
    {
        pauseButtonClick++;


        if (WiimoteManager.HasWiimote())
        {
            Dot5.enabled = Time.timeScale == 0 && plusSetup  ? true : false;
            UpdateRotationWiimotePlus();

            if (wiimote.Button.home && pauseButtonClick > 100 && plusSetup)
            {
                pauseButtonClick = 0;
                Time.timeScale   = Time.timeScale == 0 ? 1 : 0;
                MenuController.SendMessage("ShowHideMenu", Time.timeScale != 0 && plusSetup);
            }

            //Shoot if button A is pressed.
            if (wiimote.Button.a)
            {
                //Shoots raycasts to interact with buttons in menu mode, shoots balls to destroy objectives if not.
                if (Time.timeScale == 0)
                {
                    RaycastHit hit;

                    Debug.DrawRay(ir_origin.transform.position, -(ir_origin.transform.position - ir_pointer.position).normalized * 20);
                    if (Physics.Raycast(ir_origin.transform.position, -(ir_origin.transform.position - ir_pointer.position).normalized * 20, out hit))
                    {
                        Button button = hit.collider.gameObject.GetComponent <Button>();
                        if (button != null)
                        {
                            button.onClick.Invoke();
                        }
                    }
                }
            }
        }
    }
コード例 #28
0
    // Update is called once per frame
    void Update()
    {
        if (!WiimoteManager.HasWiimote())
        {
            return;
        }

        wiimote = WiimoteManager.Wiimotes[0];

        int ret;

        do
        {
            ret = wiimote.ReadWiimoteData();
        }while (ret > 0);

        WiimoteStatus.buttonA = wiimote.Button.a;
        WiimoteStatus.buttonB = wiimote.Button.b;


        //wiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL_EXT16);
        //accel = wiimote.Accel.GetCalibratedAccelData();

        float[] pointer = wiimote.Ir.GetPointingPosition();
        pointer0 = pointer[0] * 10;
        pointer1 = pointer[1] * 10;

        ir_pointer.anchorMin = new Vector2(pointer[0], pointer[1]);
        ir_pointer.anchorMax = new Vector2(pointer[0], pointer[1]);
        //cube.transform.position = new Vector3(pointer[0], pointer[1], 5.9f);

        inputX.Enqueue(pointer0);
        inputY.Enqueue(pointer1);

        WiimoteStatus.WiiX = inputX.Average();
        WiimoteStatus.WiiY = inputY.Average();
        //cube.transform.eulerAngles = GetAccelVector()*10;
    }
コード例 #29
0
    void Update()
    {
        if (!WiimoteManager.HasWiimote())
        {
            return;
        }

        bool n = wiimote == null;

        wiimote = WiimoteManager.Wiimotes[0];
        if (n && wiimote != null)
        {
            wiimote.SendPlayerLED(true, false, false, false);
            wiimote.SendDataReportMode(InputDataType.REPORT_EXT21);
        }

        int ret;

        do
        {
            ret = wiimote.ReadWiimoteData();
        } while (ret > 0);
    }
コード例 #30
0
            private void Update()
            {
                if (wiimote == null)
                {
                    if (WiimoteManager.HasWiimote())
                    {
                        wiimote = WiimoteManager.Wiimotes[0];
                    }
                    else
                    {
                        WiimoteManager.FindWiimotes();
                    }
                }
                else
                {
                    while (wiimote.ReadWiimoteData() > 0)
                    {
                        ;
                    }

                    wiiRemote.Update(wiimote.Button);
                }
            }