Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista Drivers > Keyboard filter driver for the multimedia and power keys on a usb keyboard.

Reply
Thread Tools Display Modes

Keyboard filter driver for the multimedia and power keys on a usb keyboard.

 
 
lichtf
Guest
Posts: n/a

 
      01-27-2006
Hello all --

I am trying to write a keyboard filter driver that will basically eat
the multimedia and the power keys on a USB keyboard. I used the
kbfiltr sample from the DDK and got it working for a PS/2 keyboard, but
it doesn't work for a USB keyboard.

I've read some other posts and it looks like the multimedia and the
power keys are separate HID collections. If this is true do I need to
write a HID filter driver for these collections?

If this isn't true then what is the best approach to take?

Any help would be greatly appreciated.

Thanks.

 
Reply With Quote
 
 
 
 
Robert Marquardt
Guest
Posts: n/a

 
      01-27-2006
lichtf wrote:
> Hello all --
>
> I am trying to write a keyboard filter driver that will basically eat
> the multimedia and the power keys on a USB keyboard. I used the
> kbfiltr sample from the DDK and got it working for a PS/2 keyboard, but
> it doesn't work for a USB keyboard.
>
> I've read some other posts and it looks like the multimedia and the
> power keys are separate HID collections. If this is true do I need to
> write a HID filter driver for these collections?


They are indeed separate collections and therefore show up as separate
devices. The multimedia keys are not part of the normal keyboard
handling. They get read by a service and posted as WM_APPCOMMAND
messages to the foreground application. Depending on the return value
for the message handling the keys get suppressed or not.

So if you only want to suppress it for your application then simply
handle WM_APPCOMMAND.
 
Reply With Quote
 
lichtf
Guest
Posts: n/a

 
      01-27-2006
Robert,

Thank you for your response.

I actually need to suppress the keys for all applications, not only my
own.
What I have is a keyboard with the multi-media keys. These keys have
different pictures and labels on them that link to my application. So
I need to prevent these keys from doing what they normally do, by
eating them, and I need to notify my application when they are pressed.
If my application isn't running I still need to eat them. Is there a
way I can do this before the service gets them and posts the
WM_APPCOMMAND?

Another problem is the Power buttons. Even in PS/2 if I ate the keys
they still ended up working, ie. shut down the machine. I found a way
to disable them by using the following code in the
IRP_MJ_DEVICE_CONTROL function on the IOCTL_GET_SYS_BUTTON_CAPS control
code:

ULONG caps;

caps = 0x0;

if(Irp->PendingReturned)
IoMarkIrpPending(Irp);

//
// Get the current value.
//
caps = *(PULONG) Irp->AssociatedIrp.SystemBuffer;
//
// Clear all the bits related to power.
//
caps &= ~(SYS_BUTTON_SLEEP | SYS_BUTTON_POWER | SYS_BUTTON_WAKE);

//
// Set the new value.
//
*(PULONG) Irp->AssociatedIrp.SystemBuffer = caps;

Do you know if there is a way that I can disable the power buttons
functionality, but still get notified about them, for a USB keyboard?

Thanks for the help.

 
Reply With Quote
 
Doron Holan [MS]
Guest
Posts: n/a

 
      01-28-2006
you would filter the appropriate collections based on the hw ID
(HID_DEVICE_SYSTEM_CONSUMER for the app buttons, i don't have the pwr button
offhand). you would install yourself as an upper filter or the service on
both collecitons. for the power button, you should do the same as PS2
(clear out the flags in the ioctl). as for the consumer controls, you would
have to open the collection for exclusive access so that hidserv cannot open
them. once either collection is open, you would continuously polll the
collection by always haveing a read irp pending. what you do with the
results is up to you. see the firefly example for how a HID driver can open
itself up.

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.


"lichtf" <> wrote in message
news: ups.com...
> Robert,
>
> Thank you for your response.
>
> I actually need to suppress the keys for all applications, not only my
> own.
> What I have is a keyboard with the multi-media keys. These keys have
> different pictures and labels on them that link to my application. So
> I need to prevent these keys from doing what they normally do, by
> eating them, and I need to notify my application when they are pressed.
> If my application isn't running I still need to eat them. Is there a
> way I can do this before the service gets them and posts the
> WM_APPCOMMAND?
>
> Another problem is the Power buttons. Even in PS/2 if I ate the keys
> they still ended up working, ie. shut down the machine. I found a way
> to disable them by using the following code in the
> IRP_MJ_DEVICE_CONTROL function on the IOCTL_GET_SYS_BUTTON_CAPS control
> code:
>
> ULONG caps;
>
> caps = 0x0;
>
> if(Irp->PendingReturned)
> IoMarkIrpPending(Irp);
>
> //
> // Get the current value.
> //
> caps = *(PULONG) Irp->AssociatedIrp.SystemBuffer;
> //
> // Clear all the bits related to power.
> //
> caps &= ~(SYS_BUTTON_SLEEP | SYS_BUTTON_POWER | SYS_BUTTON_WAKE);
>
> //
> // Set the new value.
> //
> *(PULONG) Irp->AssociatedIrp.SystemBuffer = caps;
>
> Do you know if there is a way that I can disable the power buttons
> functionality, but still get notified about them, for a USB keyboard?
>
> Thanks for the help.
>



 
Reply With Quote
 
Robert Marquardt
Guest
Posts: n/a

 
      01-28-2006
AFAIK it is also possible to simply shut down the service for the
multimedia keys. The only drawback is that it is not configurable. The
filter driver could be commanded to stop filtering.
 
Reply With Quote
 
Barry
Guest
Posts: n/a

 
      01-28-2006

"Doron Holan [MS]" <> wrote:
> you would filter the appropriate collections based on the hw ID
> (HID_DEVICE_SYSTEM_CONSUMER for the app buttons, i don't have the pwr

button
> offhand). you would install yourself as an upper filter or the service on
> both collecitons.


How about a lower filter?


 
Reply With Quote
 
Doron Holan [MS]
Guest
Posts: n/a

 
      01-28-2006
the type of filter doesn't matter b/c teh HID PDO is raw and there are no
other drivers attached to it.

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.


"Barry" <> wrote in message
news:%...
>
> "Doron Holan [MS]" <> wrote:
>> you would filter the appropriate collections based on the hw ID
>> (HID_DEVICE_SYSTEM_CONSUMER for the app buttons, i don't have the pwr

> button
>> offhand). you would install yourself as an upper filter or the service
>> on
>> both collecitons.

>
> How about a lower filter?
>
>



 
Reply With Quote
 
lichtf
Guest
Posts: n/a

 
      01-30-2006
Thank you for your response Doron. It is very helpful.

I haven't had a chance to try your suggestions because I am running
into a problem with actually installing the driver. I started with the
kbfilt sample inf file and tweaked it to try and install the firefly
driver for the HID_DEVICE_SYSTEM_CONSUMER. I made changes to install
to the HID class and for the "correct" device. The installation seemed
to go fine, but it doesn't seem like the driver is actually being used.
I try to output in the DriverEntry function and I never see that on my
debugger. So I'm assuming my installation is incorrect.

One thing I'm not sure about in the inf file is if I need to change
lines like:
Include = MSMOUSE.INF
Needs = HID_Mouse_Inst.NT
or if I can just remove them. Do you know of a sample inf for
installing an upper filter for a HID? Any help would be greatly
appreciated.

Thanks.

 
Reply With Quote
 
Doron Holan [MS]
Guest
Posts: n/a

 
      01-30-2006
you do not reference msmouse.inf in a hid filter, that is for a mouse only.

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.


"lichtf" <> wrote in message
news: oups.com...
> Thank you for your response Doron. It is very helpful.
>
> I haven't had a chance to try your suggestions because I am running
> into a problem with actually installing the driver. I started with the
> kbfilt sample inf file and tweaked it to try and install the firefly
> driver for the HID_DEVICE_SYSTEM_CONSUMER. I made changes to install
> to the HID class and for the "correct" device. The installation seemed
> to go fine, but it doesn't seem like the driver is actually being used.
> I try to output in the DriverEntry function and I never see that on my
> debugger. So I'm assuming my installation is incorrect.
>
> One thing I'm not sure about in the inf file is if I need to change
> lines like:
> Include = MSMOUSE.INF
> Needs = HID_Mouse_Inst.NT
> or if I can just remove them. Do you know of a sample inf for
> installing an upper filter for a HID? Any help would be greatly
> appreciated.
>
> Thanks.
>



 
Reply With Quote
 
lichtf
Guest
Posts: n/a

 
      01-30-2006
I'm sorry I might not have been clear about what I was asking. I
realize that I don't use the mouse stuff, but I was wondering if I
needed to use something else instead. I think I figured out to include
HIDserv.inf instead.

So now I have it installed, but I get an error that says can't find
device. My driver sees calls to DriverEntry followed immediately by
Unload. I don't understand why nothing else is being called before I
get an unload.

I even tried using a sample filter driver, a very basic one that just
passes things along, from one of Walter Oney's books. This has the
same thing happen.

So the device stops working when I add my filter to it.
Any advice?

Thank you.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Some extended keys (Calculator) do not work on Wireless Natural Multimedia Keyboard under Vista (32 bit) DejanVesic Windows Vista Hardware 4 08-11-2008 09:45 PM
KB950582 Disables HP Multimedia Keyboard Keys VISTA_BOY Windows Vista Installation 2 07-10-2008 08:37 PM
Logitech keyboard multimedia keys not working in Vista fyleow Windows Vista Hardware 1 06-09-2006 12:17 AM
Keyboard filter driver - obtaining keyboard indicator status Kyzer Windows Vista Drivers 21 12-06-2005 02:26 PM
How to write a keyboard filter driver to simulate keys Vamsi Krishna Windows Vista Drivers 2 06-20-2005 05:39 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59