Either I am looking in the wrong places or nobody has done this before.
What I am looking for is a way to read a USB keyboard that is attached to an extra USB port (as in the examples with D- and D+ to two/three? ports) and then write a matrix code to output.
To explain what I am trying to do in more detail. The old Sinclair ZX computers have a matrix keyboard.
For example the ZX81 has a 5x8 matrix. Five lines are selected one by one and pulled low over and over again. The pressed key pulls one out of 8 columns low. Shift key is special as it is the switch for the first bit only.
These membrane matrix keyboards tend to breakdown, their life expectancy is lower than 30 years :-)
So I'd like to find some way of using a standard USB keyboard instead.
I see several challenges:
1. Reading the USB keyboard. Looks like the USBHost library cannot be used for this???
2. Reading 5 lines (5x8 matrix) from the old retro computer line-select output (via interrupts), then if a character was received from the keyboard, translating it into 8 bit output. Should be doable as I know exactly which key is on what location, for instance if the current line is the first one, and a key '3' has been pressed without shift, then I can send a 00010000 byte, the first bit being shift. If the key was shift-3 (like '#' on some keyboards) then send 10010000.
3. Probably I got a shortage of ports on the Uno, if 3+5+8 are needed. Perhaps a way to feed a shift register with 8 bits output through one/two ports?
Or use the chipKIT Max32 that I have for this, hmmm lots more ports.
4. Somehow adjust to the timing factors of the old computer (keyboard repeats? control-shift-alt combinations?) and utilize buffers from the USB keyboard...
Of course the timing from the interrupts has the most important role. But I suspect the USB keyboard works with keypresses and releases, that might complicate things?
Can you guys please advise.
Regards, Martin