One program runs on a Linux desktop and listens to input events from the Linux input subsystem (evdev). When you press a specific key, it will start consuming all events and sending them over USB serial to a RPI Pico. Pressing the key again will toggle back into passive listening mode.
The RPI Pico is programmed to receive Linux evdev events over serial, translate them into USB HID events and send them to another Windows PC.
The end result is a KM switch that switches instantly between a Linux PC and a PC running an OS of your choice.
As a hardware noob, needing only 2 wires was a huge relief and I think this is a great starter project for other hardware noobs.
Both programs were < 100 LOC. There are tons of Rust crates and python packages to listen to Linux evdev. The program on the Pico was quite simple too, basically just a loop with a big switch statement and there are Rust crates to send USB HID events. You can use COBS to send stuff over serial without worrying about framing.
Ultimately I never ended up open sourcing it because of some USB serial bugs (it would not reconnect properly to the Linux desktop after getting disconnected). Not sure if it was because of Linux or the Pico. I still use it, the bugs aren't a problem because I never disconnect the wires.
I also specifically left out the absolute mouse feature since I play a lot of FPS games and it wouldn't work with those. I have the switch key bound to a button on the side of my mouse anyway so I can switch systems without even touching my keyboard.
That's an awesome idea, man. I wish I thought of that.
I learned about about that screen hopper project only yesterday, and it just confirmed my theory - whatever I try to do, somebody smarter than me already made, only better, smoother running and with nicer features :)
I play no games whatsoever so absolute coords would be perfectly fine, but one of the items on the to-do list is to make it configurable.
IMO the hardest part of open source is documentation and packaging so hats off to people like you who take that final step from tinkerer's project to open source! Also props to you for the galvanic isolation and actually designing a circuit lol.
I'm sure there's even more keyboard/mouse switching projects out there, there's just no good acronym or search query to find them. You could search for "KVM" but it's just dominated by PiKVM. We should really standardize on something for the SEO.
Your project is practically an example for Teensy boards. I made this exact gadget 10 years ago :)
Ultimately my friend was explaining his 'mouse jiggler' vbscript and I thought 'how can I make this a hardware version' this led to a design and once you have a design it is easy to query google for design hints at the component level "usb hid microcontroller" "usb passthrough [teensy|arduino]" "usb init host controller [teensy|arduino]" "mouse path [teensy|arduino]" etc etc
Many FPS games move the camera by listening to relative mouse movements and moving your camera a corresponding amount, while keeping your cursor hidden and in the center of the screen. Absolute movements cause different issues depending on the particular game.
I am not familiar with HID but I assume there is a way for the computer to provide feedback to the input device about the cursor’s current position. If that’s correct, it could probably be done with relative movements just fine.
I'm not very versed in gaming, so have very little knowledge about what games want. It should be possible to implement a relative mode too and some way to switch between the modes so when working use absolute, when playing use relative.
My own version of this consists of two programs.
One program runs on a Linux desktop and listens to input events from the Linux input subsystem (evdev). When you press a specific key, it will start consuming all events and sending them over USB serial to a RPI Pico. Pressing the key again will toggle back into passive listening mode.
The RPI Pico is programmed to receive Linux evdev events over serial, translate them into USB HID events and send them to another Windows PC.
The end result is a KM switch that switches instantly between a Linux PC and a PC running an OS of your choice.
Epic wiring photo: https://ibb.co/m0zhzgz. I used another Pico as a USB serial adapter.
As a hardware noob, needing only 2 wires was a huge relief and I think this is a great starter project for other hardware noobs.
Both programs were < 100 LOC. There are tons of Rust crates and python packages to listen to Linux evdev. The program on the Pico was quite simple too, basically just a loop with a big switch statement and there are Rust crates to send USB HID events. You can use COBS to send stuff over serial without worrying about framing.
Ultimately I never ended up open sourcing it because of some USB serial bugs (it would not reconnect properly to the Linux desktop after getting disconnected). Not sure if it was because of Linux or the Pico. I still use it, the bugs aren't a problem because I never disconnect the wires.
I also specifically left out the absolute mouse feature since I play a lot of FPS games and it wouldn't work with those. I have the switch key bound to a button on the side of my mouse anyway so I can switch systems without even touching my keyboard.