Re: Injecting keyboard scan codes at driver level



as a hid miniport you cannot create a control device object. you have a couple of alternatives
1) report a fake new HID TLC in your hid descriptor that is used as a control channel
2) use the WDK 6001 osrfx2hid sample which is really a full blown KMDF driver using a HID miniport that is purely pass through. at that point, you can create a control device (not recommended) or enumerate a raw PDO (see the kmdf kbdfiltr example on how to do that) to talk with user mode

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"Owen Smith" <nospam.osmith@xxxxxxxxxxxxxxxxx> wrote in message news:op.t0lu1qbu39p9aw@xxxxxxxxxxxx
Have a look at the vhidmini and toaster bus sample drivers. This should allow you to make a HID keyboard driver that is root enumerated. You will need to create a control object to communictate (you cant open the keyboard directly)
Although this will create a HID keyboard, the system will combine all the output into one, so you dont need to worry about writing for both PS/2 and USB possibilities

On Mon, 22 Oct 2007 12:17:00 +0100, Mark Andrews <Mark <Andrews@xxxxxxxxxxxxxxxxxxxxxxxxx>> wrote:

I am writing a program for a friend who has difficulty using the keyboard. I
would like to create a program that injects scan codes directly into the
keyboard data stream to simulate an actual key press. There are certain
programs he has installed that read the raw keyboard data so the simple Post
Message and Send Input solutions do not work. I must somehow simulate key
presses at the lowest level so that they appear as raw data.

Hardware:
The operating system is XP using a PS/2 keyboard. There is a high
probability that he will upgrade to a USB keyboard and Vista but probably not
at the same time. The program must therefore be compatible with both OS and
both port types.

Ideas:
I have 2 ideas. The first is to create a virtual keyboard in device manager
that Windows sees as a real keyboard. My user program will tell this virtual
keyboard what keys are pressed/released and the device will be read by
Windows/programs as normal. I have found no information on how to do this
so...
My second idea is to create a keyboard filter driver which would append the
scan codes to the keyboard data stream based on data received from the user
program.

How far I have got:
I have no experience with drivers and I’m eager to learn. I have determined
that:
- The driver must be an upper level keyboard class filter driver (simple
registry installation)
- The driver does not need to handle (dis)connection, power or LEDs. It only
injects scan codes
- The driver does not block, read or modify any real keyboard activity – it
lets it all through
- The user program simply sends scan codes to the driver – there is no other
communication (although some result value to let the program know that the
driver responded would be useful)

I have hit a brick wall as I do not know where to begin! I have successfully
built a scan code modifying kbfiltr from the DDK but this is PS/2 lower
level, has complex unnecessary code and has no injection sample code.
Ctrl2Cap sounds interesting but there is no source code available now and the
author states that injection will be difficult to achieve.

While I am fluent in C and programming in general, I understand that this
program will require non-user mode programming and I have zero experience in
this area. This program has a very simple, specific, unobtrusive function but
I’m finding it hard to know where to start. Any advice, links or samples to
help me achieve this goal would be fantastic. Thank you.




--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

.



Relevant Pages

  • Re: HID device
    ... I am not certain about this, but if the keyboard conforms to the USB HID ... Class specification, doesn't CE include a driver that handles HID devices? ...
    (microsoft.public.windowsce.platbuilder)
  • Re: HID device
    ... Just copy the PUBLIC driver code and build one ... monolithic USBHID DLL under your platform. ... > defined hid). ... We are severly customizing this keyboard and we have some ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Supporting a PS/2 Keyboard
    ... USB host port, right? ... Why not just put the HID keyboard driver in and let ... the users use a USB keyboard, or does it _have_ to be PS/2? ... interpreter that converts the scan codes returned by the USB part of the ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Supporting a PS/2 Keyboard
    ... The USB keyboard driver is an HID driver. ... interpreter that converts the scan codes returned by the USB part of the ... Hardware cost might go up, ...
    (microsoft.public.windowsce.platbuilder)
  • Re: conversion from scan code to ascii
    ... Your best bet is to log keyboard events in scan codes, ... And in driver I'd recommend to stick with scan codes. ... uses European keyboard layouts). ...
    (microsoft.public.development.device.drivers)

Loading