Exemplo n.º 1
0
        private void RemoveDevice(DeviceResources resources)
        {
            _lock.EnterWriteLock();
            try
            {
                // We need to find the corresponding HMD entry and remove
                // those resources from it.
                HMD hmd;
                var key = resources.Key;
                if (_devices.TryGetValue(key, out hmd))
                {
                    hmd.Resources = null;
                }

                _nativeResources.Remove(key);
                resources.Dispose();

                var fn = DeviceDetached;
                if (hmd != null && fn != null)
                {
                    fn(hmd);
                }
            }
            finally
            {
                _lock.ExitWriteLock();
            }
        }
Exemplo n.º 2
0
        private void AddDevice(IDeviceHandle <IHMDDevice, IHMDInfo> 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.DeviceInfo, _lock);
                    _devices.Add(key, hmd);
                }

                hmd.Resources = resources;

                var fn = DeviceAttached;
                if (fn != null)
                {
                    fn(hmd);
                }
            }
            finally
            {
                _lock.ExitWriteLock();
            }
        }
Exemplo n.º 3
0
        private void RemoveDevice(DeviceResources resources)
        {
            _lock.EnterWriteLock();
            try
            {
                // We need to find the corresponding HMD entry and remove
                // those resources from it.
                HMD hmd;
                var key = resources.Key;
                if (_devices.TryGetValue(key, out hmd))
                {
                    hmd.Resources = null;
                }

                _nativeResources.Remove(key);
                resources.Dispose();

                var fn = DeviceDetached;
                if (hmd != null && fn != null)
                {
                    fn(hmd);
                }
            }
            finally
            {
                _lock.ExitWriteLock();
            }
        }
Exemplo n.º 4
0
        private void AddDevice(IDeviceHandle<IHMDDevice, IHMDInfo> 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.DeviceInfo, _lock);
                    _devices.Add(key, hmd);
                }

                hmd.Resources = resources;

                var fn = DeviceAttached;
                if (fn != null)
                {
                    fn(hmd);
                }
            }
            finally
            {
                _lock.ExitWriteLock();
            }
        }