As I type this the keyboard in my thinkpad t60 is going, so all these keyboard projects are good. I found that the guy who created the firmware I’m using to interface the ibm 122 key to my computer also developed one that will take a raw matrix and use the same great config file structure to create a usb keyboard. There are a bunch of options for debouncing, blocking, scanning, and even muxing inputs and outputs to use a matrix larger than the free number of pins on the ’32u4 (or just use the existing hardware in the keyboard). This project was essentially a proof of concept for my arcade machine keyboard controller so now that this works I can start designing and wiring up the matrix for that.
The first thing I did was get the pinout for the keyboard matrix, then I found that one key is not part of the matrix, so I threw it on one of the rows and made it a new column with undefined keys below it. Now I have to define a key matrix in the config file, no problem. I just looked at the documentation, copied an existing config file and went to town. Some of the keys were in interesting since either the closest key didn’t exist, or I had used it elsewhere I had to use dummy keys. I chose the “LANG_#” keys since I figured even if one of the keycdes got through the OS would just shrug and forget about it.
The macros I was good at this time around, once I decided what I wanted the keys to do it was just a matter of writing up the commands and bracketing them wit a macroblock. Enter problem number one, the macroblocks have a fixed length. I didn’t bother to figure out how many macros could go in one block, I just broke them up into logical blocks and then it worked.
The next one I encountered was that for some reason the PD0 and PD1 pin (arduino D3 and D2) didn’t like being used for scanning. I don’t know what about them but when I moved to PF1 and PF0 everything went smoother. For this project I used the olimex-32u4(since the board doesn’t matter, just the mcu) and I decided to cut all the LED jumpers (there are 3) just to be safe.
Now I had a matrix, being read reliably, outputting scancodes more or less properly. There was still a problem with some keys’ shifted functions not working properly. I bumped my macro block for the shifted chunk above the general re-maps and that cleared right up.
To sum up the config file: all keys do more-or-less what they say on top. The odd F-keys are the main buttons, the even ones are done by holding down the commodore key (windows key). The british pound key is the backslash/pipe key. My favorite mod was making the “wasd” keys into the arrow keys (since the commodore arrow keys are a mortal sin) using the windows key.
That’ it. I now have a working commodore 64 keyboard as a usb keyboard. The project this is for isn’t quite a secret, but despite hackaday’s warning I’m not posting about it just yet.
my config file: here