No0ne / ps2x2pico

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

Mouse issues when using PS/2 to USB adaper #29

Closed naplesap closed 2 weeks ago

naplesap commented 3 months ago

First of all, love this project. I've used it numerous times on PiKVM v2 but now I'm running into a unique issue. I have a device that has independent USB mouse and keyboard inputs. I used the Pico HID to convert the HID to PS/2, then two independent PS/2 > USB adapters to convert back to USB. Is there an easy way to tweak the code to allow the Pico to just isolate Keyboard from Mouse and output to two separate USB-A? Forgive my lack of coding knowledge.

My problem when using Pico Bridge on PiKVM v4+ is when converting the PS/2 mouse back to USB the screen scrolls when I move the mouse up and down as if I am holding down a scroll wheel or mouse button.

image

No0ne commented 3 months ago

Hi, thats an interessting usecase! I think this should be possible using this project: https://github.com/sekigon-gonnoc/Pico-PIO-USB

You only would need a Pico, four 22 ohm resistors and two USB-A plugs. Do you have this on hand for testing?

Which PS/2 to USB adapters are you using? Maybe I could fix the mouse wheel issue.

naplesap commented 3 months ago

I only currently have 4.7k ohm and 390 ohm resistors on hand, however I could easily order 22 ohm. I've tried both of the following PS/2 > USB adaptors with the same result:

https://www.amazon.com/gp/product/B00IACID2C/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1 https://www.amazon.com/gp/product/B00028OP2Y/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&th=1

naplesap commented 3 months ago

I have ordered 22 ohm resistors that should be here in about 12 hours. I appreciate your help.

To clarify, this is the setup I have with my PiKVM v2 and it works perfectly. My issue is that the V4 plus does not have the GPIO pins that the RPi4 has. image

No0ne commented 3 months ago

And the mouse wheel issue is exactly the same with both PS/2 adapters?

naplesap commented 3 months ago

And the mouse wheel issue is exactly the same with both PS/2 adapters?

Yes, the issue is exactly the same.

No0ne commented 3 months ago

I ordered the startech one so I can reproduce/fix that.

naplesap commented 3 months ago

I think this should be possible using this project: https://github.com/sekigon-gonnoc/Pico-PIO-USB

You only would need a Pico, four 22 ohm resistors and two USB-A plugs. Do you have this on hand for testing?

I'm going to test this in a few hours. Do you happen to know if there is a video or instruction manual for the Pico-PIO-USB?

No0ne commented 3 months ago

This is mainly a library and not a finished project. You could take a look in the examples folder I guess. I'll be able to try a pikvm integration after the easter holidays.

No0ne commented 3 months ago

Got the Startech adapter today, tested it and it works fine. 😲 Maybe there was a fix since the last release, I'll build you a custom pikvm version with the 1.0 pre-release.

naplesap commented 3 months ago

Got the Startech adapter today, tested it and it works fine. 😲 Maybe there was a fix since the last release, I'll build you a custom pikvm version with the 1.0 pre-release.

That is far too kind of you. I really appreciate that. In the meantime I'm going to try to tinker with the Pico PIO USB and see if I can get that to work. Thanks again!

No0ne commented 3 months ago

I asked if it is possible to generate two devices via the PIOs as I saw no obvious way to do so: https://github.com/sekigon-gonnoc/Pico-PIO-USB/issues/114

No0ne commented 3 months ago

pico-hid-1.0-pre.zip Please try the Startech adapter on the mouse port with pikvm and this pico hid 1.0 pre-release attached.

naplesap commented 3 months ago

Testing it now and the issue seems to be the same. If i move the mouse up or down slowly the cursor barely moves but the page in the background seems to scroll insanely fast.

No0ne commented 3 months ago

Did you also update pikvm it self via [root@pi4kvm ~]# pikvm-update ? Which browser/OS are you using on the host system?

naplesap commented 3 months ago

Did you also update pikvm it self via [root@pi4kvm ~]# pikvm-update ? Which browser/OS are you using on the host system?

I just updated to the latest pikvm version. I'm using Win11 and Chrome Version 123.0.6312.59 (Official Build) (64-bit)

No0ne commented 3 months ago

hid-no-wheel.zip Please try this, it forces a two button mouse without wheel.

naplesap commented 3 months ago

hid-no-wheel.zip Please try this, it forces a two button mouse without wheel.

I've tried this too, and it still seems to be doing the same thing. I'm stumped. The little top mouse icon in the top-right flashes green and orange whenever I move the cursor, too.

No0ne commented 3 months ago

The flashing icon is correct as it indicates the bus busy state. Does it still scroll? The simulate mouse should not have a wheel at the moment. Are you shure the uf2 is on the pico? Do you have a usb serial adapter or another pico you can hook up to the serial tx pin? I could build you a serial debug version for further testing.

naplesap commented 3 months ago

Does it still scroll? The simulate mouse should not have a wheel at the moment. Are you shure the uf2 is on the pico? Do you have a usb serial adapter or another pico you can hook up to the serial tx pin? I could build you a serial debug version for further testing.

The mouse wheel no longer works but it is somehow still scrolling when I move the cursor. I made sure to run [flash_nuke] before installing the latest uf2. I do have a spare pico.

No0ne commented 3 months ago

Does the scrolling still happen if you plug the Startech mouse into a laptop?

naplesap commented 3 months ago

Does the scrolling still happen if you plug the Startech mouse into a laptop?

It seems to work fine when connected to a PC

No0ne commented 3 months ago

🤔 Do you have a real PS/2 mouse? What happens if you connect it to the Startech and then to your device?

naplesap commented 3 months ago

🤔 Do you have a real PS/2 mouse? What happens if you connect it to the Startech and then to your device?

I do not have an actual PS/2 mouse

No0ne commented 3 months ago

If you try pico-hid-1.0-pre.zip with the Startech and PC does scrolling work normal?

naplesap commented 3 months ago

If you try pico-hid-1.0-pre.zip with the Startech and PC does scrolling work normal?

This seems to work and scroll normal on PC

naplesap commented 3 months ago

Is there any way possible to maybe use PS/2 keyboard simultaneously with the pikvm HID mouse output?

No0ne commented 3 months ago

This seems to work and scroll normal on PC

Ah so thats why I wasn't able to reproduce the problem.

Is there any way possible to maybe use PS/2 keyboard simultaneously with the pikvm HID mouse output?

You mean on the pikvm v4 without gpio?

naplesap commented 3 months ago

Is there any way possible to maybe use PS/2 keyboard simultaneously with the pikvm HID mouse output?

You mean on the pikvm v4 without gpio?

Yes. I'm at a unique crossroads: My device has a video output of 1920x1080 60hz so I cannot get video on pikvm v2 but the mouse works perfectly. On V4 the video works but I'm having the mouse issues. haha

No0ne commented 3 months ago

@mdevaev should know that

mdevaev commented 3 months ago

Is there any way possible to maybe use PS/2 keyboard simultaneously with the pikvm HID mouse output?

No, right now it's not possible.

No0ne commented 2 months ago

Maybe I can adapt this so it works over the serial port. After removing the yellow jumpers this would connect to GPIO20+21 on the Pico (the usb-c serial labeled IOIOI wont work anymore). Then it should work like on the V2 but via serial instead of SPI.

@naplesap Do you also have this header on your V4? I only have the mini.

naplesap commented 2 months ago

image Hey, sorry for the delayed reply. I was out of town for a couple days. Yes, my v4+ does have the header shown in the picture.

naplesap commented 2 months ago

However it appears they're used to connect to the top board: image image

No0ne commented 2 months ago

Ha, this is working, just tested on my v4 mini! :) For testing you have to leave the top board disconnnected as it routes the serial thru the RS232 converter to the RJ45 jack.

Jumper Pico GPIO22, 2 and 3 to GND (remove any other jumper). Connect the Pico as shown in the photo bellow: screenshot

Add the following to your /etc/kvmd/override.yaml:

kvmd:
    hid:
        type: serial
        device: /dev/ttyAMA0
        reset_pin: -1

Remove the following from your /boot/cmdline.txt:

console=serial0,115200

Reboot, and then you should have a PS/2 keyboard an USB mouse.

naplesap commented 2 months ago

Ha, this is working, just tested on my v4 mini! :) For testing you have to leave the top board disconnnected as it routes the serial thru the RS232 converter to the RJ45 jack.

Add the following to your /etc/kvmd/override.yaml:

kvmd:
    hid:
        type: serial
        device: /dev/ttyAMA0
        reset_pin: -1

Remove the following from your /boot/cmdline.txt:

console=serial0,115200

Reboot, and then you should have a PS/2 keyboard an USB mouse.

Just to confirm, I would use pico-hid.uf2 on the pico, correct?

No0ne commented 2 months ago

any of the uf2 should work, try the offical first

No0ne commented 2 months ago

Just came to my mind: on the v4+ you can also use a USB serial adapter, so we don't have to connect to the internal serial port. (which would solve the top board connection problem)

naplesap commented 2 months ago

Ha, this is working, just tested on my v4 mini! :) For testing you have to leave the top board disconnnected as it routes the serial thru the RS232 converter to the RJ45 jack.

Jumper Pico GPIO22, 2 and 3 to GND (remove any other jumper). Connect the Pico as shown in the photo bellow: > Add the following to your /etc/kvmd/override.yaml:

kvmd:
    hid:
        type: serial
        device: /dev/ttyAMA0
        reset_pin: -1

Remove the following from your /boot/cmdline.txt:

console=serial0,115200

Reboot, and then you should have a PS/2 keyboard an USB mouse.

IT WORKS!!!! This is huge!! You have no idea how grateful I am!

No0ne commented 2 months ago

Cool! I closed the issue with the two PIO USB devices then.

May I close this one too?

naplesap commented 2 months ago

Yes. Thank you so much for all of your help. It’s greatly appreciated. I’ll dig out the micrometer to see if I can plug this into the USB-C or RJ-45 ports.

No0ne commented 2 months ago

On the USB-C port: No, theres a CP210x in the way!

On the RJ45 port: Maybe, theres a MAX232 in the way. You would need another MAX232 and four 10μF.

The easiest would be another pico connected via USB running this: https://github.com/Noltari/pico-uart-bridge And then connect GPIO16/17 from this to GPIO21/20 on the existing pico.

naplesap commented 2 months ago

On the USB-C port: No, theres a CP210x in the way!

On the RJ45 port: Maybe, theres a MAX232 in the way. You would need another MAX232 and four 10μF.

The easiest would be another pico connected via USB running this: https://github.com/Noltari/pico-uart-bridge And then connect GPIO16/17 from this to GPIO21/20 on the existing pico.

IMG_3553 Ending up taking the easy route and just drilled a hole into the side of the case and ran the wires directly to the main board.

Also, one minor thing I noticed. When I use the Text function on PiKVM to paste a large string of characters the output seems to glitch and I have to unplug and replug the USBs from the client in order to get it working again.

No0ne commented 2 months ago

Ok I will look into the paste feature!

No0ne commented 1 month ago

I checked that, it works if I make the output queue larger, but I don't know how much memory this needs on the pico. How many character would you like to paste?

No0ne commented 2 weeks ago

Please open a new issue if you are still interested.