Page 1 of 1

Pluggy Keyboard Interface Specification?

Posted: 23 May 2021, 14:13
by sajattack
Hi there, I'm trying to bring menloparkinnovation's aforementioned FPGA core to a popular FPGA platform for retrogaming, called the MiSTer project. https://github.com/MiSTer-devel/Main_MiSTer/wiki

As part of this process, I'm trying to add keyboard support, and I'm having trouble grokking the pluggy mcplugface arduino code. Could you give me a high-level specification of "given these ps/2 scancodes -> output these hex bytes to the joyport"? I've tried putting the ps/2 scancodes through raw, and tried ascii as well. The code looks like maybe it's ascii plus a few flags? If anyone has good documentation on this I would be very appreciative.

Re: Pluggy Keyboard Interface Specification?

Posted: 24 May 2021, 20:27
by sajattack
I found my mistake with the ascii, I had the bits backwards and inverted xD. But I would still like to know more about the flags.

Re: Pluggy Keyboard Interface Specification?

Posted: 24 May 2021, 21:12
by at67
PS2.ino does all of the keyboard encoding/decoding, have you studied this file?

Re: Pluggy Keyboard Interface Specification?

Posted: 24 May 2021, 21:20
by sajattack
Yeah I looked at the code but it wasn't very clear to me.

Re: Pluggy Keyboard Interface Specification?

Posted: 24 May 2021, 23:48
by at67
sajattack wrote: 24 May 2021, 21:20 Yeah I looked at the code but it wasn't very clear to me.
If you look at the keymaps[] array, (which is an array of keyTuple_t structs), and the lookup() function, you can see that code performs a linear search of the keymaps[] array to convert locales, modifiers and PS2 scan codes into ascii codes.

If you want to start simple, ignore the locales and modifiers and just use a look up table to convert the code field, (PS2 scan code), of the struct to the ascii field of the struct.

e.g. for '!' you would convert 0x16 to 33, for '0' you would convert 0x45 to 48.