예제 #1
0
    // This handles disabling VR in the event that the HMD has been disconnected
    bool onDeviceEvent(PlayStationVR.deviceEventType eventType, int value)
    {
        Debug.LogFormat("onDeviceEvent: {0}, {1}", eventType, value);
        bool handledEvent = false;

        switch (eventType)
        {
        case PlayStationVR.deviceEventType.deviceStopped:
            PlayStationVR.setOutputModeHMD(false);
            handledEvent = true;
            break;

        case PlayStationVR.deviceEventType.StatusChanged:       // e.g. HMD unplugged
            VRDeviceStatus devstatus = (VRDeviceStatus)value;
            Debug.LogFormat("DeviceStatus: {0}", devstatus);
            if (devstatus != VRDeviceStatus.Ready)
            {
                HmdSetupDialog.OpenAsync(0, null);
            }
            handledEvent = true;
            break;

        case PlayStationVR.deviceEventType.MountChanged:
            VRHmdMountStatus status = (VRHmdMountStatus)value;
            Debug.LogFormat("VRHmdMountStatus: {0}", status);
            handledEvent = true;
            break;
        }

        return(handledEvent);
    }
예제 #2
0
    public void SetupHMDDevice()
    {
#if UNITY_PS4
        // The HMD Setup Dialog is not displayed on the social screen in separate
        // mode, so we'll force it to mirror-mode first
        VRSettings.showDeviceView = false;

        // Show the HMD Setup Dialog, and specify the callback for when it's finished
        HmdSetupDialog.OpenAsync(0, OnHmdSetupDialogCompleted);
#endif
    }
예제 #3
0
    void PSVRCompleted(DialogStatus status, DialogResult result)
    {
        Log("PSVR Completed " + status + " " + result);

        if (result != DialogResult.OK)
        {
            HmdSetupDialog.OpenAsync(0, PSVRCompleted);
            return;
        }

        StartCoroutine(SetupPSVR());
    }
예제 #4
0
    public void SetupHMDDevice()
    {
#if UNITY_PS4
        HmdSetupDialog.OpenAsync(0, OnHmdSetupDialogCompleted);
#endif
    }
예제 #5
0
    void Start()
    {
        InputSpeed = 0;
        HeadRot    = 0;
        HeadLean   = 0;
        HeadBend   = 0;

#if !UNITY_PS4 && VZ_GAME
        // Redirect Fmod to Rift headphones
        if (GameObject.Find("FMOD_StudioSystem") != null)
        {
            FMOD.System sys = FMODUnity.RuntimeManager.LowlevelSystem;
//         Debug.Log(sys);

            int num;
            sys.getNumDrivers(out num);
//         Debug.Log(num);

            for (int i = 0; i < num; ++i)
            {
                int              namelen = 100;
                StringBuilder    name    = new StringBuilder(namelen);
                Guid             guid;
                int              systemrate;
                FMOD.SPEAKERMODE speakermode;
                int              speakermodechannels;

                sys.getDriverInfo(i, name, namelen, out guid, out systemrate, out speakermode, out speakermodechannels);

//            Debug.Log(i + " " + name + " " + namelen + " " + guid + " " + systemrate + " " + speakermode + " " + speakermodechannels);

                if (name.ToString() == "Headphones (Rift Audio)")
                {
                    sys.setDriver(i);
                    Debug.Log("Redirecting Fmod audio to Rift headphones");
                    break;
                }
            }
        }
#endif

        // Setup hmd
#if VZ_GAME
        if (VZReplay.Playback())
        {
            mHasHmd = false;
            UnityEngine.VR.VRSettings.enabled = false;

            if (VZReplay.Instance.Camera != null)
            {
                Camera().enabled = false;
            }
        }
        else
#endif
        {
            mHasHmd = UnityEngine.VR.VRDevice.isPresent;
            UnityEngine.VR.VRSettings.enabled = mHasHmd;

#if UNITY_PS4 && !UNITY_EDITOR
            HmdSetupDialog.OpenAsync(0, PSVRCompleted);
#endif
        }

        // Try serial communication
#if VZ_GAME
        if (VZReplay.Playback())
        {
            mBikeState.Type = (int)VZBikeType.None;
        }
        else
#endif
        {
            TryConnectBike();
        }

        // Determine controller for other functions
        mController = ControllerType.Keyboard;

        string[] joysticks = Input.GetJoystickNames();

        if (joysticks.Length > 0)
        {
//			Debug.Log("Joystick = " + joysticks[0]);

            if (joysticks[0] == "Logitech Dual Action")
            {
                mController = ControllerType.Logitech;
            }
            else if (joysticks[0] == "Controller (Xbox One For Windows)")
            {
                //Debug.Log("Xbox controller selected.");
                mController = ControllerType.Xbox;
            }
            else if (joysticks[0] == "Controller (XBOX 360 For Windows)")
            {
                //Debug.Log("Xbox 360 controller selected.");
                mController = ControllerType.X360;
            }
#if UNITY_PS4 && !UNITY_EDITOR
            else if (joysticks[0] != "")
#else
            else if (joysticks[0] == "Wireless Controller")
#endif
            {
                mController = ControllerType.DS4;
            }
        }

        // Log
        String hmd = "None";
        if (mHasHmd)
        {
            if (IsSteamVR)
            {
                hmd = "SteamVR";
            }
            else
            {
#if UNITY_PS4 && !UNITY_EDITOR
                hmd = "PSVR";
#else
                hmd = "Oculus";
#endif
            }
        }
        Debug.Log("Bike:" + mBikeState.Type + " Hmd:" + hmd + " Controller:" + mController);
    }