3

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.

feklee
  • 1,301
  • 1
  • 16
  • 33

1 Answers1

7

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".

Passerby
  • 72,580
  • 7
  • 90
  • 202
  • 1
    The newer Arduino boards use a 'u' series atmega with a **hardware** not software USB interface, either as a converter (uno, mega) or as the main programmable device (leonardo). Software USB is possible on a regular atmega, but is not as robust. – Chris Stratton Mar 28 '13 at 01:58
  • Would PS/2 be easier to interface with? Because I need to add a PS/2-USB converter anyhow: The TrackPoint pointing device on the keyboard directly emits PS/2. – feklee Mar 28 '13 at 09:15
  • 1
    @feklee see this http://hunt.net.nz/users/darran/weblog/329aa/ but if you want to use a ps2 touchpad on usb, a cheap ps2 to usb adapter (like 1 dollar on ebay) is all you need for that. The keyboard is different because most older laptop keyboards are just the matrix, without a controller on board. That said, emulating ps/2 is easier than bitbanging usb-hid. See: http://arduino.cc/forum/index.php?topic=19224.msg140627#msg140627 and http://playground.arduino.cc/ComponentLib/Ps2mouse – Passerby Mar 28 '13 at 09:42
  • @feklee You will still need to make up the matrix scanning part, but you could plug it into the same usb-ps/2 adapter you'd get for the touchpad, since they normally have a keyboard and mouse input option. – Passerby Mar 28 '13 at 09:43
  • @Passerby Yes, I'm talking about the bitbanging part. Many cheap PS/2-USB adapters won't work, though, as they are only for devices that already speak USB. It's not a touch pad, by the way. – feklee Mar 28 '13 at 09:58
  • @feklee no, I don't mean the super small dongle (http://www.cablesdirect.com/prodimages/USB-PS2F_LR.jpg) those are just wire/pinout changers, I mean a usb to ps/2 adapter like http://www.lankalaptophouse.com/image.php?type=P&id=17961 which have a dedicated IC inside and should work with 99% of ps/2 keyboards and mice. – Passerby Mar 28 '13 at 23:25