Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Keyboard Driver HowTo?



Hello,

I thought that I'd respond to some of your comments and questions

At 4:35 PM +0100 2/3/05, P.V. Machielse wrote:
I want to do the following: remap some keys on a _specific_ usb-keyboard. For instance: when I press the right option key, I want it to be reported as 'enter'.

When I first started reading your question, I thought that implementing a keyboard layout would be a better alternative than implementing a replacement kernel extension. However, in the above statement, one of the things which you desire is to modify the behavior when a "modifier" key is pressed so that a different keystroke is passed to the system. For this kind of change, a kernel extension is required.

In my mind this calls for an iokit driver kernel extension. (please correct me _now_ when there is a more elegant / user space way to achieve the same thing).

because of the change to the modifier key behavior, a kext is required.


On the face of it, the task doesn't look too daunting. It should be a simple matter of adapting the already available open source Apple keyboard driver. Looking around on the Apple dev web site didn't turn up (m)any clues about how usb keyboard input is handled, but downloading the USBFamily.kext code made things a little clearer.

the IOUSBHIDDriver.cpp code does show that the process point for the incoming report is with the


handleReport(_buffer) call line 1081.

At this point, the call takes you to the
IOHIDDevice::handleReport call in the IOHIDDevice.cpp file which is a part of the IOHIDFamily source. The actual processing of the keystroke is in the


IOHIDKeyboard::handleReport() call which is in the IOHIDKeyboard.cpp code.

Here you can see how the report is processed.

This should help get you started. What you should be able to do is implement a vendor specific driver for your keyboard modeled after the standard HID class driver. When the incoming report is received, you have a chance to inspect the bytes and twiddle them to make it appear that a keys were pressed or released.

For Tiger, a simpler mechanism will be introduced, but I don't have the details for this.

rich

From the code, and from using kextstat, it seems that generic usb keyboards are handled by the IOUSBHIDDriver kext, which is a 'plug in' to IOUSBFamily.kext.


So now my initial questions are:

- Is writing a kext driver the right way to go?
- If so, is there any example code for keyboard drivers
- When I complete my kext, should it be installed in the plug in folder of USBFamily
or can it remain at the top level of /System/Library/Extensions


I'm trying to figure out the flow of information from the hardware through the system, but I'm having some trouble digging up the correct documents. Any help is appreciated.

-- Sincerely, Rich Kubota email@hidden (408) 974-6212 _______________________________________________ Do not post admin requests to the list. They will be ignored. Usb mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/usb/email@hidden

This email sent to email@hidden
References: 
 >Keyboard Driver HowTo? (From: "P.V. Machielse" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.