# HG changeset patch # User sl # Date 1417827235 -3600 # Node ID fb4f80d5cf579ffa5c419662de544e5942868690 # Parent f2b65a8318e976427c3ccca7b7a3fd26fb8feb3e Proper UsageId definitions. diff -r f2b65a8318e9 -r fb4f80d5cf57 HumanInterfaceDevice.cs --- a/HumanInterfaceDevice.cs Sat Dec 06 01:09:32 2014 +0100 +++ b/HumanInterfaceDevice.cs Sat Dec 06 01:53:55 2014 +0100 @@ -48,13 +48,34 @@ TerraTecRemote = 0xffcc } - /// -/// -/// - public enum UsageId: ushort + public enum UsageIdGenericDesktop : ushort + { + Pointer = 0x01, + Mouse = 0x02, + Joystick = 0x04, + GamePad = 0x05, + Keyboard = 0x06, + KeyPad = 0x07, + MultiAxisController = 0x08, + TabletPCSystemControls = 0x09, + SystemControl = 0x80 + } + + public enum UsageIdConsumer : ushort { - MceRemoteUsage = 0x88, - ConsumerControl = 0x01 + ConsumerControl = 0x01, + NumericKeyPad = 0x02, + ProgrammableButtons = 0x03, + Microphone = 0x04, + Headphone = 0x05, + GraphicEqualizer = 0x06, + Selection = 0x80, + } + + + public enum UsageIdMce: ushort + { + MceRemote = 0x88 } diff -r f2b65a8318e9 -r fb4f80d5cf57 RemoteControlDevice.cs --- a/RemoteControlDevice.cs Sat Dec 06 01:09:32 2014 +0100 +++ b/RemoteControlDevice.cs Sat Dec 06 01:53:55 2014 +0100 @@ -174,20 +174,42 @@ RAWINPUTDEVICE[] rid = new RAWINPUTDEVICE[3]; - rid[0].usUsagePage = 0xFFBC; - rid[0].usUsage = 0x88; - rid[0].dwFlags = Const.RIDEV_EXINPUTSINK; - rid[0].hwndTarget = aHWND; + int i = 0; + rid[i].usUsagePage = (ushort)Hid.UsagePage.MceRemote; + rid[i].usUsage = (ushort)Hid.UsageIdMce.MceRemote; + rid[i].dwFlags = Const.RIDEV_EXINPUTSINK; + rid[i].hwndTarget = aHWND; - rid[1].usUsagePage = 0x0C; - rid[1].usUsage = 0x01; - rid[1].dwFlags = Const.RIDEV_EXINPUTSINK; - rid[1].hwndTarget = aHWND; + i++; + rid[i].usUsagePage = (ushort)Hid.UsagePage.Consumer; + rid[i].usUsage = (ushort)Hid.UsageIdConsumer.ConsumerControl; + rid[i].dwFlags = Const.RIDEV_EXINPUTSINK; + rid[i].hwndTarget = aHWND; - rid[2].usUsagePage = 0x0C; - rid[2].usUsage = 0x80; - rid[2].dwFlags = Const.RIDEV_EXINPUTSINK; - rid[2].hwndTarget = aHWND; + i++; + rid[i].usUsagePage = (ushort)Hid.UsagePage.Consumer; + rid[i].usUsage = (ushort)Hid.UsageIdConsumer.Selection; + rid[i].dwFlags = Const.RIDEV_EXINPUTSINK; + rid[i].hwndTarget = aHWND; + + //i++; + //rid[i].usUsagePage = (ushort)Hid.UsagePage.GenericDesktopControl; + //rid[i].usUsage = (ushort)Hid.UsageIdGenericDesktop.SystemControl; + //rid[i].dwFlags = Const.RIDEV_EXINPUTSINK; + //rid[i].hwndTarget = aHWND; + + //i++; + //rid[i].usUsagePage = (ushort)Hid.UsagePage.GenericDesktopControl; + //rid[i].usUsage = (ushort)Hid.UsageIdGenericDesktop.Keyboard; + //rid[i].dwFlags = Const.RIDEV_EXINPUTSINK; + //rid[i].hwndTarget = aHWND; + + //i++; + //rid[i].usUsagePage = (ushort)Hid.UsagePage.GenericDesktopControl; + //rid[i].usUsage = (ushort)Hid.UsageIdGenericDesktop.Mouse; + //rid[i].dwFlags = Const.RIDEV_EXINPUTSINK; + //rid[i].hwndTarget = aHWND; + if (!Function.RegisterRawInputDevices(rid,(uint) rid.Length,(uint) Marshal.SizeOf(rid[0]))) { @@ -388,12 +410,12 @@ HidUsageHandler usagePageHandler=null; //Check if this an MCE remote HID message - if (deviceInfo.hid.usUsagePage == (ushort)Hid.UsagePage.MceRemote && deviceInfo.hid.usUsage == (ushort)Hid.UsageId.MceRemoteUsage) + if (deviceInfo.hid.usUsagePage == (ushort)Hid.UsagePage.MceRemote && deviceInfo.hid.usUsage == (ushort)Hid.UsageIdMce.MceRemote) { usagePageHandler = HidMceRemoteHandler; } //Check if this is a consumer control HID message - else if (deviceInfo.hid.usUsagePage == (ushort)Hid.UsagePage.Consumer && deviceInfo.hid.usUsage == (ushort)Hid.UsageId.ConsumerControl) + else if (deviceInfo.hid.usUsagePage == (ushort)Hid.UsagePage.Consumer && deviceInfo.hid.usUsage == (ushort)Hid.UsageIdConsumer.ConsumerControl) { usagePageHandler = HidConsumerDeviceHandler; }