コード例 #1
0
            public static int FindOrAddReport(int?reportId, HID.HIDReportType reportType, List <HIDReportData> reports)
            {
                var id = 1;

                if (reportId.HasValue)
                {
                    id = reportId.Value;
                }

                for (var i = 0; i < reports.Count; ++i)
                {
                    if (reports[i].reportId == id && reports[i].reportType == reportType)
                    {
                        return(i);
                    }
                }

                reports.Add(new HIDReportData
                {
                    reportId   = id,
                    reportType = reportType
                });

                return(reports.Count - 1);
            }
コード例 #2
0
            private TreeViewItem BuildElementItem(int index, TreeViewItem parent, HID.HIDElementDescriptor element, ref int id, ref int runningBitOffset, ref HID.HIDReportType currentReportType)
            {
                var item = AddChild(parent, string.Format("Element {0} ({1})", index, element.reportType), ref id);

                AddChild(item, string.Format("Usage Page: 0x{0:X} ({1})", (uint)element.usagePage, element.usagePage), ref id);
                AddChild(item, string.Format("Usage: 0x{0:X}", element.usage), ref id);
                AddChild(item, "Report Type: " + element.reportType, ref id);
                AddChild(item, "Report ID: " + element.reportId, ref id);
                AddChild(item, "Report Size in Bits: " + element.reportSizeInBits, ref id);
                AddChild(item, "Report Count: " + element.reportCount, ref id);
                AddChild(item, "Collection Index: " + element.collectionIndex, ref id);
                AddChild(item, string.Format("Unit: {0:X}", element.unit), ref id);
                AddChild(item, string.Format("Unit Exponent: {0:X}", element.unitExponent), ref id);
                AddChild(item, "Logical Min: " + element.logicalMin, ref id);
                AddChild(item, "Logical Max: " + element.logicalMax, ref id);
                AddChild(item, "Physical Min: " + element.physicalMin, ref id);
                AddChild(item, "Physical Max: " + element.physicalMax, ref id);
                AddChild(item, "Has Null State?: " + element.hasNullState, ref id);
                AddChild(item, "Has Preferred State?: " + element.hasPreferredState, ref id);
                AddChild(item, "Is Array?: " + element.isArray, ref id);
                AddChild(item, "Is Non-Linear?: " + element.isNonLinear, ref id);
                AddChild(item, "Is Relative?: " + element.isRelative, ref id);
                AddChild(item, "Is Virtual?: " + element.isVirtual, ref id);
                AddChild(item, "Is Wrapping?: " + element.isWrapping, ref id);

                if (currentReportType != element.reportType)
                {
                    currentReportType = element.reportType;
                    runningBitOffset  = 0;
                }

                AddChild(item,
                         string.Format("Inferred Offset: byte #{0}, bit #{1}", runningBitOffset / 8, runningBitOffset % 8),
                         ref id);

                runningBitOffset += element.reportSizeInBits;

                return(item);
            }
コード例 #3
0
            private TreeViewItem BuildElementItem(int index, TreeViewItem parent, HID.HIDElementDescriptor element, ref int id, ref HID.HIDReportType currentReportType)
            {
                var item = AddChild(parent, string.Format("Element {0} ({1})", index, element.reportType), ref id);

                string usagePageString;
                string usageString;

                HID.UsageToString(element.usagePage, element.usage, out usagePageString, out usageString);

                AddChild(item, string.Format("Usage Page: 0x{0:X} ({1})", (uint)element.usagePage, usagePageString), ref id);
                if (usageString != null)
                {
                    AddChild(item, string.Format("Usage: 0x{0:X} ({1})", element.usage, usageString), ref id);
                }
                else
                {
                    AddChild(item, string.Format("Usage: 0x{0:X}", element.usage), ref id);
                }

                AddChild(item, "Report Type: " + element.reportType, ref id);
                AddChild(item, "Report ID: " + element.reportId, ref id);
                AddChild(item, "Report Size in Bits: " + element.reportSizeInBits, ref id);
                AddChild(item, "Report Bit Offset: " + element.reportOffsetInBits, ref id);
                AddChild(item, "Collection Index: " + element.collectionIndex, ref id);
                AddChild(item, string.Format("Unit: {0:X}", element.unit), ref id);
                AddChild(item, string.Format("Unit Exponent: {0:X}", element.unitExponent), ref id);
                AddChild(item, "Logical Min: " + element.logicalMin, ref id);
                AddChild(item, "Logical Max: " + element.logicalMax, ref id);
                AddChild(item, "Physical Min: " + element.physicalMin, ref id);
                AddChild(item, "Physical Max: " + element.physicalMax, ref id);
                AddChild(item, "Has Null State?: " + element.hasNullState, ref id);
                AddChild(item, "Has Preferred State?: " + element.hasPreferredState, ref id);
                AddChild(item, "Is Array?: " + element.isArray, ref id);
                AddChild(item, "Is Non-Linear?: " + element.isNonLinear, ref id);
                AddChild(item, "Is Relative?: " + element.isRelative, ref id);
                AddChild(item, "Is Constant?: " + element.isConstant, ref id);
                AddChild(item, "Is Wrapping?: " + element.isWrapping, ref id);

                return(item);
            }