Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MouseInfo"/> class.
 /// </summary>
 /// <param name="rawDeviceInfo">The raw device info.</param>
 /// <param name="deviceName">Name of the device.</param>
 /// <param name="deviceHandle">The device handle.</param>
 internal MouseInfo(ref RawDeviceInformation rawDeviceInfo, string deviceName, IntPtr deviceHandle) : base(ref rawDeviceInfo, deviceName, deviceHandle)
 {
     Id                 = rawDeviceInfo.Mouse.Id;
     ButtonCount        = rawDeviceInfo.Mouse.NumberOfButtons;
     SampleRate         = rawDeviceInfo.Mouse.SampleRate;
     HasHorizontalWheel = rawDeviceInfo.Mouse.HasHorizontalWheel;
 }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HidInfo"/> class.
 /// </summary>
 /// <param name="rawDeviceInfo">The raw device info.</param>
 /// <param name="deviceName">Name of the device.</param>
 /// <param name="deviceHandle">The device handle.</param>
 internal HidInfo(ref RawDeviceInformation rawDeviceInfo, string deviceName, IntPtr deviceHandle) : base(ref rawDeviceInfo, deviceName, deviceHandle)
 {
     VendorId      = rawDeviceInfo.Hid.VendorId;
     ProductId     = rawDeviceInfo.Hid.ProductId;
     VersionNumber = rawDeviceInfo.Hid.VersionNumber;
     UsagePage     = rawDeviceInfo.Hid.UsagePage;
     Usage         = rawDeviceInfo.Hid.Usage;
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="KeyboardInfo"/> class.
 /// </summary>
 /// <param name="rawDeviceInfo">The raw device info.</param>
 /// <param name="deviceName">Name of the device.</param>
 /// <param name="deviceHandle">The device handle.</param>
 internal KeyboardInfo(ref RawDeviceInformation rawDeviceInfo, string deviceName, IntPtr deviceHandle) : base(ref rawDeviceInfo, deviceName, deviceHandle)
 {
     KeyboardType     = rawDeviceInfo.Keyboard.Type;
     Subtype          = rawDeviceInfo.Keyboard.SubType;
     KeyboardMode     = rawDeviceInfo.Keyboard.KeyboardMode;
     FunctionKeyCount = rawDeviceInfo.Keyboard.NumberOfFunctionKeys;
     IndicatorCount   = rawDeviceInfo.Keyboard.NumberOfIndicators;
     TotalKeyCount    = rawDeviceInfo.Keyboard.NumberOfKeysTotal;
 }
Пример #4
0
        /// <summary>
        /// Converts the specified raw device info to the <see cref="DeviceInfo"/>.
        /// </summary>
        /// <param name="rawDeviceInfo">The raw device info.</param>
        /// <param name="deviceName">Name of the device.</param>
        /// <param name="deviceHandle">The device handle.</param>
        /// <returns></returns>
        internal static DeviceInfo Convert(ref RawDeviceInformation rawDeviceInfo, string deviceName, IntPtr deviceHandle)
        {
            DeviceInfo deviceInfo = null;

            switch (rawDeviceInfo.Type)
            {
            case DeviceType.HumanInputDevice:
                deviceInfo = new HidInfo(ref rawDeviceInfo, deviceName, deviceHandle);
                break;

            case DeviceType.Keyboard:
                deviceInfo = new KeyboardInfo(ref rawDeviceInfo, deviceName, deviceHandle);
                break;

            case DeviceType.Mouse:
                deviceInfo = new MouseInfo(ref rawDeviceInfo, deviceName, deviceHandle);
                break;

            default:
                throw new InvalidOperationException(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Unsupported Device Type [{0}]", (int)rawDeviceInfo.Type));
            }
            return(deviceInfo);
        }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DeviceInfo"/> class.
 /// </summary>
 /// <param name="rawDeviceInfo">The raw device info.</param>
 /// <param name="deviceName">Name of the device.</param>
 /// <param name="deviceHandle">The device handle.</param>
 internal DeviceInfo(ref RawDeviceInformation rawDeviceInfo, string deviceName, IntPtr deviceHandle)
 {
     DeviceName = deviceName;
     Handle     = deviceHandle;
     DeviceType = rawDeviceInfo.Type;
 }