26

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 recognize certain scan codes)

3
  • You could try to see if it's possible to use the drivers bundled with BootCamp. Commented Aug 20, 2010 at 2:30
  • I thought BootCamp wasn't free? Commented Aug 20, 2010 at 18:12
  • 6
    Terrible suggestion, how would anybody learn anything. Commented Aug 12, 2012 at 22:56

1 Answer 1

21

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)
  • 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.

Sign up to request clarification or add additional context in comments.

1 Comment

"I think you'd have better luck reverse engineering the driver...". How would I do this for a Huawei MateBook X Pro's keyboard driver? I've always been interested to learn driver programming so I'd like to attempt this as a learning experience, but also to tweak a few things that I don't like about the native driver. Would it be very difficult for someone with intermediate-level C++ knowledge, but no driver or kernel experience whatsoever?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.