Beispiel #1
0
    public void Update()
    {
        if (!bDoOnce)
        {
            CS_WiiMoteManager.FindWiimotes();
            bDoOnce = true;
        }

        if (!CS_WiiMoteManager.HasWiimote())
        {
            return;
        }
        if (bStartRumble)
        {
            Rumble();
        }
        wiimote = CS_WiiMoteManager.Wiimotes[0];
        wiimote.SetupIRCamera(IRDataType.BASIC);
        float fStick1 = data.stick[1];
        float fStick2 = data.stick[0];

        //Tests if there is a wiimote and is has an extension
        if (wiimote != null && wiimote.current_ext != ExtensionController.NONE && !bDoOnce1)
        {
            data     = wiimote.Nunchuck;
            bDoOnce1 = true;
        }
        xRot = (fStick1 - fXMid) / (0.5f * fRange);
        yRot = (fStick2 - fYMid) / (0.5f * fRange);
        //order to make sure it doesn't fall behind the Wiimote's update frequency
        do
        {
            iData = wiimote.ReadWiimoteData();
        } while (iData > 0);
    }
Beispiel #2
0
    void OnGUI()
    {
        //Will show the current extension (Nunchuck if plugged in) and the Nunchuck values as well as if a mote has been recognised.
        GUI.Box(new Rect(720, 10, 320, Screen.height), "");
        GUILayout.BeginArea(new Rect(720, 10, 320, Screen.height));
        GUILayout.Label("Wiimote Found: " + CS_WiiMoteManager.HasWiimote());
        //only searches for a mote at the start - can cause crashes otherwise

        if (wiimote == null)
        {
            return;
        }
        //Tests if there is a wiimote and is has an extension
        if (wiimote != null && wiimote.current_ext != ExtensionController.NONE)
        {
            GUIStyle bold = new GUIStyle(GUI.skin.button);

            bold.fontStyle = FontStyle.Bold;
            if (wiimote.current_ext == ExtensionController.NUNCHUCK)
            {
                GUILayout.Label("Nunchuck:", bold);
                GUILayout.Label("Stick: " + xRot + ", " + yRot);
                GUILayout.Label("C: " + data.c);
                GUILayout.Label("Z: " + data.z);
            }
        }
        GUILayout.EndArea();
    }