Keyboard adapter v2?

Topics regarding the Uzebox hardware/AVCore/BaseBoard (i.e: PCB, resistors, connectors, part list, schematics, hardware issues, etc.) should go here.
rv6502
Posts: 80
Joined: Mon Feb 11, 2019 4:27 am

Keyboard adapter v2?

Post by rv6502 »

What if we added a resistor to the gamepad port / PS2 adapter and allowed pass-through by default?
Mouse Passthrough.png
Mouse Passthrough.png (72.95 KiB) Viewed 7730 times
We could use both gamepads AND mouse + keyboard (each one port) at the same time.

With a bit of "magic" we can autodetect if it's a keyboard or mouse. (I don't remember off the top of my head what commands they'll respond to ID)

Then have the ATtiny respond to keyboard (KB_SEND_KEY 0x00 / INPUT_SEND_END 0x01) or ( MOUSE_SEND_EVENTS 0x02 / INPUT_SEND_END 0x01)
We don't need a separate end code.
If it's not the attached device just respond with no key data / no mouse deltas & mouse buttons released.

The ATtiny needs to stay as an input on its data out port by default/after INPUT_SEND_END to let the gamepad data through the resistor.


It could even check the incoming gamepad data and re-detect or force a mode (kb or mouse if detect fails) depending on buttons held (SELECT+START+something) maybe??

What if we added a resistor on the clock & latch pins uzebox-side, the ATtiny could override the gamepad then read the real gamepads after the Uzebox is done. As long as we read the gamepad only once per frame on the Uzebox side it leaves lots of time to sneak in.
Mouse Passthrough2.png
Mouse Passthrough2.png (73.39 KiB) Viewed 7730 times
Could also emulates a snes mouse instead of sending collected PS/2 mouse status. (It can still override the gamepad and send gamepad data)
Or emulate an snes gamepad from the keyboard.

With that protocol and a bigger MCU we can have both keyboard and mouse on the same port. The ATtiny doesn't have enough pins for 2x PS/2 data streams tho.
So 2 gamepads (more with multitap), 2 PS/2keyboards, 2 PS/2mice possible.
Or 2 snes mice, 2 PS/2 mice, 2 PS/2keyboards
(4 player fly-swat game?)

And I think it'd still be backward compatible.


I wonder if we could bit-bang a USB host and use USB keyboards & mice off the ATtiny85 with the little memory it has. It'd be easier to find than PS/2 keyboards/mice.
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Keyboard adapter v2?

Post by uze6666 »

rv6502 wrote: Wed Oct 30, 2019 3:13 pm What if we added a resistor to the gamepad port / PS2 adapter and allowed pass-through by default?
We could use both gamepads AND mouse + keyboard (each one port) at the same time.
At first view that could work. Would be *much* simpler than my keyboard adapter V2 (that I never published). I wanted to have both ports and the keyboard at the same time for my Uzebox retro computer. So I'll have to test that. :)
With a bit of "magic" we can autodetect if it's a keyboard or mouse. (I don't remember off the top of my head what commands they'll respond to ID)

Then have the ATtiny respond to keyboard (KB_SEND_KEY 0x00 / INPUT_SEND_END 0x01) or ( MOUSE_SEND_EVENTS 0x02 / INPUT_SEND_END 0x01)
We don't need a separate end code.
If it's not the attached device just respond with no key data / no mouse deltas & mouse buttons released.

The ATtiny needs to stay as an input on its data out port by default/after INPUT_SEND_END to let the gamepad data through the resistor.


It could even check the incoming gamepad data and re-detect or force a mode (kb or mouse if detect fails) depending on buttons held (SELECT+START+something) maybe??

What if we added a resistor on the clock & latch pins uzebox-side, the ATtiny could override the gamepad then read the real gamepads after the Uzebox is done. As long as we read the gamepad only once per frame on the Uzebox side it leaves lots of time to sneak in.
Without getting into the code again, this is over my head. :?

I wonder if we could bit-bang a USB host and use USB keyboards & mice off the ATtiny85 with the little memory it has. It'd be easier to find than PS/2 keyboards/mice.
Sure can, check https://www.obdev.at/products/vusb/index.html. Runs on an AVR with at least 2 kB of Flash and 128 bytes RAM. And it's a very good point, nice PS/2 keyboards are getting real hard to find these days.
User avatar
danboid
Posts: 1937
Joined: Sun Jun 14, 2020 12:14 am

Re: Keyboard adapter v2?

Post by danboid »

Did you ever try this rv6502 or anyone else?
rv6502
Posts: 80
Joined: Mon Feb 11, 2019 4:27 am

Re: Keyboard adapter v2?

Post by rv6502 »

I haven't had time to get back on Uzebox stuff.
Finishing some non-Uzebox projects first, won't have time to play with that for a little while sadly.
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Keyboard adapter v2?

Post by uze6666 »

As I mentioned back on that thread, I've made a revision to the Keyboard interface and its firmware. I can say it greatly eased the development of the last firmware version. I'm uploading the Gerbers, schematic and firmware here for those interested. I'm reworking the download section of the site which will be moved over to Github eventually. Have the keyboard interface made (and the Uzenet interface), it's worth it. ;)
Attachments
KeyboardFirmware.hex
(1.03 KiB) Downloaded 117 times
keyboard-adapter-V1_2-2022-09-20b.zip
(68.27 KiB) Downloaded 120 times
User avatar
Artcfox
Posts: 1382
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: Keyboard adapter v2?

Post by Artcfox »

Does this have a passthrough for a regular gamepad, or does it use the ICSP header to avoid that, or is an either or thing (keyboard or gamepad plugged in)?
User avatar
danboid
Posts: 1937
Joined: Sun Jun 14, 2020 12:14 am

Re: Keyboard adapter v2?

Post by danboid »

What Artcfox said plus is the ATMega85 the same as the ATTiny85?
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Keyboard adapter v2?

Post by uze6666 »

You can either build a little adapter like pictured or embed it directly in a PS/2 keyboard with an SNES cable going out. In both cases it plugs in the P2 port and does not interfere with P1 port. It uses just an ATtiny25/45/85 and a couple resistors. Internally in runs at a zippy 16Mhz using the PLL. Very inexpensive too, you can have the pcb built and shipped at JLCPCB for under 10$.
Attachments
kb_adapter.jpg
kb_adapter.jpg (36.98 KiB) Viewed 1456 times
User avatar
Artcfox
Posts: 1382
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: Keyboard adapter v2?

Post by Artcfox »

Very nice!!
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Keyboard adapter v2?

Post by uze6666 »

Very nice!!
Thanks! :P

To answer the OP, I did something like that 5 years ago (time flies!). It would have allowed to have both the P2 and keyboard on the same lines and switch between the two in software. I started working on the firwmware but the mouse gave me trouble if I recall. So it kinda fell into oblivion. Perhaps if someone gets a great project going on using a PS/2 mouse it could be revived.
Attachments
kb_mouse_adapter.JPG
kb_mouse_adapter.JPG (109.46 KiB) Viewed 1434 times
Post Reply