Electronic – How to have custom keyboard scancode set

encoderkeyboard

I'm new to the hardware field in general. For one project I'm trying to create a custom keyboard that will have some extra keys, say 20-25 more than a standard keyboard. I've read about scan codes and scan code sets. I've also read about keyboard encoders, controllers etc. at pages like these:

http://retired.beyondlogic.org/keyboard/keybrd.htm

http://www.computer-engineering.org/ps2keyboard

But still I'm not clear which encoder will allow me to generate a custom scan code that is not defined in any standard scan code sets. Also will the standard keyboard controller (8042 compatible) in a PC process these non-standard scan codes?

Best Answer

Atmel (and Microchip too I think) has a generic HID driver for their MCUs available, with full sourcecode at each end available (Client test software, and embedded HID stack).

Browsing Atmel's offering, they even have a full-blown keyboard demo board, again with source code.

It's not the simplest example (They've written their own task scheduler!), but I think it should be pretty easy to mod to do what you want.

Look in keyboard_task.c on the above links keyboard demo (or here). It seems to be exactly what you want. A great big array of scancodes, being used to write a message to the computer by emulating a keyboard into any text editor.

The actual HID keystroke values are abstracted away using #define into a file called usb_commun_hid.h, which seems to be not(!) included in the above download (I guess it comes with the compiler?), but they just map to plain old single byte values, so you should be able to add more all you want. (See the a00102.html file in the above link.)

I would image Microchip has something similar, but I don't feel too much like digging through their implementation right now. If you want, I may be able to do so later.

Of course, this doesn't really do anything about how you're decoding these scancodes at the computer end, but again, Atmel does have .Net examples of how to talk to their HID devices, so something hackable should be available.