Example #1
0
 public void OnApplicationQuit()
 {
     if (enablePSMove && psMoveWrapper && psMoveWrapper.isConnected)
     {
         psMoveWrapper.Disconnect(false);
     }
 }
Example #2
0
    void OnGUI()
    {
        GUI.Label(new Rect(10, 10, 150, 100), "PS Move count : " + psMoveWrapper.moveCount);
        GUI.Label(new Rect(140, 10, 150, 100), "PS Nav count : " + psMoveWrapper.navCount);

        if (GUI.Button(new Rect(20, 40, 100, 35), connectStr))
        {
            if (connectStr == "Connect")
            {
                psMoveWrapper.Connect();
                if (psMoveWrapper.isConnected)
                {
                    connectStr = "Disconnect";
                }
            }
            else
            {
                psMoveWrapper.Disconnect();
                connectStr = "Connect";
                Reset();
            }
        }

        if (psMoveWrapper.isConnected)
        {
            //camera stream on/off
            if (GUI.Button(new Rect(5, 80, 130, 35), cameraStr))
            {
                if (cameraStr == "Camera Switch On")
                {
                    psMoveWrapper.CameraFrameResume();
                    cameraStr = "Camera Switch Off";
                }
                else
                {
                    psMoveWrapper.CameraFramePause();
                    cameraStr = "Camera Switch On";
                }
            }

            //color and rumble for move number 0
            if (psMoveWrapper.moveConnected[0])
            {
                //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);
                        psMoveWrapper.SetColorAndTrack(0, new Color(r, g, b));
                    }
                    catch (Exception e) {
                        Debug.Log("input problem");
                    }
                }
                //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);
                        psMoveWrapper.SetRumble(0, rumbleValue);
                    }
                    catch (Exception e) {
                        Debug.Log("input problem");
                    }
                }
            }

            //move controller information
            for (int i = 0; i < PSMoveWrapper.MAX_MOVE_NUM; i++)
            {
                if (psMoveWrapper.moveConnected[i])
                {
                    string display = "PS Move #" + i +
                                     "\nPosition:\t\t" + psMoveWrapper.position[i] +
                                     "\nVelocity:\t\t" + psMoveWrapper.velocity[i] +
                                     "\nAcceleration:\t\t" + psMoveWrapper.acceleration[i] +
                                     "\nOrientation:\t\t" + psMoveWrapper.orientation[i] +
                                     "\nAngular Velocity:\t\t" + psMoveWrapper.angularVelocity[i] +
                                     "\nAngular Acceleration:\t\t" + psMoveWrapper.angularAcceleration[i] +
                                     "\nHandle Position:\t\t" + psMoveWrapper.handlePosition[i] +
                                     "\nHandle Velocity:\t\t" + psMoveWrapper.handleVelocity[i] +
                                     "\nHandle Acceleration:\t\t" + psMoveWrapper.handleAcceleration[i] +
                                     "\n" +
                                     "\nTrigger Value:\t\t" + psMoveWrapper.valueT[i] +
                                     "\nButtons:\t\t" + GetButtonStr(i) +
                                     "\nSphere Color:\t\t" + psMoveWrapper.sphereColor[i] +
                                     "\nIs Tracking:\t\t" + psMoveWrapper.isTracking[i] +
                                     "\nTracking Hue:\t\t" + psMoveWrapper.trackingHue[i];
                    GUI.Label(new Rect(10 + 650 * (i / 2), 120 + 310 * (i % 2), 300, 400), display);
                }
            }
            for (int j = 0; j < PSMoveWrapper.MAX_NAV_NUM; j++)
            {
                if (psMoveWrapper.navConnected[j])
                {
                    string navDisplay = "PS Nav #" + j +
                                        "\nAnalog X:\t\t" + psMoveWrapper.valueNavAnalogX[j] +
                                        "\nAnalog Y:\t\t" + psMoveWrapper.valueNavAnalogY[j] +
                                        "\nL2 Value:\t\t" + psMoveWrapper.valueNavL2[j] +
                                        "\nButtons:\t\t" + GetNavButtonStr(j);
                    GUI.Label(new Rect(400, 100 + 95 * j, 150, 95), navDisplay);
                }
            }
        }
    }
 void OnDestroy()
 {
     psMoveWrapper.Disconnect(false);
 }