# HG changeset patch
# User StephaneLenclud
# Date 1424028526 -3600
# Node ID bc92e26482203a59e01d3ca62a5023295a9d55dd
# Parent  60bfe508372135d2da2c7f5ff486c24e1845e6e7
Device list now showing usage collection string.
diff -r 60bfe5083721 -r bc92e2648220 HidUtils.cs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HidUtils.cs	Sun Feb 15 20:28:46 2015 +0100
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Hid
+{
+    static class Utils
+    {
+        /// 
+        /// Provide the type for the usage collection corresponding to the given usage page.
+        /// 
+        /// 
+        /// 
+        public static Type UsageCollectionType(UsagePage aUsagePage)
+        {
+            switch (aUsagePage)
+            {
+                case UsagePage.GenericDesktopControls:
+                    return typeof(UsageCollectionGenericDesktop);
+
+                case UsagePage.Consumer:
+                    return typeof(UsageCollectionConsumer);
+
+                case UsagePage.WindowsMediaCenterRemoteControl:
+                    return typeof(UsageCollectionWindowsMediaCenter);
+
+                default:
+                    return null;
+            }
+        }
+    }
+}
diff -r 60bfe5083721 -r bc92e2648220 RawInput.cs
--- a/RawInput.cs	Sun Feb 15 19:53:27 2015 +0100
+++ b/RawInput.cs	Sun Feb 15 20:28:46 2015 +0100
@@ -183,6 +183,7 @@
                 //Work out proper suffix for our device root node.
                 //That allows users to see in a glance what kind of device this is.
                 string suffix = "";
+                Type usageCollectionType=null; 
                 if (hidDevice.Info.dwType == RawInputDeviceType.RIM_TYPEHID)
                 {
                     //Process usage page
@@ -191,6 +192,7 @@
                         //We know this usage page, add its name
                         Hid.UsagePage usagePage = (Hid.UsagePage)hidDevice.Info.hid.usUsagePage;
                         suffix += " ( " + usagePage.ToString() + ", ";
+                        usageCollectionType = Hid.Utils.UsageCollectionType(usagePage);
                     }
                     else
                     {
@@ -198,9 +200,18 @@
                         suffix += " ( 0x" + hidDevice.Info.hid.usUsagePage.ToString("X4") + ", ";
                     }
 
-                    //Process usage
+                    //Process usage collection
                     //We don't know this usage page, add its value
-                    suffix += "0x" + hidDevice.Info.hid.usUsage.ToString("X4") + " )";
+                    if (usageCollectionType == null || !Enum.IsDefined(usageCollectionType, hidDevice.Info.hid.usUsage))
+                    {
+                        //Show Hexa
+                        suffix += "0x" + hidDevice.Info.hid.usUsage.ToString("X4") + " )";
+                    }
+                    else
+                    {
+                        //We know this usage page, add its name
+                        suffix += Enum.GetName(usageCollectionType, hidDevice.Info.hid.usUsage) + " )";                        
+                    }
                 }
                 else if (hidDevice.Info.dwType == RawInputDeviceType.RIM_TYPEKEYBOARD)
                 {
diff -r 60bfe5083721 -r bc92e2648220 RemoteControlSample.csproj
--- a/RemoteControlSample.csproj	Sun Feb 15 19:53:27 2015 +0100
+++ b/RemoteControlSample.csproj	Sun Feb 15 20:28:46 2015 +0100
@@ -128,6 +128,7 @@
     
     
     
+    
     
       Form