Ejemplo n.º 1
0
 void FinishedWithWiimotes()
 {
     foreach (Wiimote remote in WiimoteManager.Wiimotes)
     {
         WiimoteManager.Cleanup(remote);
     }
 }
Ejemplo n.º 2
0
 private void OnClosed(object sender, EventArgs e)
 {
     player.Stop();
     Wiimote?.StopSound();
     waveform.Stop();
     WiimoteManager.Cleanup();
 }
Ejemplo n.º 3
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);
            }
        }
    }
Ejemplo n.º 4
0
 void OnApplicationQuit()
 {
     if (wiimote != null)
     {
         WiimoteManager.Cleanup(wiimote);
     }
 }
Ejemplo n.º 5
0
    void couleur()
    {
        switch (direction)
        {
        case "haut":
            this.gameObject.GetComponent <Renderer>().material.color = new Color(0, 0, 0, 1);
            break;

        case "gauche":
            this.gameObject.GetComponent <Renderer>().material.color = new Color(0, 0, 1, 1);
            break;

        case "droite":
            this.gameObject.GetComponent <Renderer>().material.color = new Color(0, 1, 0, 1);
            break;

        case "a":
            this.gameObject.GetComponent <Renderer>().material.color = new Color(0, 1, 1, 0);
            break;

        case "b":
            this.gameObject.GetComponent <Renderer>().material.color = new Color(1, 1, 1, 1);
            break;

        case "+":
            this.gameObject.GetComponent <Renderer>().material.color = new Color(1, 0, 0, 0);
            break;

        case "-":
            this.gameObject.GetComponent <Renderer>().material.color = new Color(1, 0, 0, 1);
            break;

        case "1":
            this.gameObject.GetComponent <Renderer>().material.color = new Color(1, 0, 1, 0);
            break;

        case "2":
            this.gameObject.GetComponent <Renderer>().material.color = new Color(1, 0, 1, 1);
            break;

        case "h":
            this.gameObject.GetComponent <Renderer>().material.color = new Color(1, 1, 0, 0);
            break;

        case "bas":
            this.gameObject.GetComponent <Renderer>().material.color = new Color(1, 1, 0, 1);
            break;

        case "add":
            WiimoteManager.FindWiimotes();
            break;

        case "rmv":
            WiimoteManager.Cleanup(wiimote);
            wiimote = null;
            break;
        }
        // etc
    }
Ejemplo n.º 6
0
 void OnDestroy()
 {
     if (wiimote != null)
     {
         WiimoteManager.Cleanup(wiimote);
         wiimote = null;
     }
 }
 private void OnApplicationQuit()
 {
     if (wiimoteBlue != null)
     {
         WiimoteManager.Cleanup(wiimoteBlue);
         wiimoteBlue = null;
     }
 }
Ejemplo n.º 8
0
 private void OnApplicationQuit()
 {
     if (!(InputManager.inputs && InputManager.inputs.enabled) && wiimote != null)
     {
         WiimoteManager.Cleanup(wiimote);
         wiimote = null;
     }
 }
Ejemplo n.º 9
0
 private void OnApplicationQuit()
 {
     // Parcoure toutes les wii remotes
     foreach (Wiimote remote in WiimoteManager.Wiimotes)
     {
         WiimoteManager.Cleanup(remote);
     }
 }
Ejemplo n.º 10
0
 private void OnApplicationQuit()
 {
     if (wiimoteRed != null)
     {
         WiimoteManager.Cleanup(wiimoteRed);
         wiimoteRed = null;
     }
 }
Ejemplo n.º 11
0
 public void Reset()
 {
     if (WiimoteManager.HasWiimote())
     {
         WiimoteManager.Cleanup(_wiimote);
     }
     _wiimote = null;
 }
Ejemplo n.º 12
0
 void OnApplicationQuit()
 {
     Debug.Log("Cleanup");
     while (WiimoteManager.Wiimotes.Count > 0)
     {
         WiimoteManager.Cleanup(WiimoteManager.Wiimotes[0]);
     }
 }
Ejemplo n.º 13
0
 void OnApplicationQuit()
 {
     if (wiimote != null)
     {
         WiimoteManager.Cleanup(wiimote);
         wiimote = null;
     }
     Write_csv();
 }
Ejemplo n.º 14
0
 // Start is called before the first frame update
 void Start()
 {
     foreach (Wiimote remote in WiimoteManager.Wiimotes)
     {
         WiimoteManager.Cleanup(remote);
     }
     anim = GetComponent <Animator>();
     InitWiimotes();
 }
Ejemplo n.º 15
0
 public void QuitGame()
 {
     if (PlateController.wiiRemote != null)
     {
         WiimoteManager.Cleanup(PlateController.wiiRemote);
         PlateController.wiiRemote = null;
     }
     Application.Quit();
 }
Ejemplo n.º 16
0
 public void QuitGame()
 {
     if (wiiRemote != null)
     {
         WiimoteManager.Cleanup(wiiRemote);
         wiiRemote = null;
     }
     Application.Quit();
 }
Ejemplo n.º 17
0
    void OnDestroy()
    {
        foreach (var wiimote in wiimotes)
        {
            if (wiimote != null)
            {
                WiimoteManager.Cleanup(wiimote);
            }
        }

        wiimotes.Clear();
    }
Ejemplo n.º 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);
            }
        }
    }
Ejemplo n.º 19
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();
    }
Ejemplo n.º 20
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");
        }
    }
Ejemplo n.º 21
0
    void OnGUI()
    {
        GUI.Box(new Rect(0, 0, 320, 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;
        }

        if (wiimote == null)
        {
            return;
        }

        GUILayout.Label("Extension: " + wiimote.current_ext.ToString());

        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();

        GUILayout.Label("Set Report:");
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("But/Acc", GUILayout.Width(300 / 4)))
        {
            wiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL);
        }
        if (GUILayout.Button("But/Ext8", GUILayout.Width(300 / 4)))
        {
            wiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_EXT8);
        }
        if (GUILayout.Button("B/A/Ext16", GUILayout.Width(300 / 4)))
        {
            wiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL_EXT16);
        }
        if (GUILayout.Button("Ext21", GUILayout.Width(300 / 4)))
        {
            wiimote.SendDataReportMode(InputDataType.REPORT_EXT21);
        }
        GUILayout.EndHorizontal();

        if (GUILayout.Button("Request Status Report"))
        {
            wiimote.SendStatusInfoRequest();
        }

        GUILayout.Label("IR Setup Sequence:");
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Basic", GUILayout.Width(100)))
        {
            wiimote.SetupIRCamera(IRDataType.BASIC);
        }
        if (GUILayout.Button("Extended", GUILayout.Width(100)))
        {
            wiimote.SetupIRCamera(IRDataType.EXTENDED);
        }
        if (GUILayout.Button("Full", GUILayout.Width(100)))
        {
            wiimote.SetupIRCamera(IRDataType.FULL);
        }
        GUILayout.EndHorizontal();

        GUILayout.Label("WMP Attached: " + wiimote.wmp_attached);
        if (GUILayout.Button("Request Identify WMP"))
        {
            wiimote.RequestIdentifyWiiMotionPlus();
        }
        if ((wiimote.wmp_attached || wiimote.Type == WiimoteType.PROCONTROLLER) && GUILayout.Button("Activate WMP"))
        {
            wiimote.ActivateWiiMotionPlus();
        }
        if ((wiimote.current_ext == ExtensionController.MOTIONPLUS ||
             wiimote.current_ext == ExtensionController.MOTIONPLUS_CLASSIC ||
             wiimote.current_ext == ExtensionController.MOTIONPLUS_NUNCHUCK) && GUILayout.Button("Deactivate WMP"))
        {
            wiimote.DeactivateWiiMotionPlus();
        }

        GUILayout.Label("Calibrate Accelerometer");
        GUILayout.BeginHorizontal();
        for (int x = 0; x < 3; x++)
        {
            AccelCalibrationStep step = (AccelCalibrationStep)x;
            if (GUILayout.Button(step.ToString(), GUILayout.Width(100)))
            {
                wiimote.Accel.CalibrateAccel(step);
            }
        }
        GUILayout.EndHorizontal();

        if (GUILayout.Button("Print Calibration Data"))
        {
            StringBuilder str = new StringBuilder();
            for (int x = 0; x < 3; x++)
            {
                for (int y = 0; y < 3; y++)
                {
                    str.Append(wiimote.Accel.accel_calib[y, x]).Append(" ");
                }
                str.Append("\n");
            }
            Debug.Log(str.ToString());
        }

        if (wiimote != null && wiimote.current_ext != ExtensionController.NONE)
        {
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            GUIStyle bold = new GUIStyle(GUI.skin.button);
            bold.fontStyle = FontStyle.Bold;
            if (wiimote.current_ext == ExtensionController.NUNCHUCK)
            {
                GUILayout.Label("Nunchuck:", bold);
                NunchuckData data = wiimote.Nunchuck;
                GUILayout.Label("Stick: " + data.stick[0] + ", " + data.stick[1]);
                GUILayout.Label("C: " + data.c);
                GUILayout.Label("Z: " + data.z);
            }
            else if (wiimote.current_ext == ExtensionController.CLASSIC)
            {
                GUILayout.Label("Classic Controller:", bold);
                ClassicControllerData data = wiimote.ClassicController;
                GUILayout.Label("Stick Left: " + data.lstick[0] + ", " + data.lstick[1]);
                GUILayout.Label("Stick Right: " + data.rstick[0] + ", " + data.rstick[1]);
                GUILayout.Label("Trigger Left: " + data.ltrigger_range);
                GUILayout.Label("Trigger Right: " + data.rtrigger_range);
                GUILayout.Label("Trigger Left Button: " + data.ltrigger_switch);
                GUILayout.Label("Trigger Right Button: " + data.rtrigger_switch);
                GUILayout.Label("A: " + data.a);
                GUILayout.Label("B: " + data.b);
                GUILayout.Label("X: " + data.x);
                GUILayout.Label("Y: " + data.y);
                GUILayout.Label("Plus: " + data.plus);
                GUILayout.Label("Minus: " + data.minus);
                GUILayout.Label("Home: " + data.home);
                GUILayout.Label("ZL: " + data.zl);
                GUILayout.Label("ZR: " + data.zr);
                GUILayout.Label("D-Up: " + data.dpad_up);
                GUILayout.Label("D-Down: " + data.dpad_down);
                GUILayout.Label("D-Left: " + data.dpad_left);
                GUILayout.Label("D-Right: " + data.dpad_right);
            }
            else if (wiimote.current_ext == ExtensionController.MOTIONPLUS)
            {
                GUILayout.Label("Wii Motion Plus:", bold);
                MotionPlusData data = wiimote.MotionPlus;
                GUILayout.Label("Pitch Speed: " + data.PitchSpeed);
                GUILayout.Label("Yaw Speed: " + data.YawSpeed);
                GUILayout.Label("Roll Speed: " + data.RollSpeed);
                GUILayout.Label("Pitch Slow: " + data.PitchSlow);
                GUILayout.Label("Yaw Slow: " + data.YawSlow);
                GUILayout.Label("Roll Slow: " + data.RollSlow);
                if (GUILayout.Button("Zero Out WMP"))
                {
                    data.SetZeroValues();
                    model.rot.rotation = Quaternion.FromToRotation(model.rot.rotation * GetAccelVector(), Vector3.up) * model.rot.rotation;
                    model.rot.rotation = Quaternion.FromToRotation(model.rot.forward, Vector3.forward) * model.rot.rotation;
                }
                if (GUILayout.Button("Reset Offset"))
                {
                    wmpOffset = Vector3.zero;
                }
                GUILayout.Label("Offset: " + wmpOffset.ToString());
            }
            else if (wiimote.current_ext == ExtensionController.WIIU_PRO)
            {
                GUILayout.Label("Wii U Pro Controller:", bold);
                WiiUProData data = wiimote.WiiUPro;
                GUILayout.Label("Stick Left: " + data.lstick[0] + ", " + data.lstick[1]);
                GUILayout.Label("Stick Right: " + data.rstick[0] + ", " + data.rstick[1]);
                GUILayout.Label("A: " + data.a);
                GUILayout.Label("B: " + data.b);
                GUILayout.Label("X: " + data.x);
                GUILayout.Label("Y: " + data.y);

                GUILayout.Label("D-Up: " + data.dpad_up);
                GUILayout.Label("D-Down: " + data.dpad_down);
                GUILayout.Label("D-Left: " + data.dpad_left);
                GUILayout.Label("D-Right: " + data.dpad_right);

                GUILayout.Label("Plus: " + data.plus);
                GUILayout.Label("Minus: " + data.minus);
                GUILayout.Label("Home: " + data.home);

                GUILayout.Label("L: " + data.l);
                GUILayout.Label("R: " + data.r);
                GUILayout.Label("ZL: " + data.zl);
                GUILayout.Label("ZR: " + data.zr);
            }
            GUILayout.EndScrollView();
        }
        else
        {
            scrollPosition = Vector2.zero;
        }
        GUILayout.EndVertical();
    }
Ejemplo n.º 22
0
    //=============================================================================
    //	関数名: void OnGUI()
    //	引数  : なし
    //	戻り値: なし
    //	説明  : DebugGUI
    //=============================================================================
    void OnGUI()
    {
        // 枠
        GUI.Box(new Rect(0, 0, 0, Screen.height), "");

        GUILayout.BeginVertical(GUILayout.Width(300));
        GUILayout.Label("WiimoteFound:" + WiimoteManager.HasWiimote());

        // 接続ボタン
        if (GUILayout.Button("Find Wiimote"))
        {
            WiimoteManager.FindWiimotes();
            //wm = InitMotionPlus(WiimoteManager.Wiimotes[0]);
            wm = InitWiimote(WiimoteManager.Wiimotes[0]);
        }

        // 切断ボタン
        if (GUILayout.Button("Cleanup"))
        {
            Debug.Log("Wiiリモコンの接続を解除しました");
            WiimoteManager.Cleanup(wm);
            wm = null;
        }

        // 接続されていなかったらこれ以降を表示しない
        if (wm == null)
        {
            return;
        }

        // 外部コントローラー確認
        GUILayout.Label("Extension: " + wm.current_ext.ToString() + wm.Type);

        // LEDチェック
        GUILayout.BeginHorizontal();
        for (int i = 0; i < 4; i++)
        {
            if (GUILayout.Button("" + i, GUILayout.Width(300 / 4)))
            {
                wm.SendPlayerLED(i == 0, i == 1, i == 2, i == 3);
            }
        }
        if (GUILayout.Button("LED Reset", GUILayout.Width(300 / 4)))
        {
            wm.SendPlayerLED(false, false, false, false);
        }
        GUILayout.EndHorizontal();

        // 振動
        GUILayout.Label("振動");
        if (GUILayout.Button("ON"))
        {
            wm.RumbleOn = true;
            wm.SendStatusInfoRequest();
        }
        if (GUILayout.Button("OFF"))
        {
            wm.RumbleOn = false;
            wm.SendStatusInfoRequest();
        }

        // 加速度
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("But/Acc", GUILayout.Width(300 / 4)))
        {
            wm.SendDataReportMode(InputDataType.REPORT_BUTTONS);
        }
        if (GUILayout.Button("But/Ext8", GUILayout.Width(300 / 4)))
        {
            wm.SendDataReportMode(InputDataType.REPORT_BUTTONS_EXT8);
        }
        if (GUILayout.Button("B/A/Ext16", GUILayout.Width(300 / 4)))
        {
            wm.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL_EXT16);
        }
        if (GUILayout.Button("Ext21", GUILayout.Width(300 / 4)))
        {
            wm.SendDataReportMode(InputDataType.REPORT_EXT21);
        }
        GUILayout.EndHorizontal();

        // モーションプラス設定
        GUILayout.Label("WMP Attached: " + wm.wmp_attached);
        if (GUILayout.Button("Request Identify WMP"))
        {
            wm.RequestIdentifyWiiMotionPlus();
        }
        if ((wm.wmp_attached || wm.Type == WiimoteType.PROCONTROLLER) && GUILayout.Button("Activate WMP"))
        {
            wm.ActivateWiiMotionPlus();
        }
        if ((wm.current_ext == ExtensionController.MOTIONPLUS ||
             wm.current_ext == ExtensionController.MOTIONPLUS_CLASSIC ||
             wm.current_ext == ExtensionController.MOTIONPLUS_NUNCHUCK) && GUILayout.Button("Deactivate WMP"))
        {
            wm.DeactivateWiiMotionPlus();
        }

        GUILayout.Label("Calibrate Accelerometer");
        GUILayout.BeginHorizontal();
        for (int x = 0; x < 3; x++)
        {
            AccelCalibrationStep step = (AccelCalibrationStep)x;
            if (GUILayout.Button(step.ToString(), GUILayout.Width(100)))
            {
                wm.Accel.CalibrateAccel(step);
            }
        }
        GUILayout.EndHorizontal();
    }
Ejemplo n.º 23
0
    void OnGUI()
    {
        GUI.Box(new Rect(0, 0, 320, Screen.height), "");

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

        if (GUILayout.Button("Cleanup"))
        {
            UnityEngine.Debug.Log("Reseteo");
            WiimoteManager.Cleanup(wiimote);
            wiimote = null;
        }

        if (wiimote == null)
        {
            return;
        }

        GUILayout.Label("Extension: " + wiimote.current_ext.ToString());

        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();

        GUILayout.Label("Set Report:");
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("But/Acc", GUILayout.Width(300 / 4)))
        {
            wiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL);
        }
        if (GUILayout.Button("But/Ext8", GUILayout.Width(300 / 4)))
        {
            wiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_EXT8);
        }
        if (GUILayout.Button("B/A/Ext16", GUILayout.Width(300 / 4)))
        {
            wiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL_EXT16);
        }
        if (GUILayout.Button("Ext21", GUILayout.Width(300 / 4)))
        {
            wiimote.SendDataReportMode(InputDataType.REPORT_EXT21);
        }
        GUILayout.EndHorizontal();

        if (GUILayout.Button("Request Status Report"))
        {
            wiimote.SendStatusInfoRequest();
        }

        GUILayout.Label("IR Setup Sequence:");
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Basic", GUILayout.Width(100)))
        {
            wiimote.SetupIRCamera(IRDataType.BASIC);
        }
        if (GUILayout.Button("Extended", GUILayout.Width(100)))
        {
            wiimote.SetupIRCamera(IRDataType.EXTENDED);
        }
        if (GUILayout.Button("Full", GUILayout.Width(100)))
        {
            wiimote.SetupIRCamera(IRDataType.FULL);
        }
        GUILayout.EndHorizontal();

        GUILayout.Label("WMP Attached: " + wiimote.wmp_attached);
        if (GUILayout.Button("Request Identify WMP"))
        {
            wiimote.RequestIdentifyWiiMotionPlus();
        }
        if ((wiimote.wmp_attached || wiimote.Type == WiimoteType.PROCONTROLLER) && GUILayout.Button("Activate WMP"))
        {
            wiimote.ActivateWiiMotionPlus();
        }

        if ((wiimote.current_ext == ExtensionController.MOTIONPLUS ||
             wiimote.current_ext == ExtensionController.MOTIONPLUS_CLASSIC ||
             wiimote.current_ext == ExtensionController.MOTIONPLUS_NUNCHUCK) && GUILayout.Button("Deactivate WMP"))
        {
            wiimote.DeactivateWiiMotionPlus();
            //OnApplicationQuit();


            //WiimoteManager.Cleanup(wiimote);

            /*wiimote = null;
             * WiimoteManager.FindWiimotes();*/


            /* Debug.Log("entre1");
             *
             * NunchuckData data = wiimote.Nunchuck;
             * GUILayout.Label("Stick: " + data.stick[0] + ", " + data.stick[1]);
             * GUILayout.Label("C: " + data.c);
             * GUILayout.Label("Z: " + data.z);*/
        }
        //UnityEngine.Debug.Log("entre2");
        GUILayout.Label("Calibrate Accelerometer");
        GUILayout.BeginHorizontal();
        for (int x = 0; x < 3; x++)
        {
            AccelCalibrationStep step = (AccelCalibrationStep)x;
            if (GUILayout.Button(step.ToString(), GUILayout.Width(100)))
            {
                wiimote.Accel.CalibrateAccel(step);
            }
        }
        GUILayout.EndHorizontal();

        if (GUILayout.Button("Print Calibration Data"))
        {
            StringBuilder str = new StringBuilder();
            for (int x = 0; x < 3; x++)
            {
                for (int y = 0; y < 3; y++)
                {
                    str.Append(wiimote.Accel.accel_calib[y, x]).Append(" ");
                }
                str.Append("\n");
            }
            UnityEngine.Debug.Log(str.ToString());
        }

        if (wiimote != null && wiimote.current_ext != ExtensionController.NONE)
        {
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            GUIStyle bold = new GUIStyle(GUI.skin.button);
            bold.fontStyle = FontStyle.Bold;
            if (wiimote.current_ext == ExtensionController.NUNCHUCK)
            {
                UnityEngine.Debug.Log(wiimote.current_ext);
                GUILayout.Label("Nunchuck:", bold);
                NunchuckData data = wiimote.Nunchuck;
                GUILayout.Label("Stick: " + data.stick[0] + ", " + data.stick[1]);
                GUILayout.Label("C: " + data.c);
                GUILayout.Label("Z: " + data.z);

                if (data.stick[0] > 120 && data.stick[0] < 220 && data.stick[1] > 70 && data.stick[1] < 210)
                {
                    controlWii.transform.position = new Vector3(controlWii.transform.position.x + numUp, 0f, controlWii.transform.position.z);
                }
                if (data.stick[0] > 20 && data.stick[0] < 120 && data.stick[1] > 63 && data.stick[1] < 209)
                {
                    controlWii.transform.position = new Vector3(controlWii.transform.position.x - numUp, 0f, controlWii.transform.position.z);
                }
                if (data.stick[0] > 48 && data.stick[0] < 186 && data.stick[1] > 140 && data.stick[1] < 235)
                {
                    controlWii.transform.position = new Vector3(controlWii.transform.position.x, 0f, controlWii.transform.position.z + numUp);
                }
                if (data.stick[0] > 50 && data.stick[0] < 192 && data.stick[1] > 30 && data.stick[1] < 140)
                {
                    controlWii.transform.position = new Vector3(controlWii.transform.position.x, 0f, controlWii.transform.position.z - numUp);
                }
                if (data.z && butZ)
                {
                    UnityEngine.Debug.Log("Se oprimio la Z");
                    butZ = false;
                    wiimote.RequestIdentifyWiiMotionPlus();
                }
                if (data.c && butC)
                {
                    UnityEngine.Debug.Log("Se oprimio la C");
                    butC = false;
                    wiimote.ActivateWiiMotionPlus();
                }
            }
            else if (wiimote.current_ext == ExtensionController.CLASSIC)
            {
                GUILayout.Label("Classic Controller:", bold);
                ClassicControllerData data = wiimote.ClassicController;
                GUILayout.Label("Stick Left: " + data.lstick[0] + ", " + data.lstick[1]);
                GUILayout.Label("Stick Right: " + data.rstick[0] + ", " + data.rstick[1]);
                GUILayout.Label("Trigger Left: " + data.ltrigger_range);
                GUILayout.Label("Trigger Right: " + data.rtrigger_range);
                GUILayout.Label("Trigger Left Button: " + data.ltrigger_switch);
                GUILayout.Label("Trigger Right Button: " + data.rtrigger_switch);
                GUILayout.Label("A: " + data.a);
                GUILayout.Label("B: " + data.b);
                GUILayout.Label("X: " + data.x);
                GUILayout.Label("Y: " + data.y);
                GUILayout.Label("Plus: " + data.plus);
                GUILayout.Label("Minus: " + data.minus);
                GUILayout.Label("Home: " + data.home);
                GUILayout.Label("ZL: " + data.zl);
                GUILayout.Label("ZR: " + data.zr);
                GUILayout.Label("D-Up: " + data.dpad_up);
                GUILayout.Label("D-Down: " + data.dpad_down);
                GUILayout.Label("D-Left: " + data.dpad_left);
                GUILayout.Label("D-Right: " + data.dpad_right);
            }
            else if (wiimote.current_ext == ExtensionController.MOTIONPLUS)
            {
                UnityEngine.Debug.Log(wiimote.current_ext);
                GUILayout.Label("Wii Motion Plus:", bold);
                MotionPlusData data = wiimote.MotionPlus;
                GUILayout.Label("Pitch Speed: " + data.PitchSpeed);
                GUILayout.Label("Yaw Speed: " + data.YawSpeed);
                GUILayout.Label("Roll Speed: " + data.RollSpeed);
                GUILayout.Label("Pitch Slow: " + data.PitchSlow);
                GUILayout.Label("Yaw Slow: " + data.YawSlow);
                GUILayout.Label("Roll Slow: " + data.RollSlow);



                if (GUILayout.Button("Zero Out WMP"))
                {
                    data.SetZeroValues();
                    model.rot.rotation = Quaternion.FromToRotation(model.rot.rotation * GetAccelVector(), Vector3.up) * model.rot.rotation;
                    model.rot.rotation = Quaternion.FromToRotation(model.rot.forward, Vector3.forward) * model.rot.rotation;
                }
                if (GUILayout.Button("Reset Offset"))
                {
                    wmpOffset = Vector3.zero;
                }
                GUILayout.Label("Offset: " + wmpOffset.ToString());
            }
            else if (wiimote.current_ext == ExtensionController.WIIU_PRO)
            {
                GUILayout.Label("Wii U Pro Controller:", bold);
                WiiUProData data = wiimote.WiiUPro;
                GUILayout.Label("Stick Left: " + data.lstick[0] + ", " + data.lstick[1]);
                GUILayout.Label("Stick Right: " + data.rstick[0] + ", " + data.rstick[1]);
                GUILayout.Label("A: " + data.a);
                GUILayout.Label("B: " + data.b);
                GUILayout.Label("X: " + data.x);
                GUILayout.Label("Y: " + data.y);

                GUILayout.Label("D-Up: " + data.dpad_up);
                GUILayout.Label("D-Down: " + data.dpad_down);
                GUILayout.Label("D-Left: " + data.dpad_left);
                GUILayout.Label("D-Right: " + data.dpad_right);

                GUILayout.Label("Plus: " + data.plus);
                GUILayout.Label("Minus: " + data.minus);
                GUILayout.Label("Home: " + data.home);

                GUILayout.Label("L: " + data.l);
                GUILayout.Label("R: " + data.r);
                GUILayout.Label("ZL: " + data.zl);
                GUILayout.Label("ZR: " + data.zr);
            }
            else if (wiimote.current_ext == ExtensionController.GUITAR)
            {
                GUILayout.Label("Guitar", bold);
                GuitarData data  = wiimote.Guitar;
                float[]    stick = data.GetStick01();
                GUILayout.Label("Stick: " + stick [0] + ", " + stick [1]);
                GUILayout.Label("Slider: " + (data.has_slider ? Convert.ToString(data.GetSlider01()) : "unsupported"));
                GUILayout.Label("Green: " + data.green);
                GUILayout.Label("Red: " + data.red);
                GUILayout.Label("Yellow: " + data.yellow);
                GUILayout.Label("Blue: " + data.blue);
                GUILayout.Label("Orange: " + data.orange);
                GUILayout.Label("Strum Up: " + data.strum_up);
                GUILayout.Label("Strum Down: " + data.strum_down);
                GUILayout.Label("Minus: " + data.minus);
                GUILayout.Label("Plus: " + data.plus);
                GUILayout.Label("Whammy: " + data.GetWhammy01());
            }
            GUILayout.EndScrollView();
        }
        else
        {
            scrollPosition = Vector2.zero;
        }
        GUILayout.EndVertical();
    }
Ejemplo n.º 24
0
 private void OnClosed(object sender, EventArgs e)
 {
     WiimoteManager.Cleanup();
 }
Ejemplo n.º 25
0
 public void cleanUp()
 {
     WiimoteManager.Cleanup(wiiMote);
     wiiMote = null;
 }