This was a very cheap thing to hack together: the C64 was almost free from a garage sale, and I used an $8 Arduino Pro Micro from Aliexpress. I've seen people connect an Arduino directly to the keyboard output, but I wanted to try something using the user port, as it's a very cool feature of the C64. Also I don't have any way to load or save data on the C64 at the moment, so there wasn't much else I could do with it! (the first project probably should have been a tape adapter...)
Hardware-wise, I shared the USB and 5v C64 user port power, and connected the user port data lines from to 8 of the Arduino's pins, configured as digital inputs.
The Pro Micro can act as a USB keyboard (so that bit's easy), so all I had to do was 1) Write a 2 line BASIC program (As short as possible as I have to retype it on power on) that dumps a byte to the user port alternately for the currently pressed key and current modifiers (Ctr/Shift/C=), and 2) Convert the 8 data inputs back into a byte in the Arduino, work out the corresponding key pressed, and send it to the USB keyboard. Seemed responsive enough for any lag to be not really noticeable, but I'd like to give it a more thorough test. IThe data could be pushed to the user port quicker by an assembler loop, which would probably decrease the lag.
Connecting to the C64 was a bit Heath Robinson, as I don't have a proper user port edge connector and it's quite fiddly to build one. if I can construct a better edge connector or find a proper one I'll finish it off and take some photos.
Of course, configurable keys, macros, key combinations for nonexistent keys etc. would all be pretty easy to do in software on the Arduino.
Edited by galax, Sat Jul 12, 2014 2:51 AM.