According to Microsoft doc: https://learn.microsoft.com/en-us/windows/win32/api/ntddkbd/ns-ntddkbd-keyboard_input_data
UnitId:
Specifies the unit number of a keyboard device. A keyboard device name has the format \Device\KeyboardPortN, where the suffix N is the unit number of the device. For example, a device, whose name is \Device\KeyboardPort0, has a unit number of zero, and a device, whose name is \Device\KeyboardPort1, has a unit number of one.
Firstly, I can never found a device named “\Device\KeyboardPortN” in my win10 system using Sysinternal’s WinObj. The only name related to keyboard that I could locate is “\Device\KeyboardClassN”. Is it an error with the documentation?
Secondly, after some tests, the UnitId doesn’t seem to be the same as the N in the “\Device\KeyboardClassN” (if this is the actual name).
In one test, in a Virtualbox system running win10 guest where there is an emulated PS/2 keyboard using \Device\KeyboardClass0, and another 2 USB keyboards using \Device\KeyboardClass1 and \Device\KeyboardClass2, the UnitId sent by kbdhid.sys does equal to 1 and 2 presumably corresponding to KeyboardClassN.
But in the another test host win10 where I have only 2 USB keyboards without any PS2 keyboard. The UnitId sent by kbdhid.sys is of value 1 or 2 and never equal to 0 while WinObj indicates i have 2 devices “\Device\KeyboardClass0” and “\Device\KeyboardClass1” corresponding to the 2 usb keyboard devices.
So my 2nd question is what is this UnitId corresponds to?