So I did it!
I dropped the idea to re-solder l1kvm switch button and went Teensy board way. I think it’s way better as the kvm switch has only one button (I thought those lights are buttons, but they are not) and with custom remote you can have as many buttons as there are hot keys for the switch or more. I have tried Arduino Pro Micro, but did not manage to make it work as a HID device (it works as a keyboard, but more magic is needed to make it work as hid device). I used two buttons from AliExpress and printed a case for them and Teensy board running usb-a to micro usb cable from remote to l1kvm switch.
Here’s my code for teensy keyboard:
const int pc1BtnPin = 22;
const int pc2BtnPin = 21;
const int MODIFIER_KEY = MODIFIERKEY_CTRL;
const int PC_1_KEY = 1;
const int PC_2_KEY = 2;
int currentPC = 0;
int cycles = 0;
int cyclesLimit = 100;
void setup() {
pinMode(pc1BtnPin, INPUT);
pinMode(pc2BtnPin, INPUT);
Keyboard.begin();
Serial.begin(9600);
}
void loop() {
if (digitalRead(pc1BtnPin) == HIGH && currentPC != 1) {
switchPC(1);
} else if (digitalRead(pc2BtnPin) == HIGH && currentPC != 2) {
switchPC(2);
}
cycles++;
resetCycles();
delay(100);
}
void switchPC(int no) {
Keyboard.press(MODIFIER_KEY);
Keyboard.releaseAll();
delay(100);
Keyboard.press(MODIFIER_KEY);
Keyboard.releaseAll();
delay(100);
switch (no) {
case 1:
Keyboard.write('1');
break;
case 2:
Keyboard.write('2');
break;
}
currentPC = no;
cycles = 0;
Serial.print("PC: ");
Serial.println(no);
}
void resetCycles() {
if (cycles > cyclesLimit) {
cycles = 0;
currentPC = 0;
}
}
My setup is my personal PC and work MacBook Pro 2020 with two 4k Dell displays (U4320Q and U2718Q) PC is connected straight to l1kvm switch using display port cables and USB Type-A to Type-C cable. MacBook is connected to CalDigit USB-C Pro Dock using 2m thunderbolt cable and display port cables from dock to l1kvm switch and another usb-c cable from MacBook straight to l1kvm switch. All display port cables are Club3D as recommended. I have tried to connect usb-c cable from dock to kvm switch and have only one cable going to MacBook but I ran into problems - all usb devices randomly disconnects and never connects back unless I reconnect thunderbolt cable to MacBook, then it starts working again but after some random time disconnects again. Connecting USB-C cable straight from MacBook to l1kvm switch solved the problem.
I also tried to connect MacBook using one Club3D display port to usb-c cable and CableMatters USB-C dongle which has display port connection, but ran into problems when switching - pc side works great, but switching to mac only sometimes turned on displays, sometimes it shows mac desktop for a second and goes black, sometimes only 1 display connected though dongle worked, but most of the time displays went straight to standby mode. Also usb did not work at all (cablematters dongle usb type-a to kvm switch type c). I have belkin usb-c dock, it worked but display link sucks, felt like using 30Hz, so i decided to try thunderbolt dock and it worked great.
I also have Logitech unifying receiver connected to kvm switch hid port - works great, Logi Bolt receiver connected to first usb3 port - works great and usb3 hub to second usb3 port on l1kvm which has Logitech Brio 4k camera, Stream Deck Mini, Mayflower ARC MK2 dac and Audioengine A2+ speakers connected to it. All devices work great, only problem is with Logitech MX Keys Mini - sometimes when I switch for example from Windows PC to MacBook, keyboard still thinks that the layout is windows and Start button works as CMD and vice versa - CMD works as Start. It fixes itself after some time and sometimes stays like that :)) i’ll do more debugging as I’ll use my setup.
Thanks to everyone for your input and help from this thread and others and @wendell for a great KVM switch!
Some more photos