public void TestHMDDevices() { // ReSharper disable PossibleMultipleEnumeration IDeviceManager mgr; using (mgr = Factory.CreateDeviceManager()) { mgr.RefCount.Should().Be(1); mgr.IsDisposed.Should().BeFalse(); var devices = mgr.HMDDevices; devices.Should().NotBeNull(); foreach (var desc in devices) { desc.DeviceType.Should().NotBe(DeviceType.None); desc.Should().NotBeNull(); desc.IsAvailable.Should().BeTrue(); desc.IsCreated.Should().BeFalse(); using (IHMDDevice hmd = desc.CreateDevice()) { hmd.Type.Should().BeSameAs(desc.DeviceType); hmd.Should().NotBeNull(); } desc.IsCreated.Should().BeTrue(); } } mgr.RefCount.Should().Be(0); mgr.IsDisposed.Should().BeTrue(); // ReSharper restore PossibleMultipleEnumeration }
public DeviceResources(IFactory factory, IDeviceHandle <IHMDDevice, IHMDInfo> handle) { if (factory == null || handle == null) { throw new ArgumentNullException(); } Info = handle.DeviceInfo; Device = handle.CreateDevice(); Sensor = Device.Sensor; Fusion = factory.CreateSensorFusion(Sensor); if (Info == null) { throw new ArgumentNullException(); } if (Device == null) { throw new ArgumentNullException(); } if (Sensor == null) { throw new ArgumentNullException(); } Key = new DeviceKey(Sensor.Info); }
public DeviceResources(IFactory factory, IDeviceHandle<IHMDDevice, IHMDInfo> handle) { if (factory == null || handle == null) throw new ArgumentNullException(); Info = handle.DeviceInfo; Device = handle.CreateDevice(); Sensor = Device.Sensor; Fusion = factory.CreateSensorFusion(Sensor); if (Info == null) throw new ArgumentNullException(); if (Device == null) throw new ArgumentNullException(); if (Sensor == null) throw new ArgumentNullException(); Key = new DeviceKey(Sensor.Info); }
public DeviceResources(IFactory factory, IHMDDevice handle) { if (factory == null || handle == null) throw new ArgumentNullException(); Info = handle.Info; Device = handle; Sensor = Device.GetSensorState(0.0); if (Info == null) throw new ArgumentNullException(); if (Device == null) throw new ArgumentNullException(); if (Sensor == null) System.Diagnostics.Trace.TraceWarning("Unable to create Sensor"); if (Sensor != null) Key = new DeviceKey(Device.SensorInfo); }
public DeviceResources(IFactory factory, IDeviceHandle<IHMDDevice, IHMDInfo> handle) { if (factory == null || handle == null) throw new ArgumentNullException(); Info = handle.DeviceInfo; Device = handle.CreateDevice(); Sensor = Device.Sensor; Fusion = factory.CreateSensorFusion(Sensor); if (Info == null) throw new ArgumentNullException(); if (Device == null) throw new ArgumentNullException(); if (Sensor == null) System.Diagnostics.Trace.TraceWarning("Unable to create Sensor"); if (Sensor != null) Key = new DeviceKey(Sensor.Info); }
private OculusOrientation() { manager = Factory.CreateDeviceManager(); fusion = Factory.CreateSensorFusion(); var devices = manager.HMDDevices; if (devices.Length <= 0) { throw new Exception("No Oculus Hardware found"); } var handle = devices[0]; Console.WriteLine("Found an HMD device: " + handle.DeviceInfo.DisplayDevice); device = handle.CreateDevice(); fusion.AttachedDevice = device.Sensor; fusion.IsPredictionEnabled = true; updateThread = new Thread(new ThreadStart(updateOrientation)); updateThread.Start(); }
private void AddDevice(IHMDDevice handle) { _lock.EnterWriteLock(); try { var resources = new DeviceResources(_factory, handle); var key = resources.Key; _nativeResources.Add(key, resources); HMD hmd; if (!_devices.TryGetValue(key, out hmd)) { // There's no HMD for this device yet: We need to create one hmd = new HMD(handle.Info, _lock); _devices.Add(key, hmd); } hmd.Resources = resources; var fn = DeviceAttached; if (fn != null) { fn(hmd); } } finally { _lock.ExitWriteLock(); } }