void OnGUI() { if (!PSMoveInput.IsConnected) { GUI.Label(new Rect(20, 45, 30, 35), "IP:"); ipAddress = GUI.TextField(new Rect(60, 45, 120, 25), ipAddress); GUI.Label(new Rect(190, 45, 30, 35), "port:"); port = GUI.TextField(new Rect(230, 45, 50, 25), port); if (GUI.Button(new Rect(300, 40, 100, 35), "Connect")) { PSMoveInput.Connect(ipAddress, int.Parse(port)); } } else { if (GUI.Button(new Rect(20, 40, 100, 35), "Disconnect")) { PSMoveInput.Disconnect(); } } if (GUI.Button(new Rect(20, 80, 100, 35), "Start")) { Application.LoadLevel("menuui"); } }
void Update() { PSMoveInput.UpdateState(); if (enableDefaultInGameCalibrate) { if (PSMoveInput.IsConnected) { foreach (MoveController controller in PSMoveInput.MoveControllers) { if (controller.Data.GetButtonsDown(MoveButton.Move)) { if (controller.Data.SphereColor == new Color(0, 0, 0, 1)) { controller.CalibrateAndTrack(); } else { controller.CalibrateAndTrack(controller.Data.SphereColor); } } if (controller.Data.GetButtonsDown(MoveButton.Select)) { controller.Reset(); } } } } }
void Start() { loadFile("config.ini"); initialTime = Time.time; PSMoveInput.Connect(ipAddress, int.Parse(port)); Debug.Log("Connecting... Address: " + ipAddress + ", Port: " + port); }
// Update is called once per frame void Update() { Color32[] image = PSMoveInput.GetCameraImage(); if (image != null && image.Length == 640 * 480) { tex.SetPixels32(image); tex.Apply(false); } }
// Use this for initialization void Start() { loadFile(filename); //connect psmove if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.OSXPlayer) { PSMoveInput.Connect(ipAddress, int.Parse(port)); } }
/// <summary> /// Let PS3 pick color and track the selected PS Move. /// Use this method when you do not care about the color of the ball. /// </summary> public void AutoTrack() { if (!PSMoveInput.IsConnected) { return; } int[] hues = PSMoveInput.GetTrackingHues(); hues[Num] = Convert.ToInt32(PSMoveInput.PICK_FOR_ME); PSMoveNetwork.moveClient.SendRequestPacket(PSMoveClient.ClientRequest.PSMoveClientRequestTrackHues, Convert.ToUInt32(hues[0]), Convert.ToUInt32(hues[1]), Convert.ToUInt32(hues[2]), Convert.ToUInt32(hues[3])); }
void Update() { if (PSMoveInput.IsConnected) { //Application.LoadLevel("intro"); } else { if (initialTime + timeout < Time.time) { Debug.Log("Unsuccessful...reconnecting.."); initialTime = Time.time; PSMoveInput.Connect(ipAddress, int.Parse(port)); } } }
void OnGUI() { if (!PSMoveInput.IsConnected) { GUI.Label(new Rect(20, 45, 30, 35), "IP:"); ipAddress = GUI.TextField(new Rect(60, 45, 120, 25), ipAddress); GUI.Label(new Rect(190, 45, 30, 35), "port:"); port = GUI.TextField(new Rect(230, 45, 50, 25), port); if (GUI.Button(new Rect(300, 40, 100, 35), "Connect")) { PSMoveInput.Connect(ipAddress, int.Parse(port)); } } }
// Use this for initialization void Start() { loadFile(filename); PSMoveInput.Connect(ipAddress, int.Parse(port)); /* * //find active psmove controller * for (int i=0; i<PSMoveInput.MoveControllers.Length; i++) { * if (PSMoveInput.MoveControllers[i].Connected) { * activeMoveController = PSMoveInput.MoveControllers[i]; * break; * } * } * * Debug.Log ("activeMoveController" + activeMoveController); */ }
void OnApplicationQuit() { PSMoveInput.Disconnect(); }
void OnGUI() { if (!PSMoveInput.IsConnected) { GUI.Label(new Rect(20, 45, 30, 35), "IP:"); ipAddress = GUI.TextField(new Rect(60, 45, 120, 25), ipAddress); GUI.Label(new Rect(190, 45, 30, 35), "port:"); port = GUI.TextField(new Rect(230, 45, 50, 25), port); if (GUI.Button(new Rect(300, 40, 100, 35), "Connect")) { PSMoveInput.Connect(ipAddress, int.Parse(port)); } } else { if (GUI.Button(new Rect(20, 40, 100, 35), "Disconnect")) { PSMoveInput.Disconnect(); Reset(); } GUI.Label(new Rect(10, 10, 150, 100), "PS Move count : " + PSMoveInput.MoveCount); GUI.Label(new Rect(140, 10, 150, 100), "PS Nav count : " + PSMoveInput.NavCount); //camera stream on/off if (GUI.Button(new Rect(5, 80, 130, 35), cameraStr)) { if (cameraStr == "Camera Switch On") { PSMoveInput.CameraFrameResume(); cameraStr = "Camera Switch Off"; } else { PSMoveInput.CameraFramePause(); cameraStr = "Camera Switch On"; } } //color and rumble for move number 0 if (PSMoveInput.MoveControllers[0].Connected) { //Set Color and Track GUI.Label(new Rect(300, 50, 200, 20), "R,G,B are floats that fall in 0 ~ 1"); GUI.Label(new Rect(260, 20, 20, 20), "R"); rStr = GUI.TextField(new Rect(280, 20, 60, 20), rStr); GUI.Label(new Rect(350, 20, 20, 20), "G"); gStr = GUI.TextField(new Rect(370, 20, 60, 20), gStr); GUI.Label(new Rect(440, 20, 20, 20), "B"); bStr = GUI.TextField(new Rect(460, 20, 60, 20), bStr); if (GUI.Button(new Rect(550, 30, 160, 35), "SetColorAndTrack")) { try { float r = float.Parse(rStr); float g = float.Parse(gStr); float b = float.Parse(bStr); PSMoveInput.MoveControllers[0].SetColorAndTrack(new Color(r, g, b)); } catch (Exception e) { Debug.Log("input problem: " + e.Message); } } //Rumble rumbleStr = GUI.TextField(new Rect(805, 20, 40, 20), rumbleStr); GUI.Label(new Rect(800, 50, 200, 20), "0 ~ 19"); if (GUI.Button(new Rect(870, 30, 100, 35), "Rumble")) { try { int rumbleValue = int.Parse(rumbleStr); PSMoveInput.MoveControllers[0].SetRumble(rumbleValue); } catch (Exception e) { Debug.Log("input problem: " + e.Message); } } } //move controller information for (int i = 0; i < PSMoveInput.MAX_MOVE_NUM; i++) { MoveController moveController = PSMoveInput.MoveControllers[i]; if (moveController.Connected) { MoveData moveData = moveController.Data; string display = "PS Move #" + i + "\nPosition:\t\t" + moveData.Position + "\nVelocity:\t\t" + moveData.Velocity + "\nAcceleration:\t\t" + moveData.Acceleration + "\nOrientation:\t\t" + moveData.Orientation + "\nAngular Velocity:\t\t" + moveData.AngularVelocity + "\nAngular Acceleration:\t\t" + moveData.AngularAcceleration + "\nHandle Position:\t\t" + moveData.HandlePosition + "\nHandle Velocity:\t\t" + moveData.HandleVelocity + "\nHandle Acceleration:\t\t" + moveData.HandleAcceleration + "\n" + "\nTrigger Value:\t\t" + moveData.ValueT + "\nButtons:\t\t" + moveData.Buttons + "\nSphere Color:\t\t" + moveData.SphereColor + "\nIs Tracking:\t\t" + moveData.IsTracking + "\nTracking Hue:\t\t" + moveData.TrackingHue; GUI.Label(new Rect(10 + 650 * (i / 2), 120 + 310 * (i % 2), 300, 400), display); } } for (int j = 0; j < PSMoveInput.MAX_NAV_NUM; j++) { NavController navController = PSMoveInput.NavControllers[j]; if (navController.Connected) { NavData navData = navController.Data; string navDisplay = "PS Nav #" + j + "\nAnalog :\t\t" + navData.ValueAnalog + "\nL2 Value:\t\t" + navData.ValueL2 + "\nButtons:\t\t" + navData.Buttons; GUI.Label(new Rect(400, 100 + 95 * j, 150, 95), navDisplay); } } } }