Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / October 2007



Tip: Looking for answers? Try searching our database.

How do I extract keystrokes from a specific USB HID Device (external Keypad) before the OS interprets them as keystrokes?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
markusw - 14 Oct 2007 23:53 GMT
Hello everyone,

here's what I'd like to do: I want to take a standard issue external
USB Keypad (like those sold for laptops that come without one) and use
it as programmable function keys.

Now what I've figured is that since the Keypad must have a different
USB Vendor/Device-ID combination than the normal keyboard, there might
be a way to somehow snatch the keystrokes of that specific device out
of the HID driver stack before they get into the OS and are
interpreted as the numeric key strokes they originally were (and
possibly reinsert them, after alteration)

I've been poking around at developer.apple.com, but being new to
driver-level programming I haven't been able to see a viable way of
doing this without programming an entire driver myself. Has anyone
done this before or knows where I should start looking?

I know there are dedicated devices out there that offer such
functionality out if the box, but compaired to a 10$ USB keypad they
cost teh $$$ and, being a student, are way beyond my budget. Plus,
it's no challenge at all. I only need the proper entry point to start
looking at, no need to spell out the solution step by step ;-)

Anyway, thanks for reading and helping.

Bye
Markus
David Phillip Oster - 15 Oct 2007 01:44 GMT
> here's what I'd like to do: I want to take a standard issue external
> USB Keypad (like those sold for laptops that come without one) and use
[quoted text clipped - 17 lines]
> it's no challenge at all. I only need the proper entry point to start
> looking at, no need to spell out the solution step by step ;-)

Look in the sample code for USB DDK (referenced off of
http://developer.apple.com/hardwaredrivers/download/

for sample code to write a driver to attach to specific USB
Vendor/Device-ID pair. I believe a complete keyboard driver is given as
an example.

The sample code HID Explorer
http://developer.apple.com/samplecode/HID_Explorer/

shows how to write an application that further processes a specific USB
device (watch out: it doesn't cover all the runloop modes a real app
should cover.)

But, to do what you want: inject keystrokes into the event stream other
than those from the actual device, you'd probably will need to write a
device driver that captures the device, with an ioctl() that you can use
from an application to configure your driver's behavior.

You may be able to do what you want without writing any code, by
learning more about the tables OS X uses to turn hardware keystrokes
into the key events seen by the O.S.
markusw - 15 Oct 2007 19:08 GMT
Hi David.

Thanks for the helpful pointers.

I'll start reading into the DDK and the HID_Explorer-code tonight. (I
admit I haven't had a look into the DDK because I didn't expect having
to write a driver).

I've read up on ioctl(). I didn't know of this function, and it looks
very promising for what I want to do. I'll also read up on those
tables that map hardware keystrokes, but I don't know if they'll help
me if I want to also be able to execute scripts and start programs.

Thank you!

bye
Markus
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.