Writing a keyboard device driver
I was wondering if anybody out there has had experience writing keyboard device drivers. I know the basics of how keyboard interrupts work however don't really know the details of everything. Is it difficult? Too difficult for one person?
I ask this because recently I purchased a Apple keyboard and the windows driver doesn't seem to recognize a lot of keys. Also if you know an easier solution to solve this other than writing a driver I would appreciate that as well. (I've already tried SharpKeys, seems like it's a windows driver problem that it can't reco开发者_StackOverflow中文版gnize certain scan codes)
Here is what you will need to write the device driver for Windows:
- An understanding of the wdf driver framework (KMDF) and its API's (I don't recommend WDM)
- http://msdn.microsoft.com/en-us/windows/hardware/gg463342
- http://msdn.microsoft.com/en-us/windows/hardware/gg463311
- A second PC (or Hyper-V) that you can use for kernel debugging. Download WinDbg and then remote debug the second machine. Do not try to write a device driver without a way to debug.
- A complete specification of the keyboard's software<->hardware interface. Maybe an expert can somehow infer the interface experimentally, but this could take ages. I think you'd have better luck reverse engineering the driver on the other platform.
If you can find the source for a very similar driver or the driver on another platform this might become doable, otherwise...
If you are interested in device drivers, try starting by writing a software-only driver. It will most likely be just a "toy", but you can do some really neat stuff in the kernel so maybe its worth having a toy driver. You can communicate between a user-mode .exe and your driver with an IOCTL. Maybe eventually you can update it into a software-only keyboard emulating driver, then try to upgrade it into the actual keyboard device driver that you want.
Found a thread about software-only keyboard drivers: http://www.osronline.com/showthread.cfm?link=119885
Maybe this is useful: http://www.osronline.com/ddkx/intinput/i8042ref_9eb6.htm
Update: Hyper-V is available for all Windows 8 users, and should largely eliminate the "second PC" requirement. You can run your driver on a VM and connect the kernel debugger to it.
精彩评论