HID report question

Hello…
I was wondering if anyone knows of a simple/straightforward way to convert
PS/2 scan codes into a HID report format (sort of the opposite of
HidP_TranslateUsagesToI8042ScanCodes)?
I’m trying to take PS/2 keyboard scancode data and create HID input
reports from it; this is pretty much the opposite of what kbdhid.sys does.
I can create and initialize a new HID read report for a collection, but
I’m a bit confused as to exactly how to setup the HID input report to
reflect that a particular key (which I have a scancode for) is
pressed/released…

Thanks,
sean

At the bottom of http://www.microsoft.com/hwdev/tech/input/Scancode.asp,
there is a table (As a pdf or xl file) which has the hid to ps/2 scan
key mapping. You can use the table to generate your own xlation table
to map to HID.

If I may ask, if you are getting your scancodes from ps2 keyboard, why
do you need to convert that into HID?

d

-----Original Message-----
From: xxxxx@stg.com [mailto:xxxxx@stg.com]
Sent: Thursday, April 17, 2003 1:06 PM
To: NT Developers Interest List
Subject: [ntdev] HID report question

Hello…
I was wondering if anyone knows of a simple/straightforward way to
convert
PS/2 scan codes into a HID report format (sort of the opposite of
HidP_TranslateUsagesToI8042ScanCodes)?
I’m trying to take PS/2 keyboard scancode data and create HID input
reports from it; this is pretty much the opposite of what kbdhid.sys
does.
I can create and initialize a new HID read report for a collection, but
I’m a bit confused as to exactly how to setup the HID input report to
reflect that a particular key (which I have a scancode for) is
pressed/released…

Thanks,
sean


You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

> If I may ask, if you are getting your scancodes from ps2 keyboard, why

do you need to convert that into HID?

d

Basically my situation is that I’m writing a driver that needs to run on
systems which may or may not have an i8042 port on them for the keyboard.
The driver gets keyboard data from across the network, and needs to insert
that KB data into the input stream.
From what I’ve read (in various WinHEC/WinDEV presentations), on systems
without i8042 user32.exe/win32k.sys will grab data *directly* from HID
devices (since there would be no need to load up kbdhid.sys and
kbdclass.sys to handle an i8042 keyboard). This directly contradicts the
drawing in the DDK, which shows that user32.exe/win32k.sys *only* goes
through the kbdclass.sys driver, but it makes sense and seems like the DDK
drawing is wrong…
So going on the assumption that win32k.sys can read directly from a HID
driver for input data, I want to get the scancodes from across the
network, and format them into a HID report that can be used to satisfy
win32k.sys HID IRP_MJ_READ requests…
Is my assumption about kbdclass.sys not always being loaded incorrect? I
don’t see why kbdclass.sys and kbdhid.sys would be loaded on a legacy-free
system since they would just add unnecessary complexity as opposed to
reading the HID data directly… and if a i8042 HID minidriver was ever
written, then kbdclass.sys and kbdhid.sys would be irrelevant…

Thanks for your help,
sean

You are incorrect on a few points.

I8042prt.sys is loaded for ps2 devices (both keyboard and mouse)
Kbdhid.sys is loaded for HID devices (USB, Bluetooth, etc)

So on LF systems, kbdhid is still loaded (as is mouhid for mice).

Win32k listens for and and sends reads to the keyboard device interface
guid, not the HID interface for keyboards (and the mouse device
interface guid for mice). Starting in XP, win32k understands raw HID
for devices outside of keyboard and mouse as well (WM_INPUT), but it
still reads from the keyboards and mice using KEYBOARD_INPUT_DATA and
MOUSE_INPUT_DATA.

What you want to do is install your own device stack for your keyboard
in the keyboard device class. This will auto load kbdclass on top of
you. Then, just call the service class callback when you have any data.
Since you are reporting KEYBOARD_INPUT_DATAs which contain scancodes and
not HID, there is no conversion. Kbdclass takes care of the read IRPs
on your behalf, you just worry about getting the data to kbdclass.

D

This posting is provided “AS IS” with no warranties, and confers no
rights

-----Original Message-----
From: xxxxx@stg.com [mailto:xxxxx@stg.com]
Sent: Thursday, April 17, 2003 1:37 PM
To: NT Developers Interest List
Subject: [ntdev] RE: HID report question

If I may ask, if you are getting your scancodes from ps2 keyboard, why
do you need to convert that into HID?

d

Basically my situation is that I’m writing a driver that needs to run on
systems which may or may not have an i8042 port on them for the
keyboard.
The driver gets keyboard data from across the network, and needs to
insert
that KB data into the input stream.
From what I’ve read (in various WinHEC/WinDEV presentations), on systems
without i8042 user32.exe/win32k.sys will grab data *directly* from HID
devices (since there would be no need to load up kbdhid.sys and
kbdclass.sys to handle an i8042 keyboard). This directly contradicts the
drawing in the DDK, which shows that user32.exe/win32k.sys *only* goes
through the kbdclass.sys driver, but it makes sense and seems like the
DDK
drawing is wrong…
So going on the assumption that win32k.sys can read directly from a HID
driver for input data, I want to get the scancodes from across the
network, and format them into a HID report that can be used to satisfy
win32k.sys HID IRP_MJ_READ requests…
Is my assumption about kbdclass.sys not always being loaded incorrect? I
don’t see why kbdclass.sys and kbdhid.sys would be loaded on a
legacy-free
system since they would just add unnecessary complexity as opposed to
reading the HID data directly… and if a i8042 HID minidriver was ever
written, then kbdclass.sys and kbdhid.sys would be irrelevant…

Thanks for your help,
sean


You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

> What you want to do is install your own device stack for your keyboard

in the keyboard device class. This will auto load kbdclass on top of
you. Then, just call the service class callback when you have any data.
Since you are reporting KEYBOARD_INPUT_DATAs which contain scancodes and
not HID, there is no conversion. Kbdclass takes care of the read IRPs
on your behalf, you just worry about getting the data to kbdclass.

D

Ah… thanks for clearing that up for me. One more quick question: I don’t
have a physical keyboard on the machine that I would like to insert the
input data into. The machine may or may not have a HID keyboard installed,
so it’s possible the machine would be running without a kb/mouse. Would it
be correct to use a root-enumerated software-only driver to force the kbd
and mou device stacks to load on 2K/XP? Thus forcing the mouse and kbd
device stacks to load up on top of root-enumerated device?

Thanks again for all the help!
sean

Yes, create root enumerated stacks. The FDO for the stack would *not*
be a built in driver (i8042prt, kbdhid, mouhid) though. Instead, the
FDO would be your own driver that knows how to talk over the network.
On top of your FDO will be kbdclass (which an in the build driver) if
you install your device under the keyboard device class guid (which is
specified in the INF).

d

-----Original Message-----
From: xxxxx@stg.com [mailto:xxxxx@stg.com]
Sent: Thursday, April 17, 2003 2:12 PM
To: NT Developers Interest List
Subject: [ntdev] RE: HID report question

What you want to do is install your own device stack for your keyboard
in the keyboard device class. This will auto load kbdclass on top of
you. Then, just call the service class callback when you have any
data.
Since you are reporting KEYBOARD_INPUT_DATAs which contain scancodes
and
not HID, there is no conversion. Kbdclass takes care of the read IRPs
on your behalf, you just worry about getting the data to kbdclass.

D

Ah… thanks for clearing that up for me. One more quick question: I
don’t
have a physical keyboard on the machine that I would like to insert the
input data into. The machine may or may not have a HID keyboard
installed,
so it’s possible the machine would be running without a kb/mouse. Would
it
be correct to use a root-enumerated software-only driver to force the
kbd
and mou device stacks to load on 2K/XP? Thus forcing the mouse and kbd
device stacks to load up on top of root-enumerated device?

Thanks again for all the help!
sean


You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

> Yes, create root enumerated stacks. The FDO for the stack would *not*

be a built in driver (i8042prt, kbdhid, mouhid) though. Instead, the
FDO would be your own driver that knows how to talk over the network.
On top of your FDO will be kbdclass (which an in the build driver) if
you install your device under the keyboard device class guid (which is
specified in the INF).

d

Cool… thanks again for all of the help!

sean