コード例 #1
0
ファイル: WiiMote.cs プロジェクト: Felix-Aberg/RTCS
 void Start()
 {
     WiimoteManager.FindWiimotes();
     wiimote = WiimoteManager.Wiimotes[0];
     wiimote.SendPlayerLED(true, true, false, false);
     wiimote.SetupIRCamera(IRDataType.FULL);
 }
コード例 #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
    // 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!");
        }
    }
コード例 #4
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);
            }
        }
    }
コード例 #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;
        }
    }
コード例 #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
    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;
            }
        }
    }
コード例 #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);
            }
        }
    }
コード例 #9
0
    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);
    }
コード例 #10
0
ファイル: color.cs プロジェクト: tdunglas/Immersion
    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
    }
コード例 #11
0
ファイル: WiimoteDemo.cs プロジェクト: Nicklon/TFG-Unity
    void SearchAndInitialize()
    {
        WiimoteManager.FindWiimotes();

        wiimote = WiimoteManager.Wiimotes[0];
        wiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL);
        wiimote.SetupIRCamera(IRDataType.EXTENDED);
        wiimote.SendPlayerLED(true, true, true, true);
    }
コード例 #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;
     }
 }
コード例 #13
0
ファイル: Axe.cs プロジェクト: D34D10CK/Bucheron-Simulator
    // Use this for initialization
    void Start()
    {
        WiimoteManager.FindWiimotes();
        wiimote = WiimoteManager.Wiimotes[0];
        wiimote.RequestIdentifyWiiMotionPlus();
        wiimote.ActivateWiiMotionPlus();
        wiimote.SetupIRCamera(IRDataType.BASIC);

        pivot = transform.parent;
    }
コード例 #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;
     }
 }
コード例 #15
0
ファイル: Menu.cs プロジェクト: kokoloko4/FurnitureSimulator
    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++;
                }
            }
        }
    }
コード例 #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];
 }
コード例 #17
0
ファイル: WiiRemotes.cs プロジェクト: Ev-rees/ev-rees
    // 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 !");
        }
    }
コード例 #18
0
ファイル: DefaultInput.cs プロジェクト: yhnu/unity-platformer
        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
        }
コード例 #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);
    }
コード例 #20
0
 void Update()
 {
     /////////////////////////////////
     //*wiimoteが見つかってない場合*//
     /////////////////////////////////
     if (!WiimoteManager.HasWiimote())
     {
         WiimoteManager.FindWiimotes();
         return;
     }
     /////////////////////////////
     //*wiimoteが見つかった場合*//
     /////////////////////////////
     _wiimote = WiimoteManager.Wiimotes[0];
 }
コード例 #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);
     }
 }
コード例 #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();
     }
 }
コード例 #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);
            }
        }
    }
コード例 #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();
    }
コード例 #25
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;
    }
コード例 #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;
 }
コード例 #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");
        }
    }
コード例 #28
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();
        };
    }
コード例 #29
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;
        }
    }
コード例 #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);
                }
            }