I am considering connecting a ThinkPad X4x keyboard to a PC, using a programmable KeyWarrior keyboard controller in between the keyboard's ribbon cable and the USB cable to connect it to the PC. Not being an electronics guy, I checked back in the KeyWarrior forum and was told that this should work. The necessary parts are all easy to obtain, and I know how to use a soldering iron. ;-)
Anyway, everywhere I hear Arduino, and it would probably be worthwhile to learn about this universal microcontroller. Would it be possible to replace the KeyWarrior solution by an Arduino solution?
Note that the KeyWarrior16 supports two layers, for the FN key on the keyboard.
I now also opened a thread in the Arduino forum.
Answer
Yes. There are three things you would need to do. The first is the keyboard matrix. Keyboards are normally made using a matrix of outputs to inputs, where each key on the keyboard corresponds to one combination of in and out. 8x8 is a common matrix. Smaller phone keypads are an example of 4x3 and 4x4 matrixes, and are commonly used in Arduino projects.
The second part and third part are intertwined. The second part is the protocol to the computer. Serial, PS/2 or USB are common ones, with USB being the most recent (bluetooth as well, but that's wireless). Serial and PS/2 can be bitbanged, as can USB, but it is slightly harder. V-USB is a project for software USB implementation on ATTINY and ATTMEGA (like the arduino) processors.
The third part is the actual code between reading keyboard matrix, and sending it over usb. On the USB side you want a USB-HID keyboard (driverless on the PC side). On the keyboard side, you can use polling or interrupts. Your code would decide what matrix combination is what keyboard key, and what keyboard scan code.
The Function keys are essentially handled by software, same as the shift/control/option/command/windows key are. Your code would read the function key being pressed, then any other key being pressed would send the key+function scan code, instead of just the key scan code.
Simply googling "Arduino USB Keyboard" will give you a literal google of example projects doing as such. Also "Arduino Keypad".
No comments:
Post a Comment