Example #1
0
 void Start()
 {
     WiimoteManager.FindWiimotes();
     wiimote = WiimoteManager.Wiimotes[0];
     wiimote.SendPlayerLED(true, true, false, false);
     wiimote.SetupIRCamera(IRDataType.FULL);
 }
Example #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);
        }
    }
Example #3
0
    // Start is called before the first frame update
    void Start()
    {
        //Find and stor Wiimote ref in variable
        WiimoteManager.FindWiimotes();
        if (WiimoteManager.Wiimotes.Count != 0)
        {
            _remote = WiimoteManager.Wiimotes[0];
            _remote.SendPlayerLED(false, false, false, false);

            isConnected = true;

            //Setup IR Camera
            if (_remote.SetupIRCamera(IRDataType.BASIC))
            {
                Debug.Log("IR Setup Successful!");
            }
            else
            {
                Debug.Log("IR Setup Failed!");
            }
        }
        else
        {
            isConnected = false;

            Debug.Log("Wiimote not connected!");
        }
    }
    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);
            }
        }
    }
Example #5
0
    void InitWiimotes()
    {
        WiimoteManager.FindWiimotes();         // Poll native bluetooth drivers to find Wiimotes

        int i = 0;

        foreach (Wiimote remote in WiimoteManager.Wiimotes)
        {
            SetWiimoteLeds(remote, i);
            remote.SetupIRCamera(IRDataType.BASIC);             // Basic IR dot position data
            GameObject face = Instantiate(facePrefab, Vector3.zero, Quaternion.identity) as GameObject;
            faces.Add(face);
            animators.Add(face.GetComponent <Animator>());
            pitches.Add(basePitch + i * 500);
            prevShootTimes.Add(0);
            prevSoundTimes.Add(0);
            reloadTimes.Add(baseReloadTime);

            GameObject pointer = Instantiate(pointerPrefab);
            pointer.GetComponent <SpriteRenderer>().color = Color.HSVToRGB(i * 0.15f % 1, 0.7f, 1);
            pointers.Add(pointer);

            ++i;
        }
    }
Example #6
0
    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;
            }
        }
    }
    private void OnCollisionStay(Collision collision)
    {
        GameObject obj = collision.gameObject;

        if (obj.name.Equals("RightHand"))
        {
            RightHand = collision.gameObject;
        }
        if (TouchingFurniture() && OpenFingersRight <= 2)
        {
            transform.SetParent(RightHand.transform.parent.transform);
            transform.position = new Vector3(vista.transform.position.x, vista.transform.position.y, vista.transform.position.z);
            GetComponent <Rigidbody>().useGravity  = false;
            GetComponent <Rigidbody>().isKinematic = true;
            isGrabbed = true;
            WiimoteManager.FindWiimotes();
            controlWii = WiimoteManager.Wiimotes[0];
            controlWii.SetupIRCamera(IRDataType.BASIC);
            if (!transform.name.Equals(nameFurni))
            {
                nameFurni   = transform.name;
                actualScale = transform.localScale;
            }
        }
    }
Example #8
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);
            }
        }
    }
    IEnumerator searchForWiiControler()
    {
        Wiimote newWiimote;

        WiimoteManager.FindWiimotes();
        while (WiimoteManager.Wiimotes.Count() == 0)
        {
            yield return(new WaitForSeconds(1.5f));

            WiimoteManager.FindWiimotes();
        }

        Debug.Log("found wiiMote");
        newWiimote = WiimoteManager.Wiimotes.First();
        newWiimote.SendPlayerLED(true, false, false, false);
        newWiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL);

        _wiimote = newWiimote;
        Debug.Log("Assigned wiiMote");
        _wiimote.RumbleOn = true;
        yield return(new WaitForSeconds(0.15f));

        _wiimote.RumbleOn = false;


        //Debug.Log("Calibratin accelerometer, put the controller facing up, and the A button side facing you");
        //_wiimote.Accel.CalibrateAccel((AccelCalibrationStep)0);
        //_wiimote.Accel.CalibrateAccel((AccelCalibrationStep)1);
        //_wiimote.Accel.CalibrateAccel((AccelCalibrationStep)2);
    }
Example #10
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
    }
Example #11
0
    void SearchAndInitialize()
    {
        WiimoteManager.FindWiimotes();

        wiimote = WiimoteManager.Wiimotes[0];
        wiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL);
        wiimote.SetupIRCamera(IRDataType.EXTENDED);
        wiimote.SendPlayerLED(true, true, true, true);
    }
Example #12
0
 void InitWiimotes()
 {
     WiimoteManager.FindWiimotes(); // Poll native bluetooth drivers to find Wiimotes
     foreach (Wiimote remote in WiimoteManager.Wiimotes)
     {
         remote.SendPlayerLED(true, false, false, true);
         remote.SetupIRCamera(IRDataType.BASIC);     // Basic IR dot position data
         wiimote = remote;
     }
 }
Example #13
0
    // Use this for initialization
    void Start()
    {
        WiimoteManager.FindWiimotes();
        wiimote = WiimoteManager.Wiimotes[0];
        wiimote.RequestIdentifyWiiMotionPlus();
        wiimote.ActivateWiiMotionPlus();
        wiimote.SetupIRCamera(IRDataType.BASIC);

        pivot = transform.parent;
    }
Example #14
0
 void InitWiimotes()
 {
     WiimoteManager.FindWiimotes(); // Poll native bluetooth drivers to find Wiimotes
     foreach (Wiimote remote in WiimoteManager.Wiimotes)
     {
         // Do stuff.
         Debug.Log("Found Wiimote");
         this.remote = remote;
     }
 }
Example #15
0
    void MainMenu()
    {
        WiimoteManager.FindWiimotes();
        controlWii = WiimoteManager.Wiimotes[0];
        //controlWii = transform.parent.GetComponent<MoveCamera>().controlWii;
        controlWii.SetupIRCamera(IRDataType.BASIC);
        if (controlWii != null)
        {
            int ret;
            do
            {
                ret = controlWii.ReadWiimoteData();

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

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

            NunchuckData data = controlWii.Nunchuck;

            if (data.c && data.z && created == false)
            {
                menu.transform.parent.GetComponent <MoveCamera>().enabled = false;
                CreateMenu();
                created = true;
            }
            else if (data.z && !data.c && created == true)
            {
                DestroyMenu();
                Destroy(GameObject.FindGameObjectWithTag("selection"));
                menu.transform.parent.GetComponent <MoveCamera>().enabled = true;
                created    = false;
                controlWii = null;
            }
            if (created == true)
            {
                int i = 0;
                while (i < opts.Length)
                {
                    if (opts[i].tag == "active")
                    {
                        activeOpt = opts[i];
                    }
                    i++;
                }
            }
        }
    }
Example #16
0
 // Start is called before the first frame update
 void Start()
 {
     //WiimoteManager.FindWiimotes();
     //controlWii = WiimoteManager.Wiimotes[0];
     botones          = GameObject.FindGameObjectWithTag("botones");
     actualButton     = botones.transform.GetChild(index).GetComponent <Button>();
     actualButton.tag = "select";
     actualButton.GetComponent <Image>().color = Color.gray;
     actualButton.OnSelect(null);
     WiimoteManager.FindWiimotes();
     controlWii = WiimoteManager.Wiimotes[0];
 }
Example #17
0
    // Initialise les wii remotes
    public void InitWiimotes()
    {
        // Trouve les wiimotes connectées
        WiimoteManager.FindWiimotes();

        // Parcoure toutes les wii remotes
        foreach (Wiimote wiiRemote in WiimoteManager.Wiimotes)
        {
            wiiRemotes.Add(wiiRemote);
            wiiRemotes[wiiRemotes.Count - 1].SetupIRCamera(IRDataType.EXTENDED);

            Debug.Log("Wii Remote trouvée !");
        }
    }
Example #18
0
        public override void Start()
        {
            base.Start();
      #if UP_USE_WII_INPUT_MANAGER
            WiimoteManager.FindWiimotes(); // Poll native bluetooth drivers to find Wiimotes

            foreach (Wiimote r in WiimoteManager.Wiimotes)
            {
                remote = r;
                remote.SendPlayerLED(true, false, false, true);
                remote.SendDataReportMode(InputDataType.REPORT_BUTTONS);
            }
      #endif
        }
Example #19
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);
    }
Example #20
0
 void Update()
 {
     /////////////////////////////////
     //*wiimoteが見つかってない場合*//
     /////////////////////////////////
     if (!WiimoteManager.HasWiimote())
     {
         WiimoteManager.FindWiimotes();
         return;
     }
     /////////////////////////////
     //*wiimoteが見つかった場合*//
     /////////////////////////////
     _wiimote = WiimoteManager.Wiimotes[0];
 }
Example #21
0
 // Use this for initialization
 void Start()
 {
     if (wiimote == null)
     {
         WiimoteManager.FindWiimotes();
         wiimote = WiimoteManager.Wiimotes [0];
         wiimote.RequestIdentifyWiiMotionPlus();
         wiimote.SendDataReportMode(InputDataType.REPORT_EXT21);
         if (wiimote.ActivateWiiMotionPlus())
         {
             Debug.Log("WiiMotionPlus Activated");
         }
         wiimote.SendPlayerLED(true, false, false, false);
     }
 }
Example #22
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();
     }
 }
Example #23
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);
            }
        }
    }
Example #24
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();
    }
    // 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;
    }
Example #26
0
 /// <summary>
 /// Initiate the Wiimotes
 /// </summary>
 void InitWiimotes()
 {
     WiimoteManager.FindWiimotes();
     foreach (WiimoteApi.Wiimote remote in WiimoteManager.Wiimotes)
     {
         wiimote = remote;
         wiimote.SendPlayerLED(false, false, false, false);
     }
     //If there's no Wiimote detected
     if (wiimote == null)
     {
         isWiimote = false;
         return;
     }
     wiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL_EXT16);
     isWiimote = true;
 }
Example #27
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");
        }
    }
Example #28
0
    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();
        };
    }
    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;
        }
    }
            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);
                }
            }