Exemple #1
0
        /// <summary>
        /// Registers the devices that supply the raw input data.
        /// </summary>
        /// <param name="usagePage">The usage page.</param>
        /// <param name="usageId">The usage id.</param>
        /// <param name="flags">The flags.</param>
        /// <param name="target">The target.</param>
        /// <param name="options">The options.</param>
        public static void RegisterDevice(UsagePage usagePage, UsageId usageId, DeviceFlags flags, IntPtr target, RegisterDeviceOptions options = RegisterDeviceOptions.Default)
        {
            var rawInputDevices = new RawInputDevice[1];

            rawInputDevices[0].UsagePage = (short)usagePage;
            rawInputDevices[0].Usage     = (short)usageId;
            rawInputDevices[0].Flags     = (int)flags;
            rawInputDevices[0].Target    = target;

            // Register this device
            RawInputFunctions.RegisterRawInputDevices(rawInputDevices, 1, Utilities.SizeOf <RawInputDevice>());

            if (options != RegisterDeviceOptions.NoFiltering && rawInputMessageFilter == null)
            {
                rawInputMessageFilter = new RawInputMessageFilter();
                if (options == RegisterDeviceOptions.Default)
                {
                    Application.AddMessageFilter(rawInputMessageFilter);
                }
                else
                {
                    MessageFilterHook.AddMessageFilter(target, rawInputMessageFilter);
                }
            }
        }
Exemple #2
0
 // This allocates, however it should be used only when launching app
 public static void RegisterDevice(UsagePage usagePage, UsageId usageId, DeviceFlags flags, IntPtr target)
 {
     Device.RegisterDevice(usagePage, usageId, flags, target, false);
     if (m_filter == null)
     {
         m_filterWindow = target;
         m_filter = new RawInputMessageFilter();
         MessageFilterHook.AddMessageFilter(m_filterWindow, m_filter);
     }
 }
Exemple #3
0
            public DisposableRawInputHook(UsagePage usagePage, UsageId usageId, DeviceFlags flags, IntPtr target,
                                          EventHandler <KeyboardInputEventArgs> handler)
            {
                this.usagePage = usagePage;
                this.usageId   = usageId;
                this.handler   = handler;

                Device.RegisterDevice(usagePage, usageId, flags, target);
                Device.KeyboardInput += handler;
            }
 private void ParseCapabilities()
 {
     if (!string.IsNullOrEmpty(description.capabilities))
     {
         var capabilities = JsonUtility.FromJson <Capabilities>(description.capabilities);
         m_SubType = capabilities.subType;
         m_Flags   = capabilities.flags;
     }
     m_HaveParsedCapabilities = true;
 }
Exemple #5
0
 // This allocates, however it should be used only when launching app
 public static void RegisterDevice(UsagePage usagePage, UsageId usageId, DeviceFlags flags, IntPtr target)
 {
     Device.RegisterDevice(usagePage, usageId, flags, target, false);
     if (m_filter == null)
     {
         m_filterWindow = target;
         m_filter       = new RawInputMessageFilter();
         MessageFilterHook.AddMessageFilter(m_filterWindow, m_filter);
     }
 }
Exemple #6
0
        private DeviceFlags QueryDeviceFlags()
        {
            string message = Command.SendCommand(_appSettings.LibVoltronicPath, DeviceFlags.COMMAND);

            if (DeviceFlags.CanProcess(message))
            {
                return(new DeviceFlags(message));
            }
            else
            {
                _logger.LogInformation($"Error in Command {DeviceFlags.COMMAND} : {message}");
            }
            return(null);
        }
        public Device(DeviceFlags flags, int numThreads)
        {
            var device = OidnAPI.oidnNewDevice(flags);

            if (numThreads > 0)
            {
                OidnAPI.oidnSetDevice1i(device, "numThreads", numThreads);
            }

            OidnAPI.oidnCommitDevice(device);

            m_numThreads = numThreads > 0 ? numThreads : OidnAPI.oidnGetDevice1i(device, "numThreads");

            m_device = device;
        }
        /// <summary>
        ///   Registers a device that supplies the raw input data.
        /// </summary>
        /// <param name="usagePage">The usage page.</param>
        /// <param name="usageId">The usage id.</param>
        /// <param name="flags">A combination of flags specifying how to interpret the values of <paramref name="usageId"/> and <paramref name="usagePage"/>.</param>
        /// <param name="windowHandle">
        ///   A handle to the target window. Specify <see cref="IntPtr.Zero"/> to not associate the device with a window. Instead the
        ///   input data will follow the input focus. This is useful when specifying the flag <see cref="DeviceFlags.InputSink"/> or
        ///   <see cref="DeviceFlags.ExclusiveInputSink"/>. The default value is <see cref="IntPtr.Zero"/>.
        /// </param>
        /// <remarks>
        ///   To receive <c>WM_INPUT</c> messages (through the events <see cref="MouseInput"/>, <see cref="KeyboardInput"/>, and
        ///   <see cref="Input"/>), an application must first register the raw input devices using <see cref="RegisterRawInputDevice"/>.
        ///   By default, an application does not receive raw input.
        ///   <para/>
        ///   To receive <c>WM_INPUT_DEVICE_CHANGE</c> messages (through the <see cref="DeviceChanged"/> event), an application must
        ///   specify <see cref="DeviceFlags.DeviceNotify"/> for each device class that is specified by the <see cref="UsagePage"/>
        ///   and <see cref="UsageId"/> of the  <see cref="RawInputDevice" /> structure. By default, an application does not receive
        ///   <c>WM_INPUT_DEVICE_CHANGE</c> notifications for raw input device arrival and removal.
        ///   <para/>
        ///   To unregister a device, specify <see cref="DeviceFlags.Remove"/>. This tells the operating system to stop reading
        ///   from a device that matches the top level collection (specified through <paramref name="usagePage"/> and
        ///   <paramref name="usageId"/>). Alternatively, use the <see cref="UnregisterDevice"/> method.
        ///   <para/>
        ///   If the <see cref="DeviceFlags.Remove"/> flag is set and <paramref name="windowHandle"/> is not set to
        ///   <see cref="IntPtr.Zero"/>, then parameter validation will fail.
        /// </remarks>
        public static void RegisterDevice(UsagePage usagePage, UsageId usageId, DeviceFlags flags, IntPtr windowHandle = default)
        {
            RawInputDevice rawInputDevice;

            rawInputDevice.UsagePage = usagePage;
            rawInputDevice.UsageId   = usageId;
            rawInputDevice.Flags     = flags;
            rawInputDevice.Target    = windowHandle;

            if (!RegisterRawInputDevice(rawInputDevice))
            {
                CheckLastResult();
            }

            UpdateRegisteredDeviceList();
        }
Exemple #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="flags"></param>
        /// <returns></returns>
        private string CreateQuery(DeviceFlags flags)
        {
            string query = string.Empty;

            query += $"?network={flags.HasFlag(DeviceFlags.NETWORK).ToString().ToLower()}";
            query += $"&endpoints={flags.HasFlag(DeviceFlags.ENDPOINTS).ToString().ToLower()}";
            query += $"&type={flags.HasFlag(DeviceFlags.TYPE).ToString().ToLower()}";
            query += $"&config={flags.HasFlag(DeviceFlags.CONFIG).ToString().ToLower()}";
            query += $"&state={flags.HasFlag(DeviceFlags.STATE).ToString().ToLower()}";
            query += $"&icons={flags.HasFlag(DeviceFlags.ICONS).ToString().ToLower()}";
            query += $"&info={flags.HasFlag(DeviceFlags.INFO).ToString().ToLower()}";
            query += $"&descriptor={flags.HasFlag(DeviceFlags.DESCRIPTOR).ToString().ToLower()}";
            query += $"&room={flags.HasFlag(DeviceFlags.ROOM).ToString().ToLower()}";
            query += $"&unsupported={flags.HasFlag(DeviceFlags.UNSUPPORTED).ToString().ToLower()}";
            query += $"&full={flags.HasFlag(DeviceFlags.FULL).ToString().ToLower()}";

            return(query);
        }
Exemple #10
0
        static RawInputService()
        {
            messageOnlyWindow            = new MessageOnlyWindow();
            messageOnlyWindow.OnWndProc += (sender, m) =>
            {
                switch (m.Msg)
                {
                case (int)WM.INPUT:
                    Device.HandleMessage(m.LParam, m.HWnd);
                    break;

                case (int)WM.INPUT_DEVICE_CHANGE:
                    EnumerateDevices();
                    break;
                }
            };
            const DeviceFlags deviceFlags = DeviceFlags.InputSink | DeviceFlags.DeviceNotify;

            Device.RegisterDevice(UsagePage.Generic, UsageId.GenericKeyboard, deviceFlags, messageOnlyWindow.Handle, RegisterDeviceOptions.NoFiltering);
            Device.RegisterDevice(UsagePage.Generic, UsageId.GenericMouse, deviceFlags, messageOnlyWindow.Handle, RegisterDeviceOptions.NoFiltering);
        }
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.DeviceDeviceFlags                 = ((DeviceFlags)(binaryReader.ReadInt32()));
     this.PowerTransitionTime               = binaryReader.ReadSingle();
     this.PowerAccelerationTime             = binaryReader.ReadSingle();
     this.PositionTransitionTime            = binaryReader.ReadSingle();
     this.PositionAccelerationTime          = binaryReader.ReadSingle();
     this.DepoweredPositionTransitionTime   = binaryReader.ReadSingle();
     this.DepoweredPositionAccelerationTime = binaryReader.ReadSingle();
     this.DeviceLightmapFlags               = ((LightmapFlags)(binaryReader.ReadInt16()));
     this.fieldpad3   = binaryReader.ReadBytes(2);
     this.Open        = binaryReader.ReadTagReference();
     this.Close       = binaryReader.ReadTagReference();
     this.Opened      = binaryReader.ReadTagReference();
     this.Closed      = binaryReader.ReadTagReference();
     this.Depowered   = binaryReader.ReadTagReference();
     this.Repowered   = binaryReader.ReadTagReference();
     this.DelayTime   = binaryReader.ReadSingle();
     this.DelayEffect = binaryReader.ReadTagReference();
     this.AutomaticActivationRadius = binaryReader.ReadSingle();
     return(pointerQueue);
 }
Exemple #12
0
 /// <summary>
 /// Registers the devices that supply the raw input data.
 /// </summary>
 /// <param name="usagePage">The usage page.</param>
 /// <param name="usageId">The usage id.</param>
 /// <param name="flags">The flags.</param>
 public static void RegisterDevice(UsagePage usagePage, UsageId usageId, DeviceFlags flags)
 {
     RegisterDevice(usagePage, usageId, flags, IntPtr.Zero);
 }
Exemple #13
0
        /// <summary>
        /// Registers the devices that supply the raw input data.
        /// </summary>
        /// <param name="usagePage">The usage page.</param>
        /// <param name="usageId">The usage id.</param>
        /// <param name="flags">The flags.</param>
        /// <param name="target">The target.</param>
        /// <param name="options">The options.</param>
        public static void RegisterDevice(UsagePage usagePage, UsageId usageId, DeviceFlags flags, IntPtr target, RegisterDeviceOptions options = RegisterDeviceOptions.Default)
        {
            var rawInputDevices = new RawInputDevice[1];
            rawInputDevices[0].UsagePage = (short)usagePage;
            rawInputDevices[0].Usage = (short)usageId;
            rawInputDevices[0].Flags = (int)flags;
            rawInputDevices[0].Target = target;

            // Register this device
            RawInputFunctions.RegisterRawInputDevices(rawInputDevices, 1, Utilities.SizeOf<RawInputDevice>());

            if (options != RegisterDeviceOptions.NoFiltering && rawInputMessageFilter == null)
            {
                rawInputMessageFilter = new RawInputMessageFilter();
                if (options == RegisterDeviceOptions.Default)
                {
                    Application.AddMessageFilter(rawInputMessageFilter);
                }
                else
                {
                    MessageFilterHook.AddMessageFilter(target, rawInputMessageFilter);
                }
            }
        }
Exemple #14
0
 /// <summary>
 /// Registers the devices that supply the raw input data.
 /// </summary>
 /// <param name="usagePage">The usage page.</param>
 /// <param name="usageId">The usage id.</param>
 /// <param name="flags">The flags.</param>
 public static void RegisterDevice(UsagePage usagePage, UsageId usageId, DeviceFlags flags)
 {
     RegisterDevice(usagePage, usageId, flags, IntPtr.Zero);
 }
Exemple #15
0
            public DisposableRawInputHook(UsagePage usagePage, UsageId usageIdKeyboard, UsageId usageIdMouse, DeviceFlags flags, IntPtr target,
                                          EventHandler <KeyboardInputEventArgs> keyHandler, EventHandler <MouseInputEventArgs> mouseHandler)
            {
                this.usagePage       = usagePage;
                this.usageIdKeyboard = usageIdKeyboard;
                this.usageIdMouse    = usageIdMouse;
                this.keyHandler      = keyHandler;
                this.mouseHandler    = mouseHandler;

                Device.RegisterDevice(usagePage, usageIdKeyboard, flags, target);
                Device.KeyboardInput += keyHandler;

                Device.RegisterDevice(usagePage, usageIdMouse, flags, target);
                Device.MouseInput += mouseHandler;
            }
Exemple #16
0
        /// <summary>
        /// Registers the devices that supply the raw input data.
        /// </summary>
        /// <param name="usagePage">The usage page.</param>
        /// <param name="usageId">The usage id.</param>
        /// <param name="flags">The flags.</param>
        /// <param name="target">The target.</param>
        /// <param name="addMessageFilter">if set to <c>true</c> register message filter to Application.AddMessageFilter.</param>
        public static void RegisterDevice(UsagePage usagePage, UsageId usageId, DeviceFlags flags, IntPtr target, bool addMessageFilter = true)
        {
            if (target == IntPtr.Zero)
            {
                target = Win32Native.GetFocus();
            }

            var rawInputDevices = new RawInputDevice[1];
            rawInputDevices[0].UsagePage = (short) usagePage;
            rawInputDevices[0].Usage = (short) usageId;
            rawInputDevices[0].Flags = (int) flags;
            rawInputDevices[0].Target = target;

            // Register this device
            RawInputFunctions.RegisterRawInputDevices(rawInputDevices, 1, Utilities.SizeOf<RawInputDevice>());

            if (rawInputMessageFilter == null && addMessageFilter)
            {
                rawInputMessageFilter = new RawInputMessageFilter();
                MessageFilterHook.AddMessageFilter(target, rawInputMessageFilter);
            }
        }
Exemple #17
0
        /// <summary>
        /// Registers the devices that supply the raw input data.
        /// </summary>
        /// <param name="usagePage">The usage page.</param>
        /// <param name="usageId">The usage id.</param>
        /// <param name="flags">The flags.</param>
        /// <param name="target">The target.</param>
        /// <param name="addMessageFilter">if set to <c>true</c> register message filter to Application.AddMessageFilter.</param>
        public static void RegisterDevice(UsagePage usagePage, UsageId usageId, DeviceFlags flags, IntPtr target, bool addMessageFilter = true)
        {
            var rawInputDevices = new RawInputDevice[1];
            rawInputDevices[0].UsagePage = (short) usagePage;
            rawInputDevices[0].Usage = (short) usageId;
            rawInputDevices[0].Flags = (int) flags;
            rawInputDevices[0].Target = target;

            // Register this device
            RawInputFunctions.RegisterRawInputDevices(rawInputDevices, 1, Utilities.SizeOf<RawInputDevice>());

            if (rawInputMessageFilter == null && addMessageFilter)
            {
                rawInputMessageFilter = new RawInputMessageFilter();
                Application.AddMessageFilter(rawInputMessageFilter);
            }
        }
Exemple #18
0
 public static extern IntPtr oidnNewDevice(DeviceFlags flags);
Exemple #19
0
 public static extern Device Create(string deviceName, DeviceFlags flags);