No0ne / ps2x2pico

USB keyboard/mouse to PS/2 interface converter using a Raspberry Pi Pico
MIT License
196 stars 35 forks source link

[feature request] PS2 input repeating #24

Open Gouster4 opened 4 months ago

Gouster4 commented 4 months ago

Hello. I would like to use this project on my KVM which is almost older than me and has only PS2 port. But i would also like to keep my RKM working, which has ps2 output.

Can you please make optional PS2 input, so it can repeat PS2 input and also convert USB to PS2? This way i can connect both USB keyboard and PS2 keyboard to raspberry, and use both inputs. Maybe it will cause issues when used simultaneously, but otherwise it should be ok. Thank you.

No0ne commented 4 months ago

Yes! In fact I'm already working on it because of this related issue: https://github.com/pikvm/pikvm/issues/476

I'm experimenting with an 8-channel level shifter, but I think I got the wrong part wich isn't suitable for open-drain circuits. But I can always use two 4-channel ones. I'll keep you updated if I made progress!

Gouster4 commented 4 months ago

Thats awesome. Thank you.

Now bit unrelated question, but dont want to open new issue report. I would also like to know if this project can run on rp2040 zero with 2M flash. Thank you, and sorry for unrelaedd question.

No0ne commented 4 months ago

I think this should work with any rp2040 board. Maybe you have to compile it with your own different GPIOs.

Gouster4 commented 4 months ago

Awesome. I would rather re-route cables from controller to level converter to keep gpio pins same if possible. I would like to prepare my hardware for PS2 passtrought, do you have already plans which gpio pins you will use for ps2 input once you implement ps2 passtrought? Are there also some specific requirements for pin capabilities for data or clock? Or basically any gpio pins can be used? Because im not sure about raspberry, but arduino doesnt have all pins same, for example some does support PWM, some not, thats why im asking. Thank you.

Gouster4 commented 4 months ago

Can you comfortably use pins between gpio0 and gpio10? Because those are present and easy accessable also on zero version. Basically 0-15&26-29 are easy accesable, 17-25 are still accessable but requires precise soldering on small solder pads with small gaps between, but still good enought. GPIO 16 is missing. I think, if usable, then requires microscopic soldering to chip/soc itself.

If it wouldnt be possible to confortably use gpio0-15 pins, there is still way to chagne gpio and compile for myself. But its easier to be up-to-date when using releases.

gpio 11-15 used as ps2 output are easy accessable on zero version without any issues. So thats perfect. Luck for users with zero version, because i cannot imagine changing existing pins in this project when lot of people have already soldered those exact pins to support releases instead of compiling themself.

Just let me know how did you decided. Its not a big deal for me to change gpio and compile, but if it would be possible to use gpio0-10 and still keep it good looking on pico board, it would be way easier for all users with zero version.

Thank you

No0ne commented 4 months ago

Sure, I corrected this for PS/2 input:

                   _________________
                  |                 |
 Pico GPIO3 ______| LV1         HV1 |______ PS/2 keyboard data
 Pico GPIO4 ______| LV2         HV2 |______ PS/2 keyboard clock
 Pico GPIO5 ______| LV          HV  |______ PS/2 5V + Pico VBUS
 Pico   GND ______| GND         GND |______ PS/2 GND
 Pico GPIO6 ______| LV3         HV3 |______ PS/2 mouse data
 Pico GPIO7 ______| LV4         HV4 |______ PS/2 mouse clock
                  |_________________|
Gouster4 commented 4 months ago

Awesome. God bless you. Thats just perfect. Once i recieve logic converters, i will let you know about RP2040 zero compatibility. I can make some photos then.

No0ne commented 4 months ago

I've cobbled together the first prototype: only keyboard is working at the moment and also only one data direction, meaning the leds, typematic and other settings on the keyboard don't get set.

Please try this: https://github.com/No0ne/ps2x2pico/raw/24-ps2-input/ps2x2pico.uf2

I also added two 3.3k pull-up resistors from HV1 to HV and HV2 to HV as the built-in 10k from the levelshifter might be too weak for your keyboard, you'll have to try it out.

Gouster4 commented 4 months ago

Thank you. Im still waiting for levelshifters. But maybe i can prototype my own temporary level shifter from pocally available components to test it.

No0ne commented 4 months ago

You can try to run your keyboard on 3.3 Volts, maybe it works. Then you don't need a level shifter, only two pull-up resistors.

No0ne commented 2 months ago

Did you have time to try it out?

Gouster4 commented 2 months ago

Did you have time to try it out?

Sorry. I went to work trip, and im out of my tech for a while. Only access i have is remote services running at my server.

But in about 2 weeks i will be at home. And i already recived bunch of level converters, which my wife picked up. So, once i get home im ready to test it.

Gouster4 commented 2 months ago

Finally got home, and put that together. Keyboard is working exaclty like you described. Do you plan to add mouse support, and keyboard leds support.

Thank you.

EDIT: Im using KVM switch with RKM (rackmounted keyboard+mouse+monitor). There was ball mouse, and i replaced it to touchpad from some old laptop. Keyboard does work as expected. Touchpad is working when directly connected to device´s PS2 port, but doesnt work trought KVM, but ball mouse was working trought KVM. So my guess is some incompatibility between touchpad and KVM. Can you please implement also some "protocol simplificator" or whatever to increase compatibility? If so, is there any way to catch touchpad data for futher investigation?

Interesting is that touchpad was working without any special drivers in PS2 port. So my guess is that it is somehow in PS2 specs, but uses some advanced part of spec that KVM doesnt like.

No0ne commented 2 months ago

Thats cool to hear, yes I'll add mouse passthru support as I also need it for the PiKVM integration.

For the other issue, please post a diagram which devices are connected how.

Gouster4 commented 2 months ago

lease post a diagram which devices are connected how.

Awesome. My plan is also to use PiKVM, but old X86 unofficial release of PiKVM as VM on my main server, with USB-Uart adapter (keyboard+mouse from PiKVM VM to KVM switch) adapter and Video Grabber passed trought to VM.

Currently, im using Belkin´s Matrix2 KVM, HP RKM and bunch of Servers. On that HP rkm, i replaced ball mouse to some random touchpad from some broken laptop.

HP RKM(with replaced ps2 touchpad) -> Belkin´s Matrix2 KVM -> HP DL380p Server.

Before touchpad replacement, it was working. Now im using ps2 mouse instead, and i have connected touchpad with PS2->USB converter directly to Server, as KVM doesnt like it.

For future, i would like to integrate ps2x2pico into KVM case like cutting wires on original ps2 connector of keyboard/mouse input, and connecting it trought ps2x2pico, and add 3 usb ports (2 TypeA connected to USB hub which connects to ps2x2pico, and 3rd typeC (for PiKVMx86) which would be connected to USB hub, where video grabber card and usb-uard bridge would be connected.) so, it would be like this: HP RKM(with replaced ps2 touchpad) -> ps2x2pico ->Belkin´s Matrix2 KVM -> HP DL380p Server.

No0ne commented 2 months ago

Ah yes now I understand. It will most certainly fix the touchpad problem as the PS2 input and output are isolated, as in no bytes travel directly from in to out. The PS2 input rather controls the virtual mouse created on the PS2 output, same as the USB input events do.

Gouster4 commented 2 months ago

It will most certainly fix the touchpad problem as the PS2 input and output are isolated, as in no bytes travel directly from in to out. The PS2 input rather controls the virtual mouse created on the PS2 output, same as the USB input events do.

Thats awesome. Thank you. Looking forward for mouse support. 👍

No0ne commented 2 weeks ago

Sorry, took me a bit longer to find time for this 😯 Try this, now keyboard and mouse should work: ps2input.zip

Gouster4 commented 2 weeks ago

Sorry, took me a bit longer to find time for this 😯 Try this, now keyboard and mouse should work: ps2input.zip

Thank you so much. I'm on work trip again, but I will be at home in about two weeks, so will definitely test this out. Looking forward to test it.

Is this with PiKVM support on RX&TX pins included or without?

No0ne commented 2 weeks ago

I currently have a pull request open for this: https://github.com/pikvm/kvmd/pull/171 Yes I tested this with the pico hid bridge over usb and it should also work over spi and serial.

No0ne commented 2 weeks ago

But the pinout is different (uses 26+27 and 16+27) so for rp2040 zero we'll have to compile a custom pico hid bridge.

Gouster4 commented 2 weeks ago

I currently have a pull request open for this: pikvm/kvmd#171 Yes I tested this with the pico hid bridge over usb and it should also work over spi and serial.

Nice. I will then make a fork, try to merge it, and keep current pin Configuration and build.