RawInput.cs
changeset 19 d066e3999973
parent 17 8f7e35c3bfd1
child 22 8b2a3da54187
     1.1 --- a/RawInput.cs	Fri Dec 05 23:18:13 2014 +0100
     1.2 +++ b/RawInput.cs	Sat Dec 06 00:59:59 2014 +0100
     1.3 @@ -94,7 +94,7 @@
     1.4          }
     1.5  
     1.6          /// <summary>
     1.7 -        /// 
     1.8 +        /// Fetch pre-parsed data corresponding to HID descriptor for the given HID device.
     1.9          /// </summary>
    1.10          /// <param name="device"></param>
    1.11          /// <returns></returns>
    1.12 @@ -118,120 +118,6 @@
    1.13              return ppData;
    1.14          }
    1.15  
    1.16 -        /// <summary>
    1.17 -        /// 
    1.18 -        /// </summary>
    1.19 -        /// <param name="driver"></param>
    1.20 -        /// <param name="device"></param>
    1.21 -        /// <param name="input"></param>
    1.22 -        /// <param name="rawInput"></param>
    1.23 -        /// <param name="usageType"></param>
    1.24 -        /// <param name="usage"></param>
    1.25 -        /// <param name="usageName"></param>
    1.26 -        /// <returns></returns>
    1.27 -        /// 
    1.28 -        /*
    1.29 -        private bool GetUsageFromRawInput(TwinhanHidDriver driver, TwinhanHid device, NativeMethods.RAWINPUT input, IntPtr rawInput, out UsageType usageType, out int usage, out string usageName)
    1.30 -        {
    1.31 -            usageType = 0;
    1.32 -            usage = 0;
    1.33 -            usageName = string.Empty;
    1.34 -            if (input.header.dwType == NativeMethods.RawInputDeviceType.RIM_TYPEKEYBOARD)
    1.35 -            {
    1.36 -                if (input.data.keyboard.Flags == NativeMethods.RawInputKeyboardFlag.RI_KEY_BREAK)
    1.37 -                {
    1.38 -                    _modifiers = 0;
    1.39 -                    // Key up event. We don't handle repeats, so ignore this.
    1.40 -                    return false;
    1.41 -                }
    1.42 -                NativeMethods.VirtualKey vk = input.data.keyboard.VKey;
    1.43 -                if (vk == NativeMethods.VirtualKey.VK_CONTROL)
    1.44 -                {
    1.45 -                    _modifiers |= VirtualKeyModifier.Control;
    1.46 -                    return false;
    1.47 -                }
    1.48 -                if (vk == NativeMethods.VirtualKey.VK_SHIFT)
    1.49 -                {
    1.50 -                    _modifiers |= VirtualKeyModifier.Shift;
    1.51 -                    return false;
    1.52 -                }
    1.53 -                if (vk == NativeMethods.VirtualKey.VK_MENU)
    1.54 -                {
    1.55 -                    _modifiers |= VirtualKeyModifier.Alt;
    1.56 -                    return false;
    1.57 -                }
    1.58 -                usageType = UsageType.Keyboard;
    1.59 -                usage = (int)vk | (int)_modifiers;
    1.60 -                usageName = vk.ToString();
    1.61 -                if (_modifiers != 0)
    1.62 -                {
    1.63 -                    usageName += string.Format(", modifiers = {0}", _modifiers);
    1.64 -                }
    1.65 -            }
    1.66 -            else if (input.header.dwType == NativeMethods.RawInputDeviceType.RIM_TYPEHID)
    1.67 -            {
    1.68 -                if ((!driver.IsTerraTec && device.Name.Contains("Col03")) || (driver.IsTerraTec && device.Name.Contains("Col02")))
    1.69 -                {
    1.70 -                    usageType = UsageType.Raw;
    1.71 -                    usage = Marshal.ReadByte(rawInput, HID_INPUT_DATA_OFFSET + 1);
    1.72 -                    usageName = string.Format("0x{0:x2}", usage);
    1.73 -                }
    1.74 -                else if (device.Name.Contains("Col05"))
    1.75 -                {
    1.76 -                    usageType = UsageType.Ascii;
    1.77 -                    usage = Marshal.ReadByte(rawInput, HID_INPUT_DATA_OFFSET + 1);
    1.78 -                    usageName = string.Format("0x{0:x2}", usage);
    1.79 -                }
    1.80 -                else
    1.81 -                {
    1.82 -                    byte[] report = new byte[input.data.hid.dwSizeHid];
    1.83 -                    Marshal.Copy(IntPtr.Add(rawInput, HID_INPUT_DATA_OFFSET), report, 0, report.Length);
    1.84 -                    uint usageCount = input.data.hid.dwCount;
    1.85 -                    NativeMethods.USAGE_AND_PAGE[] usages = new NativeMethods.USAGE_AND_PAGE[usageCount];
    1.86 -                    NativeMethods.HidStatus status = NativeMethods.HidP_GetUsagesEx(NativeMethods.HIDP_REPORT_TYPE.HidP_Input, 0, usages, ref usageCount, device.PreParsedData, report, (uint)report.Length);
    1.87 -                    if (status != NativeMethods.HidStatus.HIDP_STATUS_SUCCESS)
    1.88 -                    {
    1.89 -                        this.LogError("Twinhan HID remote: failed to get raw input HID usages, device = {0}, status = {1}", device.Name, status);
    1.90 -                        Dump.DumpBinary(rawInput, (int)input.header.dwSize);
    1.91 -                        return false;
    1.92 -                    }
    1.93 -                    if (usageCount > 1)
    1.94 -                    {
    1.95 -                        this.LogWarn("Twinhan HID remote: multiple simultaneous HID usages not supported");
    1.96 -                    }
    1.97 -                    NativeMethods.USAGE_AND_PAGE up = usages[0];
    1.98 -                    HidUsagePage page = (HidUsagePage)up.UsagePage;
    1.99 -                    usage = up.Usage;
   1.100 -                    if (page != HidUsagePage.MceRemote && usage == 0)
   1.101 -                    {
   1.102 -                        // Key up event. We don't handle repeats, so ignore this.
   1.103 -                        return false;
   1.104 -                    }
   1.105 -                    if (page == HidUsagePage.Consumer)
   1.106 -                    {
   1.107 -                        usageType = UsageType.Consumer;
   1.108 -                        usageName = Enum.GetName(typeof(HidConsumerUsage), up.Usage);
   1.109 -                    }
   1.110 -                    else if (page == HidUsagePage.MceRemote)
   1.111 -                    {
   1.112 -                        usageType = UsageType.Mce;
   1.113 -                        usageName = Enum.GetName(typeof(MceRemoteUsage), up.Usage);
   1.114 -                    }
   1.115 -                    else
   1.116 -                    {
   1.117 -                        this.LogError("Twinhan HID remote: unexpected usage page, device = {0}, page = {1}, usage = {2}", device.Name, page, up.Usage);
   1.118 -                        return false;
   1.119 -                    }
   1.120 -                }
   1.121 -            }
   1.122 -            else
   1.123 -            {
   1.124 -                this.LogError("Twinhan HID remote: received input from unsupported input device type, device = {0}, type = {1}", device.Name, input.header.dwType);
   1.125 -                return false;
   1.126 -            }
   1.127 -            return true;
   1.128 -        }
   1.129 -         * */
   1.130  
   1.131      }
   1.132  }
   1.133 \ No newline at end of file