Switch solution to 2013.
Event repeat now a Handler option.
Handler now deregisters devices when disposed.
Adding Thinkpad custom usages.
2 // Copyright (C) 2014-2015 Stéphane Lenclud.
4 // This file is part of SharpLibHid.
6 // SharpDisplayManager is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
11 // SharpDisplayManager is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with SharpDisplayManager. If not, see <http://www.gnu.org/licenses/>.
20 namespace SharpLib.Hid
23 /// From USB HID usage tables.
24 /// http://www.usb.org/developers/hidpage#HID_Usage
25 /// http://www.usb.org/developers/hidpage/Hut1_12v2.pdf
27 public enum UsagePage : ushort
30 GenericDesktopControls,
32 VirtualRealityControls,
35 GenericDeviceControls,
43 PhysicalInterfaceDevice = 0x0f,
45 AlphaNumericDisplay = 0x14,
46 MedicalInstruments = 0x40,
55 BarCodeScanner = 0x8c,
61 // http://msdn.microsoft.com/en-us/library/windows/desktop/bb417079.aspx
62 WindowsMediaCenterRemoteControl = 0xffbc,
63 TerraTecRemote = 0xffcc
67 /// Usage Collections are special values from our Usage enumeration.
68 /// Thus they are also part of the corresponding Usage enumeration.
70 namespace UsageCollection
73 /// Usage Collection for usage page GenericDesktopControls.
75 public enum GenericDesktop : ushort
83 MultiAxisController = 0x08,
84 TabletPCSystemControls = 0x09,
89 /// Usage Collection for usage page Consumer.
91 public enum Consumer : ushort
93 ConsumerControl = 0x01,
95 ProgrammableButtons = 0x03,
98 GraphicEqualizer = 0x06,
99 FunctionButtons = 0x36,
101 MediaSelection = 0x0087,
103 PlaybackSpeed = 0x00F1,
105 SpeakerSystem = 0x0160,
106 ChannelLeft = 0x0161,
107 ChannelRight = 0x0162,
108 ChannelCenter = 0x0163,
109 ChannelFront = 0x0164,
110 ChannelCenterFront = 0x0165,
111 ChannelSide = 0x0166,
112 ChannelSurrond = 0x0167,
113 ChannelLowFrequencyEnhancement = 0x0168,
115 ChannelUnknown = 0x016A,
116 ApplicationLaunchButtons = 0x016A,
117 GenericGuiApplicationControls = 0x0200,
121 public enum WindowsMediaCenter : ushort
123 WindowsMediaCenterRemoteControl = 0x88
135 public enum WindowsMediaCenterRemoteControl : ushort
138 /// Not defined by the Microsoft specs.
142 ClosedCaptioning = 0x2B,
145 TeletextGreen = 0x5C,
146 TeletextYellow = 0x5D,
162 /// First press action: Ejects a DVD drive.
164 /// Second press action: Repeats first press action.
166 /// Notably issued by XBOX360 remote as defined in irplus - Remote Control - Android application.
171 /// First press action: Generates EXTn HID message in the Media Center Vendor Specific
172 /// Collection (page 0xFFBC, usage 0x88).
174 /// Second press action: Repeats message.
178 /// Notably sent by the 'Visualization' button of HP Windows Media Center Remote (TSGH-IR08).
180 /// According to HP specs it displays visual imagery that is synchronized to the sound of your music tracks.
184 /// First press action: Generates EXTn HID message in the Media Center Vendor Specific
185 /// Collection (page 0xFFBC, usage 0x88).
187 /// Second press action: Repeats message.
191 /// Notably sent by the 'Slide Show' button of HP Windows Media Center Remote (TSGH-IR08).
193 /// According to HP specs it plays a slide show of all the pictures on your hard disk drive.
197 /// First press action: Generates EXTn HID message in the Media Center Vendor Specific
198 /// Collection (page 0xFFBC, usage 0x88).
200 /// Second press action: Repeats message.
204 /// Notably sent by the 'Eject' button of HP Windows Media Center Remote (TSGH-IR08).
205 /// Also interpreted as 'Eject' action by SoundGraph iMON Manager in MCE mode (OrigenAE VF310).
209 /// First press action: Generates EXTn HID message in the Media Center Vendor Specific
210 /// Collection (page 0xFFBC, usage 0x88).
212 /// Second press action: Repeats message.
216 /// Notably sent by the 'Input selection' button of HP Windows Media Center Remote (TSGH-IR08).
234 /// First press action: Generates OEM2 HID message in the Media Center Vendor Specific
235 /// Collection. This button is intended to control the front panel display of home entertainment
236 /// computers. When this button is pressed, the display could be turned on or off, or the display
237 /// mode could change.
239 /// Second press action: Repeats message.
243 /// Notably issued by XBOX360 remote as defined in irplus - Remote Control - Android application.
247 /// First press action: To be determined.
249 /// Second press action: Repeats message.
254 NetworkSelection = 0x2C,
257 VideoSelection = 0x61
261 /// Those codes come from experimenting with HP remotes.
263 public enum HpWindowsMediaCenterRemoteControl : ushort
266 /// Displays visual imagery that is synchronized to the sound of your music tracks.
268 /// Second press action: Repeats message.
272 /// Notably sent by the 'Visualization' button of HP Windows Media Center Remote (TSGH-IR08).
274 /// According to HP specs it displays visual imagery that is synchronized to the sound of your music tracks.
276 Visualization = WindowsMediaCenterRemoteControl.Ext0,
278 /// Plays a slide show of all the pictures on your hard disk drive.
280 /// Second press action: Repeats message.
284 /// Notably sent by the 'Slide Show' button of HP Windows Media Center Remote (TSGH-IR08).
286 /// According to HP specs it plays a slide show of all the pictures on your hard disk drive.
288 SlideShow = WindowsMediaCenterRemoteControl.Ext1,
290 /// Eject optical drive.
292 /// Second press action: Repeats message.
296 /// Notably sent by the 'Eject' button of HP Windows Media Center Remote (TSGH-IR08).
297 /// Also interpreted as 'Eject' action by SoundGraph iMON Manager in MCE mode (OrigenAE VF310).
299 HpEject = WindowsMediaCenterRemoteControl.Ext2,
301 /// Not sure what this should do.
303 /// Second press action: Repeats message.
307 /// Notably sent by the 'Input selection' button of HP Windows Media Center Remote (TSGH-IR08).
309 InputSelection = WindowsMediaCenterRemoteControl.Ext3,
313 /// Usage Table for Consumer Controls
316 public enum ConsumerControl : ushort
319 ConsumerControl = 0x01,
320 NumericKeyPad = 0x02,
321 ProgrammableButtons = 0x03,
324 GraphicEqualizer = 0x06,
325 ThinkPadMicrophoneMute = 0x10, //Custom
326 ThinkPadVantage = 0x11, //Custom
327 ThinkPadSystemLock = 0x12, //Custom
328 ThinkPadPowerManagement = 0x13, //Custom
329 ThinkPadWirelessNetwork = 0x14, //Custom
330 ThinkPadCamera = 0x15, //Custom
331 ThinkPadDisplayScheme = 0x16, //Custom
332 ThinkPadMouseProperties = 0x17, //Custom
333 ThinkPadEject = 0x18, //Custom
334 ThinkPadSystemHibernate = 0x19, //Custom
335 ThinkPadBrightnessIncrement = 0x1A, //Custom
336 ThinkPadBrightnessDecrement = 0x1B, //Custom
337 ThinkPadFullscreenMagnifier = 0x1D, //Custom
347 FunctionButtons = 0x36,
355 MenuValueIncrease = 0x47,
356 MenuValueDecrease = 0x48,
358 ClosedCaption = 0x61,
359 ClosedCaptionSelect = 0x62,
361 BroadcastMode = 0x64,
365 AssignSelection = 0x81,
371 MediaSelection = 0x87,
372 MediaSelectComputer = 0x88,
373 MediaSelectTv = 0x89,
374 MediaSelectWww = 0x8A,
375 MediaSelectDvd = 0x8B,
376 MediaSelectTelephone = 0x8C,
377 MediaSelectProgramGuide = 0x8D,
378 MediaSelectVideoPhone = 0x8E,
379 MediaSelectGames = 0x8F,
380 MediaSelectMessages = 0x90,
381 MediaSelectCd = 0x91,
382 MediaSelectVcr = 0x92,
383 MediaSelectTuner = 0x93,
386 MediaSelectTape = 0x96,
387 MediaSelectCable = 0x97,
388 MediaSelectSatellite = 0x98,
389 MediaSelectSecurity = 0x99,
390 MediaSelectHome = 0x9A,
391 MediaSelectCall = 0x9B,
392 ChannelIncrement = 0x9C,
393 ChannelDecrement = 0x9D,
394 MediaSelectSap = 0x9E,
405 ScanNextTrack = 0xB5,
406 ScanPreviousTrack = 0xB6,
420 RepeatFromMark = 0xC4,
422 SearchMarkForward = 0xC6,
423 SearchMarkBackwards = 0xC7,
426 TrackingIncrement = 0xCA,
427 TrackingDecrement = 0xCB,
440 VolumeIncrement = 0xE9,
441 VolumeDecrement = 0xEA,
443 PlaybackSpeed = 0xF1,
451 LightIlluminationLevel = 0x103,
452 ClimateControlEnable = 0x104,
453 RoomTemperature = 0x105,
454 SecurityEnable = 0x106,
461 MedicalAlarm = 0x10D,
462 BalanceRight = 0x150,
464 BassIncrement = 0x152,
465 BassDecrement = 0x153,
466 TrebleIncrement = 0x154,
467 TrebleDecrement = 0x155,
468 SpeakerSystem = 0x160,
470 ChannelRight = 0x162,
471 ChannelCenter = 0x163,
472 ChannelFront = 0x164,
473 ChannelCenterFront = 0x165,
475 ChannelSurround = 0x167,
476 ChannelLowFrequencyEnhancement = 0x168,
478 ChannelUnknown = 0x16A,
480 SubChannelIncrement = 0x171,
481 SubChannelDecrement = 0x172,
482 AlternateAudioIncrement = 0x173,
483 AlternateAudioDecrement = 0x174,
484 ApplicationLaunchButtons = 0x180,
485 AppLaunchLaunchButtonConfigurationTool = 0x181,
486 AppLaunchProgrammableButtonConfiguration = 0x182,
487 AppLaunchConsumerControlConfiguration = 0x183,
488 AppLaunchWordProcessor = 0x184,
489 AppLaunchTextEditor = 0x185,
490 AppLaunchSpreadsheet = 0x186,
491 AppLaunchGraphicsEditor = 0x187,
492 AppLaunchPresentationApp = 0x188,
493 AppLaunchDatabaseApp = 0x189,
494 AppLaunchEmailReader = 0x18A,
495 AppLaunchNewsreader = 0x18B,
496 AppLaunchVoicemail = 0x18C,
497 AppLaunchContactsAddressBook = 0x18D,
498 AppLaunchCalendarSchedule = 0x18E,
499 AppLaunchTaskProjectManager = 0x18F,
500 AppLaunchLogJournalTimecard = 0x190,
501 AppLaunchCheckbookFinance = 0x191,
502 AppLaunchCalculator = 0x192,
503 AppLaunchAVCapturePlayback = 0x193,
504 AppLaunchLocalMachineBrowser = 0x194,
505 AppLaunchLanWanBrowser = 0x195,
506 AppLaunchInternetBrowser = 0x196,
507 AppLaunchRemoteNetworkingIspConnect = 0x197,
508 AppLaunchNetworkConference = 0x198,
509 AppLaunchNetworkChat = 0x199,
510 AppLaunchTelephonyDialer = 0x19A,
511 AppLaunchLogon = 0x19B,
512 AppLaunchLogoff = 0x19C,
513 AppLaunchLogonLogoff = 0x19D,
514 AppLaunchTerminalLockScreensaver = 0x19E,
515 AppLaunchControlPanel = 0x19F,
516 AppLaunchCommandLineProcessorRun = 0x1A0,
517 AppLaunchProcessTaskManager = 0x1A1,
518 AppLaunchSelectTaskApplication = 0x1A2,
519 AppLaunchNextTaskApplication = 0x1A3,
520 AppLaunchPreviousTaskApplication = 0x1A4,
521 AppLaunchPreemptiveHaltTaskApplication = 0x1A5,
522 AppLaunchIntegratedHelpCenter = 0x1A6,
523 AppLaunchDocuments = 0x1A7,
524 AppLaunchThesaurus = 0x1A8,
525 AppLaunchDictionary = 0x1A9,
526 AppLaunchDesktop = 0x1AA,
527 AppLaunchSpellCheck = 0x1AB,
528 AppLaunchGrammarCheck = 0x1AC,
529 AppLaunchWirelessStatus = 0x1AD,
530 AppLaunchKeyboardLayout = 0x1AE,
531 AppLaunchVirusProtection = 0x1AF,
532 AppLaunchEncryption = 0x1B0,
533 AppLaunchScreenSaver = 0x1B1,
534 AppLaunchAlarms = 0x1B2,
535 AppLaunchClock = 0x1B3,
536 AppLaunchFileBrowser = 0x1B4,
537 AppLaunchPowerStatus = 0x1B5,
538 AppLaunchImageBrowser = 0x1B6,
539 AppLaunchAudioBrowser = 0x1B7,
540 AppLaunchMovieBrowser = 0x1B8,
541 AppLaunchDigitalRightsManager = 0x1B9,
542 AppLaunchDigitalWallet = 0x1BA,
543 AppLaunchInstantMessaging = 0x1BC,
544 AppLaunchOemFeaturesTipsTutorialBrowser = 0x1BD,
545 AppLaunchOemHelp = 0x1BE,
546 AppLaunchOnlineCommunity = 0x1BF,
547 AppLaunchEntertainmentContentBrowser = 0x1C0,
548 AppLaunchOnlineShoppingBrowser = 0x1C1,
549 AppLaunchSmartcardInformationHelp = 0x1C2,
550 AppLaunchMarketMonitorFinanceBrowser = 0x1C3,
551 AppLaunchCustomizedCorporateNewsBrowser = 0x1C4,
552 AppLaunchOnlineActivityBrowser = 0x1C5,
553 AppLaunchResearchSearchBrowser = 0x1C6,
554 AppLaunchAudioPlayer = 0x1C7,
555 GenericGuiApplicationControls = 0x200,
558 AppCtrlClose = 0x203,
560 AppCtrlMaximize = 0x205,
561 AppCtrlMinimize = 0x206,
563 AppCtrlPrint = 0x208,
564 AppCtrlProperties = 0x209,
568 AppCtrlPaste = 0x21D,
569 AppCtrlSelectAll = 0x21E,
571 AppCtrlFindAndReplace = 0x220,
572 AppCtrlSearch = 0x221,
576 AppCtrlForward = 0x225,
578 AppCtrlRefresh = 0x227,
579 AppCtrlPreviousLink = 0x228,
580 AppCtrlNextLink = 0x229,
581 AppCtrlBookmarks = 0x22A,
582 AppCtrlHistory = 0x22B,
583 AppCtrlSubscriptions = 0x22C,
584 AppCtrlZoomIn = 0x22D,
585 AppCtrlZoomOut = 0x22E,
587 AppCtrlFullScreenView = 0x230,
588 AppCtrlNormalView = 0x231,
589 AppCtrlViewToggle = 0x232,
590 AppCtrlScrollUp = 0x233,
591 AppCtrlScrollDown = 0x234,
592 AppCtrlScroll = 0x235,
593 AppCtrlPanLeft = 0x236,
594 AppCtrlPanRight = 0x237,
596 AppCtrlNewWindow = 0x239,
597 AppCtrlTileHorizontally = 0x23A,
598 AppCtrlTileVertically = 0x23B,
599 AppCtrlFormat = 0x23C,
602 AppCtrlItalics = 0x23F,
603 AppCtrlUnderline = 0x240,
604 AppCtrlStrikethrough = 0x241,
605 AppCtrlSubscript = 0x242,
606 AppCtrlSuperscript = 0x243,
607 AppCtrlAllCaps = 0x244,
608 AppCtrlRotate = 0x245,
609 AppCtrlResize = 0x246,
610 AppCtrlFlipHorizontal = 0x247,
611 AppCtrlFlipVertical = 0x248,
612 AppCtrlMirrorHorizontal = 0x249,
613 AppCtrlMirrorVertical = 0x24A,
614 AppCtrlFontSelect = 0x24B,
615 AppCtrlFontColor = 0x24C,
616 AppCtrlFontSize = 0x24D,
617 AppCtrlJustifyLeft = 0x24E,
618 AppCtrlJustifyCenterH = 0x24F,
619 AppCtrlJustifyRight = 0x250,
620 AppCtrlJustifyBlockH = 0x251,
621 AppCtrlJustifyTop = 0x252,
622 AppCtrlJustifyCenterV = 0x253,
623 AppCtrlJustifyBottom = 0x254,
624 AppCtrlJustifyBlockV = 0x255,
625 AppCtrlIndentDecrease = 0x256,
626 AppCtrlIndentIncrease = 0x257,
627 AppCtrlNumberedList = 0x258,
628 AppCtrlRestartNumbering = 0x259,
629 AppCtrlBulletedList = 0x25A,
630 AppCtrlPromote = 0x25B,
631 AppCtrlDemote = 0x25C,
634 AppCtrlCancel = 0x25F,
635 AppCtrlCatalog = 0x260,
636 AppCtrlBuyCheckout = 0x261,
637 AppCtrlAddToCart = 0x262,
638 AppCtrlExpand = 0x263,
639 AppCtrlExpandAll = 0x264,
640 AppCtrlCollapse = 0x265,
641 AppCtrlCollapseAll = 0x266,
642 AppCtrlPrintPreview = 0x267,
643 AppCtrlPasteSpecial = 0x268,
644 AppCtrlInsertMode = 0x269,
645 AppCtrlDelete = 0x26A,
647 AppCtrlUnlock = 0x26C,
648 AppCtrlProtect = 0x26D,
649 AppCtrlUnprotect = 0x26E,
650 AppCtrlAttachComment = 0x26F,
651 AppCtrlDeleteComment = 0x270,
652 AppCtrlViewComment = 0x271,
653 AppCtrlSelectWord = 0x272,
654 AppCtrlSelectSentence = 0x273,
655 AppCtrlSelectParagraph = 0x274,
656 AppCtrlSelectColumn = 0x275,
657 AppCtrlSelectRow = 0x276,
658 AppCtrlSelectTable = 0x277,
659 AppCtrlSelectObject = 0x278,
660 AppCtrlRedoRepeat = 0x279,
662 AppCtrlSortAscending = 0x27B,
663 AppCtrlSortDescending = 0x27C,
664 AppCtrlFilter = 0x27D,
665 AppCtrlSetClock = 0x27E,
666 AppCtrlViewClock = 0x27F,
667 AppCtrlSelectTimeZone = 0x280,
668 AppCtrlEditTimeZones = 0x281,
669 AppCtrlSetAlarm = 0x282,
670 AppCtrlClearAlarm = 0x283,
671 AppCtrlSnoozeAlarm = 0x284,
672 AppCtrlResetAlarm = 0x285,
673 AppCtrlSynchronize = 0x286,
674 AppCtrlSendReceive = 0x287,
675 AppCtrlSendTo = 0x288,
676 AppCtrlReply = 0x289,
677 AppCtrlReplyAll = 0x28A,
678 AppCtrlForwardMsg = 0x28B,
680 AppCtrlAttachFile = 0x28D,
681 AppCtrlUpload = 0x28E,
682 AppCtrlDownloadSaveTargetAs = 0x28F,
683 AppCtrlSetBorders = 0x290,
684 AppCtrlInsertRow = 0x291,
685 AppCtrlInsertColumn = 0x292,
686 AppCtrlInsertFile = 0x293,
687 AppCtrlInsertPicture = 0x294,
688 AppCtrlInsertObject = 0x295,
689 AppCtrlInsertSymbol = 0x296,
690 AppCtrlSaveAndClose = 0x297,
691 AppCtrlRename = 0x298,
692 AppCtrlMerge = 0x299,
693 AppCtrlSplit = 0x29A,
694 AppCtrlDistributeHorizontally = 0x29B,
695 AppCtrlDistributeVertically = 0x29C
701 enum GenericDesktop : ushort
710 MultiAxisController = 0x08,
711 TabletPcSystemControls = 0x09,
722 CountedBuffer = 0x3A,
734 SystemControl = 0x80,
735 SystemPowerDown = 0x81,
738 SystemContextMenu = 0x84,
739 SystemMainMenu = 0x85,
740 SystemAppMenu = 0x86,
741 SystemMenuHelp = 0x87,
742 SystemMenuExit = 0x88,
743 SystemMenuSelect = 0x89,
744 SystemMenuRight = 0x8A,
745 SystemMenuLeft = 0x8B,
747 SystemMenuDown = 0x8D,
748 SystemColdRestart = 0x8E,
749 SystemWarmRestart = 0x8F,
758 SystemDebuggerBreak = 0xA4,
759 ApplicationBreak = 0xA5,
760 ApplicationDebuggerBreak = 0xA6,
761 SystemSpeakerMute = 0xA7,
762 SystemHibernate = 0xA8,
763 SystemDisplayInvert = 0xB0,
764 SystemDisplayInternal = 0xB1,
765 SystemDisplayExternal = 0xB2,
766 SystemDisplayBoth = 0xB3,
767 SystemDisplayDual = 0xB4,
768 SystemDisplayToggleIntExt = 0xB5,
769 SystemDisplaySwapPrimarySecondary = 0xB6,
770 SystemDisplayLcdAutoscale = 0xB7
776 enum SimulationControl : ushort
779 FlightSimulationDevice = 0x01,
780 AutomobileSimulationDevice = 0x02,
781 TankSimulationDevice = 0x03,
782 SpaceshipSimulationDevice = 0x04,
783 SubmarineSimulationDevice = 0x05,
784 SailingSimulationDevice = 0x06,
785 MotorcycleSimulationDevice = 0x07,
786 SportsSimulationDevice = 0x08,
787 AirplaneSimulationDevice = 0x09,
788 HelicopterSimulationDevice = 0x0A,
789 MagicCarpetSimulationDevice = 0x0B,
790 BicycleSimulationDevice = 0x0C,
791 FlightControlStick = 0x20,
793 CyclicControl = 0x22,
799 AntiTorqueControl = 0xB2,
800 AutopilotEnable = 0xB3,
802 CollectiveControl = 0xB5,
804 ElectronicCountermeasures = 0xB7,
809 FlightCommunications = 0xBC,
815 WeaponsSelect = 0xC2,
822 TurretDirection = 0xC9,
823 BarrelElevation = 0xCA,
835 enum GameControl : ushort
838 GameController3D = 0x01,
839 PinballDevice = 0x02,
842 TurnRightLeft = 0x21,
843 PitchForwardBackward = 0x22,
844 RollRightLeft = 0x23,
845 MoveRightLeft = 0x24,
846 MoveForwardBackward = 0x25,
848 LeanRightLeft = 0x27,
849 LeanForwardBackward = 0x28,
852 SecondaryFlipper = 0x2B,
860 GunSingleShot = 0x33,
864 GamepadFireJump = 0x37,
865 GamepadTrigger = 0x39
871 enum TelephonyDevice : ushort
875 AnsweringMachine = 0x02,
876 MessageControls = 0x03,
879 TelephonyKeyPad = 0x06,
880 ProgrammableButton = 0x07,
890 AlternateFunction = 0x29,
902 PhoneDirectory = 0x53,
908 InsideDialTone = 0x90,
909 OutsideDialTone = 0x91,
910 InsideRingTone = 0x92,
911 OutsideRingTone = 0x93,
912 PriorityRingTone = 0x94,
913 InsideRingback = 0x95,
914 PriorityRingback = 0x96,
917 CallWaitingTone = 0x99,
918 ConfirmationTone1 = 0x9A,
919 ConfirmationTone2 = 0x9B,
921 OutsideRingback = 0x9D,
934 PhoneKeyPound = 0xBB,