void IScene.Attach(ISceneHost host) { this.Host = host; keyboardInput = new InputDevices.KeyboardInputDevice(); gamepadInput = new InputDevices.GamepadInputDevice(); navigatorInput = new InputDevices.NavigatorInputDevice(); _device = host.Device; if (_device == null) { throw new Exception("Scene host device is null"); } graphicsDevice = SharpDX.Toolkit.Graphics.GraphicsDevice.New(_device); customEffect = Headset.GetCustomEffect(graphicsDevice); MediaDecoder.Instance.OnContentChanged += ContentChanged; projectionMatrix = Matrix.PerspectiveFovRH((float)(72f * Math.PI / 180f), (float)16f / 9f, 0.0001f, 50.0f); worldMatrix = Matrix.Identity; //primitive = GraphicTools.CreateGeometry(projectionMode, graphicsDevice); _device.ImmediateContext.Flush(); ResetRotation(); var devices = SharpDX.RawInput.Device.GetDevices(); devices.ForEach(dev => { if (dev.DeviceType == SharpDX.RawInput.DeviceType.Mouse) { SharpDX.RawInput.Device.RegisterDevice(SharpDX.Multimedia.UsagePage.Generic, SharpDX.Multimedia.UsageId.GenericMouse, SharpDX.RawInput.DeviceFlags.None, dev.Handle); } Console.WriteLine($"Scene::Attach DX device: {dev.DeviceName} :: {dev.DeviceType}"); }); }
//bool IContentUpdatableFromMediaEngine.IsReady => throw new NotImplementedException(); internal void HeadsetEnabled(Headset headset) { headset.ProvideLook += Headset_ProvideLook; log.Publish("headset", headset.DescribeType); }
internal void HeadsetDisabled(Headset headset) { headset.ProvideLook -= Headset_ProvideLook; Headset_ProvideLook(Vector3.Zero, Quaternion.Identity, 0); LoggerManager.Publish("headset", null); }
// ShellViewModel.cs#636 void ResetVR() { Logger log = new Logger("ResetVR"); if (CurrentHeadsetMode == SettingHeadsetUsage) { log.Info("Will not reset, because the headset is still alive."); return; } else { log.Info($"Headset change: {CurrentHeadsetMode} -> {SettingHeadsetUsage}"); } CurrentHeadset?.Abort(); CurrentHeadset = null; while (headsets.Any(h => h.Lock)) { Thread.Sleep(50); } // case HeadsetMode.Oculus: Logic.Notify("Oculus Rift playback selected."); break; // case HeadsetMode.OSVR: Logic.Notify("OSVR playback selected."); break; // case HeadsetMode.OpenVR: Logic.Notify("OpenVR (SteamVR) playback selected."); break; if (SettingHeadsetUsage == HeadsetMode.Oculus) { Logic.Instance.stats.TrackEvent("Application events", "Headset", "Oculus Rift"); try { Headset oculusPlayback = headsets.Find(h => h is Oculus.OculusPlayback); if (oculusPlayback.IsPresent()) { Logic.Notify("Oculus Rift detected. Starting VR playback..."); oculusPlayback.Media = SelectedServiceResult; oculusPlayback.Start(); ShellViewModel.SendEvent("headsetConnected", "oculus"); CurrentHeadset = oculusPlayback; return; } } catch (Exception e) { log.Error("Headset detection exception (Oculus): " + e); } Logic.Notify("Oculus Rift not detected."); ShellViewModel.SendEvent("headsetError", "oculus"); } if (SettingHeadsetUsage == HeadsetMode.OpenVR) { Logic.Instance.stats.TrackEvent("Application events", "Headset", "OpenVR"); try { Headset openVRPlayback = headsets.Find(h => h is OpenVR.OpenVRPlayback); if (openVRPlayback.IsPresent()) { Logic.Notify("OpenVR detected. Starting VR playback..."); openVRPlayback.Media = SelectedServiceResult; openVRPlayback.Start(); ShellViewModel.SendEvent("headsetConnected", "openvr"); CurrentHeadset = openVRPlayback; return; } } catch (Exception e) { log.Error("Headset detection exception (OpenVR): " + e); } Logic.Notify("OpenVR not detected."); ShellViewModel.SendEvent("headsetError", "openvr"); } if (SettingHeadsetUsage == HeadsetMode.OSVR) { Logic.Instance.stats.TrackEvent("Application events", "Headset", "OSVR"); Headset osvrPlayback = headsets.Find(h => h is OSVRKit.OSVRPlayback); if (osvrPlayback.IsPresent()) { Logic.Notify("OSVR detected. Starting VR playback..."); osvrPlayback.Media = SelectedServiceResult; osvrPlayback.Start(); ShellViewModel.SendEvent("headsetConnected", "osvr"); CurrentHeadset = osvrPlayback; return; } Logic.Notify("OSVR not detected."); ShellViewModel.SendEvent("headsetError", "osvr"); } }