Using a USB keyboard with your PS/2 port

There have been many discussions on this forum about whether/how to use a modern (i.e. USB) keyboard over PS/2. Recently, I built a little box that can help solve this problem. It’s a microcontroller that speaks PS/2 to the computer, and acts as a USB controller for your keyboard (and mouse).



It’s a hat for a Raspberry Pi Pico. The hat costs about $12 to build and a pico retails for $5. All the code and hardware is open source. I’ve built a half dozen of these and they work excellent for all the USB keyboards I’ve tested. They also work for mice, however the scroll wheel doesn’t work on some mice (there’s an open issue about this and a plan to solve it).

The advantage of using this device is that you don’t have to pass any USB devices to dom0, nor dedicate an entire USB controller for use with HID devices. For more info on this, see Device handling security | Qubes OS or search this forum.

My repo is at Public repos / Ps2x2pico · GitLab and the upstream repo is at GitHub - No0ne/ps2x2pico: USB keyboard/mouse to PS/2 interface converter using a Raspberry Pi Pico (I expect to get my contributions upstreamed soon).

This ps2x2pico project has been mentioned before on this forum, but up until now it required finding a male PS/2 connector and soldering it onto a level shifter board. The hat is easier to build and use in some ways, and certainly looks a lot nicer. :slightly_smiling_face:

To address some common questions: Most brand new desktop computers have PS/2 ports. If you don’t have a PS/2 port, then this post is not for you. The old purple USB → PS/2 adapters don’t work with modern keyboards. They are purely mechanical adapters which just jammed the USB pins into the PS/2 port. The keyboards would detect this and speak PS/2 over the same wires. It was actually pretty brilliant, but keyboards no longer ship with this functionality.

There are commercial devices that do the exact same thing as this Pi Pico and hat. For example, the https://tripplite.eaton.com/ps-2-to-usb-converter~0DT60002 which was mentioned in this thread. It costs $80 and is not open source.

Netiquette: I wasn’t sure about the etiquette of responding to old posts. I know many forums strongly prefer not replying to old posts and others have a slight preference for doing so because that’s what pops up when people search for the issue. I didn’t see this addressed in the welcome post. If any veteran Qubes Forum members have a suggestion on this, please let me know. I want to get people the answers they were looking for, but I certainly don’t want to spam people.

Other relevant posts on this topic:

14 Likes

This is a great idea! Do you think you could upload a step-by-step tutorial or even maybe a video showing how to build the device? I think dummies like me would definitely appreciate that:-)

5 Likes

Yeah, when I get more boards (they’re currently all soldered together) I can document soldering the hat and I’ll also work with the author of the software to keep improving the documentation on how to build and flash the Pi Pico.

3 Likes

Thanks for the information! Please give us an update when your changes are upstreamed. What did you change?

I agree with @absent clear docs and a soldering tutorial for idiots like me would be fantastic!

A device that supports 2 ports (mouse + keyboard) would also be nice.

i like this a lot. Thanks for the links.

Though, as with anything like this - please inspect any source code that you intent to plug into anything thats HID, folks!

5 Likes

Thank you for asking @hax0rbana_adam !

It feels better not to edit old topics. Yours stands out and will pop up in search anyway. Besides, your mention of the related posts already leaves a subtle cross-link in those older topics. :+1:

1 Like

@absent & @wilsonb I’ve put together some screenshots of the assembly process and would like to get your feedback on them. See the “build guide” below.

@wilsonb Yep, I will post back here when my changes get upstreamed. My changes were adding the KiCAD files for the hat and the FreeCAD files for the case. The main advantage of these contributions is that it eliminates the need to solder anything if you buy a hat, and whether you buy or build, it looks nicer. I have listed the hat and full adapter in my store and the artisans coop store (hat, complete adapter) if anyone in the US wants to buy them. I’m not dealing with international shipping & customs (sorry, not sorry).

The current device does support keyboard and mouse. If you have a combo PS/2 port, you’re all set. If you have separate PS/2 ports for mouse and keyboard, you’ll need a Y adapter. On the USB side, you’ll need a USB hub to connect multiple devices.

There is also discussion about a version of the hat which has two PS/2 ports, two USB-A ports, and two USB-C ports (if possible). The goal would be to eliminate the need for both of these adapters in all situations. It’ll require the Raspberry Pi Pico 2 and the main question is how to fit all of that onto the hat.

@Plexus Yep. I also suggest getting the version of the Raspberry Pi Pico that does NOT have wifi. There’s absolutely no reason to have that capability on this adapter.

Also, the hat is now certified open source hardware by the Open Source Hardware Association. So that’s cool.

Build guide

  1. Get the PCB made by a PCB shop (e.g. OSH Park)
  2. Buy the components (eight 0603 inch 10K ohm resistors, four BSS138 mosfets, one mini-DIN6 connector, and two 1x20 female headers)
  3. Surface mount solder the resistors and mosfets (per screenshots below)
  4. Solder the mini-DIN6 and female headers (per screenshots below)
  5. Your device should look like the photos below

Note: The “front” of the board is the side with the surface mount components. All components except the mini-DIN6 go on this side. The screenshots below come from the interactive BOM located here.

2 Likes

My contributions have been upstreamed. :partying_face:

4 Likes

Thank you for the guide. It is still pretty technical but I think I can follow…could you please provide the links for the components used e.g. PCB? I could not find immediately it in the shop OSH Park shop.
It is pity that the hat can be bought only in the US.

Components

I’ve updated the interactive Bill of Materials to include links on what components to buy and links to buy them on Mouser.

Thank you for pointing out that this information was hard to find. This information was in the KiCAD files, but now it’s more accessible.

PCB

As for the PCB, one needs to be manufactured on demand, which is the service OSH park (and others) provide. To get a PCB from them, you’ll have to upload the kicad/ps2_pico_hat.kicad_pcb file and they’ll show you what the board they will produce looks like before you check out.

There’s no requirement to use Mouser to buy the components, nor OSH Park to have PCBs made. These are just the companies I use.

Pre-made boards

I’ve been thinking about the implied question about international shipping. When I’ve shipped small, lightweight electronics things to Canada, it was about $25 and for a board that sells for $15 it feels really wasteful to be shipping these things around the world, both in terms of money and the environment.

But I also want people worldwide to be able to buy these. What to do?

I’m going to try to see if there’s a network of Makerspaces or Hackspaces that I can contact to help solve this problem. It’d be great if someone relatively local to you could make it. It’d be nice if they’d give me a dollar for making it and the author of the code a dollar for writing and maintaining the code, but that’d be entirely voluntary.

If you want to DM me contact info for your local Maker/Hacker-space, I can reach out to them and see if they’re interested in collaborating. I’m a member of my local Makerspace and I’m not aware of any site that has a bunch of open source designs and spaces which produce them. I feel like that should exist. And if it doesn’t, I’d be willing to chip in to help make it happen.

1 Like

For easier reference:

That will get you everything you need for the hat (well, I guess technically there’s also solder paste and solder core but if you were planning on soldering it together I assume you have access that and the equipment needed for assembly).

You’ll also need a Raspberry Pi Pico and a USB-micro (male) to USB-A (female) adapter. If you want to plug in a mouse in addition to a keyboard, you’ll need a USB splitter or hub too.

1 Like