Esempio n. 1
0
        public bool Destroy()
        {
            if (!Created)
            {
                return(true);
            }
            // destroy devices
            foreach (var pair in deviceHandles)
            {
                switch (pair.Key.DeviceType)
                {
                case VirtualDeviceType.Keyboard:
                    Ivj.DisconnectKeyboard(contextHandle, pair.Value);
                    break;

                case VirtualDeviceType.TrackingInterface:
                    Ivj.DisconnectFreetrackInterface(contextHandle, pair.Value);
                    break;

                default:
                    throw new NotImplementedException();
                    // TODO: implement missing cases
                }
            }
            deviceHandles.Clear();
            bool result = Ivj.DestroyContext(contextHandle);

            contextHandle = IntPtr.Zero;
            return(result);
        }
Esempio n. 2
0
        public bool DisconnectDevice(IVirtualDevice device)
        {
            if (device == null)
            {
                throw new ArgumentNullException("device");
            }
            if (!Created)
            {
                return(false);
            }
            IntPtr handle;

            if (!deviceHandles.TryGetValue(device, out handle))
            {
                return(true);
            }
            switch (device.DeviceType)
            {
            case VirtualDeviceType.Keyboard:
                Ivj.DisconnectKeyboard(contextHandle, handle);
                break;

            case VirtualDeviceType.TrackingInterface:
                Ivj.DisconnectFreetrackInterface(contextHandle, handle);
                break;

            default:
                throw new NotImplementedException();
            }
            deviceHandles.Remove(device);
            return(true);
        }