Proper UsageId definitions.
authorsl
Sat, 06 Dec 2014 01:53:55 +0100
changeset 21fb4f80d5cf57
parent 20 f2b65a8318e9
child 22 8b2a3da54187
Proper UsageId definitions.
HumanInterfaceDevice.cs
RemoteControlDevice.cs
     1.1 --- a/HumanInterfaceDevice.cs	Sat Dec 06 01:09:32 2014 +0100
     1.2 +++ b/HumanInterfaceDevice.cs	Sat Dec 06 01:53:55 2014 +0100
     1.3 @@ -48,13 +48,34 @@
     1.4          TerraTecRemote = 0xffcc
     1.5      }
     1.6  
     1.7 -    /// <summary>
     1.8 -/// 
     1.9 -/// </summary>
    1.10 -    public enum UsageId: ushort
    1.11 +    public enum UsageIdGenericDesktop : ushort
    1.12 +    {      
    1.13 +        Pointer = 0x01,
    1.14 +        Mouse = 0x02,
    1.15 +        Joystick = 0x04,
    1.16 +        GamePad = 0x05,
    1.17 +        Keyboard = 0x06,
    1.18 +        KeyPad = 0x07,
    1.19 +        MultiAxisController = 0x08,
    1.20 +        TabletPCSystemControls = 0x09,
    1.21 +        SystemControl = 0x80
    1.22 +    }
    1.23 +
    1.24 +    public enum UsageIdConsumer : ushort
    1.25      {
    1.26 -        MceRemoteUsage = 0x88,
    1.27 -        ConsumerControl = 0x01
    1.28 +        ConsumerControl = 0x01,
    1.29 +        NumericKeyPad = 0x02,
    1.30 +        ProgrammableButtons = 0x03,
    1.31 +        Microphone = 0x04,
    1.32 +        Headphone = 0x05,
    1.33 +        GraphicEqualizer = 0x06,
    1.34 +        Selection = 0x80,
    1.35 +    }
    1.36 +
    1.37 +    
    1.38 +    public enum UsageIdMce: ushort
    1.39 +    {
    1.40 +        MceRemote = 0x88        
    1.41      }
    1.42  
    1.43  
     2.1 --- a/RemoteControlDevice.cs	Sat Dec 06 01:09:32 2014 +0100
     2.2 +++ b/RemoteControlDevice.cs	Sat Dec 06 01:53:55 2014 +0100
     2.3 @@ -174,20 +174,42 @@
     2.4  
     2.5  			RAWINPUTDEVICE[] rid = new RAWINPUTDEVICE[3];
     2.6  
     2.7 -			rid[0].usUsagePage = 0xFFBC;
     2.8 -			rid[0].usUsage = 0x88;
     2.9 -            rid[0].dwFlags = Const.RIDEV_EXINPUTSINK;
    2.10 -            rid[0].hwndTarget = aHWND;
    2.11 +            int i = 0;
    2.12 +			rid[i].usUsagePage = (ushort)Hid.UsagePage.MceRemote;
    2.13 +            rid[i].usUsage = (ushort)Hid.UsageIdMce.MceRemote;
    2.14 +            rid[i].dwFlags = Const.RIDEV_EXINPUTSINK;
    2.15 +            rid[i].hwndTarget = aHWND;
    2.16  
    2.17 -			rid[1].usUsagePage = 0x0C;
    2.18 -			rid[1].usUsage = 0x01;
    2.19 -            rid[1].dwFlags = Const.RIDEV_EXINPUTSINK;
    2.20 -            rid[1].hwndTarget = aHWND;
    2.21 +            i++;
    2.22 +            rid[i].usUsagePage = (ushort)Hid.UsagePage.Consumer;
    2.23 +            rid[i].usUsage = (ushort)Hid.UsageIdConsumer.ConsumerControl;
    2.24 +            rid[i].dwFlags = Const.RIDEV_EXINPUTSINK;
    2.25 +            rid[i].hwndTarget = aHWND;
    2.26  
    2.27 -			rid[2].usUsagePage = 0x0C;
    2.28 -			rid[2].usUsage = 0x80;
    2.29 -            rid[2].dwFlags = Const.RIDEV_EXINPUTSINK;
    2.30 -            rid[2].hwndTarget = aHWND;
    2.31 +            i++;
    2.32 +            rid[i].usUsagePage = (ushort)Hid.UsagePage.Consumer;
    2.33 +            rid[i].usUsage = (ushort)Hid.UsageIdConsumer.Selection;
    2.34 +            rid[i].dwFlags = Const.RIDEV_EXINPUTSINK;
    2.35 +            rid[i].hwndTarget = aHWND;
    2.36 +
    2.37 +            //i++;
    2.38 +            //rid[i].usUsagePage = (ushort)Hid.UsagePage.GenericDesktopControl;
    2.39 +            //rid[i].usUsage = (ushort)Hid.UsageIdGenericDesktop.SystemControl;
    2.40 +            //rid[i].dwFlags = Const.RIDEV_EXINPUTSINK;
    2.41 +            //rid[i].hwndTarget = aHWND;
    2.42 +
    2.43 +            //i++;
    2.44 +            //rid[i].usUsagePage = (ushort)Hid.UsagePage.GenericDesktopControl;
    2.45 +            //rid[i].usUsage = (ushort)Hid.UsageIdGenericDesktop.Keyboard;
    2.46 +            //rid[i].dwFlags = Const.RIDEV_EXINPUTSINK;
    2.47 +            //rid[i].hwndTarget = aHWND;
    2.48 +
    2.49 +            //i++;
    2.50 +            //rid[i].usUsagePage = (ushort)Hid.UsagePage.GenericDesktopControl;
    2.51 +            //rid[i].usUsage = (ushort)Hid.UsageIdGenericDesktop.Mouse;
    2.52 +            //rid[i].dwFlags = Const.RIDEV_EXINPUTSINK;
    2.53 +            //rid[i].hwndTarget = aHWND;
    2.54 +
    2.55  
    2.56  			if (!Function.RegisterRawInputDevices(rid,(uint) rid.Length,(uint) Marshal.SizeOf(rid[0])))
    2.57  			{
    2.58 @@ -388,12 +410,12 @@
    2.59                      HidUsageHandler usagePageHandler=null;
    2.60  
    2.61                      //Check if this an MCE remote HID message
    2.62 -                    if (deviceInfo.hid.usUsagePage == (ushort)Hid.UsagePage.MceRemote && deviceInfo.hid.usUsage == (ushort)Hid.UsageId.MceRemoteUsage)
    2.63 +                    if (deviceInfo.hid.usUsagePage == (ushort)Hid.UsagePage.MceRemote && deviceInfo.hid.usUsage == (ushort)Hid.UsageIdMce.MceRemote)
    2.64                      {                        
    2.65                          usagePageHandler = HidMceRemoteHandler;
    2.66                      }
    2.67                      //Check if this is a consumer control HID message
    2.68 -                    else if (deviceInfo.hid.usUsagePage == (ushort)Hid.UsagePage.Consumer && deviceInfo.hid.usUsage == (ushort)Hid.UsageId.ConsumerControl)
    2.69 +                    else if (deviceInfo.hid.usUsagePage == (ushort)Hid.UsagePage.Consumer && deviceInfo.hid.usUsage == (ushort)Hid.UsageIdConsumer.ConsumerControl)
    2.70                      {
    2.71                          usagePageHandler = HidConsumerDeviceHandler;
    2.72                      }