# HG changeset patch # User StephaneLenclud # Date 1424037458 -3600 # Node ID 09f1435bfb9472f420c67dcb6327752e3e3e4523 # Parent 8c2380995bb7650bbf14d9bbadbd1bc5f1972c9e Device list now displaying input value description, those are basically your gamepad axis. Adding collapse and expand buttons. diff -r 8c2380995bb7 -r 09f1435bfb94 HidDevice.cs --- a/HidDevice.cs Sun Feb 15 22:13:33 2015 +0100 +++ b/HidDevice.cs Sun Feb 15 22:57:38 2015 +0100 @@ -47,9 +47,6 @@ public HIDP_VALUE_CAPS[] InputValueCapabilities { get { return iInputValueCapabilities; } } private HIDP_VALUE_CAPS[] iInputValueCapabilities; - - - /// /// Class constructor will fetch this object properties from HID sub system. /// @@ -265,6 +262,30 @@ } /// + /// + /// + /// + /// + public string InputValueCapabilityDescription(HIDP_VALUE_CAPS aCaps) + { + if (!aCaps.IsRange && Enum.IsDefined(typeof(UsagePage), Capabilities.UsagePage)) + { + return "Input Value: " + Enum.GetName(Utils.UsageType((UsagePage)Capabilities.UsagePage), aCaps.NotRange.Usage); + } + + return null; + } + + public bool IsGamePad + { + get + { + return ((UsagePage)iCapabilities.UsagePage == UsagePage.GenericDesktopControls && (UsageCollectionGenericDesktop)iCapabilities.Usage == UsageCollectionGenericDesktop.GamePad); + } + } + + + /// /// Print information about this device to our debug output. /// public void DebugWrite() diff -r 8c2380995bb7 -r 09f1435bfb94 HidUtils.cs --- a/HidUtils.cs Sun Feb 15 22:13:33 2015 +0100 +++ b/HidUtils.cs Sun Feb 15 22:57:38 2015 +0100 @@ -28,5 +28,38 @@ return null; } } + + /// + /// Provide the type for the usage corresponding to the given usage page. + /// + /// + /// + public static Type UsageType(UsagePage aUsagePage) + { + switch (aUsagePage) + { + case UsagePage.GenericDesktopControls: + return typeof(UsageTables.GenericDesktop); + + case UsagePage.Consumer: + return typeof(UsageTables.ConsumerControl); + + case UsagePage.WindowsMediaCenterRemoteControl: + return typeof(UsageTables.WindowsMediaCenterRemoteControl); + + case UsagePage.Telephony: + return typeof(UsageTables.TelephonyDevice); + + case UsagePage.SimulationControls: + return typeof(UsageTables.SimulationControl); + + case UsagePage.GameControls: + return typeof(UsageTables.GameControl); + + default: + return null; + } + } + } } diff -r 8c2380995bb7 -r 09f1435bfb94 MainForm.Designer.cs --- a/MainForm.Designer.cs Sun Feb 15 22:13:33 2015 +0100 +++ b/MainForm.Designer.cs Sun Feb 15 22:57:38 2015 +0100 @@ -27,6 +27,8 @@ this.columnHeaderTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.tabPageDevices = new System.Windows.Forms.TabPage(); this.treeViewDevices = new System.Windows.Forms.TreeView(); + this.buttonTreeViewCollapseAll = new System.Windows.Forms.Button(); + this.buttonTreeViewExpandAll = new System.Windows.Forms.Button(); this.tabControl.SuspendLayout(); this.tabPageMessages.SuspendLayout(); this.tabPageDevices.SuspendLayout(); @@ -139,11 +141,13 @@ // // tabPageDevices // + this.tabPageDevices.Controls.Add(this.buttonTreeViewExpandAll); + this.tabPageDevices.Controls.Add(this.buttonTreeViewCollapseAll); this.tabPageDevices.Controls.Add(this.treeViewDevices); this.tabPageDevices.Location = new System.Drawing.Point(4, 22); this.tabPageDevices.Name = "tabPageDevices"; this.tabPageDevices.Padding = new System.Windows.Forms.Padding(3); - this.tabPageDevices.Size = new System.Drawing.Size(918, 512); + this.tabPageDevices.Size = new System.Drawing.Size(894, 488); this.tabPageDevices.TabIndex = 1; this.tabPageDevices.Text = "Devices"; this.tabPageDevices.UseVisualStyleBackColor = true; @@ -154,9 +158,29 @@ | System.Windows.Forms.AnchorStyles.Left))); this.treeViewDevices.Location = new System.Drawing.Point(8, 6); this.treeViewDevices.Name = "treeViewDevices"; - this.treeViewDevices.Size = new System.Drawing.Size(713, 498); + this.treeViewDevices.Size = new System.Drawing.Size(713, 474); this.treeViewDevices.TabIndex = 0; // + // buttonTreeViewCollapseAll + // + this.buttonTreeViewCollapseAll.Location = new System.Drawing.Point(813, 35); + this.buttonTreeViewCollapseAll.Name = "buttonTreeViewCollapseAll"; + this.buttonTreeViewCollapseAll.Size = new System.Drawing.Size(75, 23); + this.buttonTreeViewCollapseAll.TabIndex = 1; + this.buttonTreeViewCollapseAll.Text = "Collapse All"; + this.buttonTreeViewCollapseAll.UseVisualStyleBackColor = true; + this.buttonTreeViewCollapseAll.Click += new System.EventHandler(this.buttonTreeViewCollapseAll_Click); + // + // buttonTreeViewExpandAll + // + this.buttonTreeViewExpandAll.Location = new System.Drawing.Point(813, 6); + this.buttonTreeViewExpandAll.Name = "buttonTreeViewExpandAll"; + this.buttonTreeViewExpandAll.Size = new System.Drawing.Size(75, 23); + this.buttonTreeViewExpandAll.TabIndex = 2; + this.buttonTreeViewExpandAll.Text = "Expand All"; + this.buttonTreeViewExpandAll.UseVisualStyleBackColor = true; + this.buttonTreeViewExpandAll.Click += new System.EventHandler(this.buttonTreeViewExpandAll_Click); + // // MainForm // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); @@ -175,5 +199,8 @@ } #endregion Windows Form Designer generated code + private System.Windows.Forms.Button buttonTreeViewExpandAll; + private System.Windows.Forms.Button buttonTreeViewCollapseAll; + } } diff -r 8c2380995bb7 -r 09f1435bfb94 MainForm.cs --- a/MainForm.cs Sun Feb 15 22:13:33 2015 +0100 +++ b/MainForm.cs Sun Feb 15 22:57:38 2015 +0100 @@ -166,5 +166,15 @@ listViewEvents.Items.Clear(); } + private void buttonTreeViewCollapseAll_Click(object sender, EventArgs e) + { + treeViewDevices.CollapseAll(); + } + + private void buttonTreeViewExpandAll_Click(object sender, EventArgs e) + { + treeViewDevices.ExpandAll(); + } + } } diff -r 8c2380995bb7 -r 09f1435bfb94 RawInput.cs --- a/RawInput.cs Sun Feb 15 22:13:33 2015 +0100 +++ b/RawInput.cs Sun Feb 15 22:57:38 2015 +0100 @@ -206,7 +206,20 @@ { node.Nodes.Add(hidDevice.InputCapabilitiesDescription); } - + + if (hidDevice.InputValueCapabilities != null) + { + foreach (HIDP_VALUE_CAPS caps in hidDevice.InputValueCapabilities) + { + string des = hidDevice.InputValueCapabilityDescription(caps); + if (des != null) + { + node.Nodes.Add(des); + } + } + + } + node.Nodes.Add(hidDevice.Name); } }