Hello! I absolutely adore my KVM, but I’d love to place it under my desk to keep things tidy. Unfortunately, I use a Logitech Bolt receiver which very much does not like being plugged into the HID port, so I’ve just been switching by pressing the button manually. I’ve recently learned how to use CircuitPython on the ESP32-S3 to create programmable HID devices, and figured I could essentially make a WiFi-connected keyboard to switch the KVM via my Elgato Stream Deck.
Unfortunately, while my “keyboard” works (since my OS reports ScrollLock, ScrollLock, 1 key press events), the KVM isn’t switching to the first input.
I know at least one other person managed to make a HID device, but that was with a WiFi-less board. Has anyone managed to get it working with a CircuitPython ESP32-S3 device?
Here’s what I have in case anyone is curious!
# boot.py
import storage
import usb_cdc
import usb_midi
from usb_hid import Device
storage.disable_usb_drive()
usb_cdc.disable()
usb_midi.disable()
# Inform the host that support for a a boot keyboard is available
usb_hid.enable((Device.KEYBOARD), boot_device=1)
# code.py
import socketpool
import wifi
import usb_hid
from time import sleep
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
from adafruit_httpserver import Server, Request, Response, POST
pool = socketpool.SocketPool(wifi.radio)
server = Server(pool, "/static", debug=True)
keyboard = Keyboard(usb_hid.devices)
@server.route("/switch", [POST])
def switch(request: Request):
port = request.form_data.get("port")
try:
if port == "1":
keyboard.send(Keycode.SCROLL_LOCK)
sleep(0.1)
keyboard.send(Keycode.SCROLL_LOCK)
sleep(0.1)
keyboard.send(Keycode.ONE)
return Response(request, "1")
else:
return Response(request, "invalid port")
except Exception as e:
return Response(request, f"{e}")
server.serve_forever(str(wifi.radio.ipv4_address), port=80)
Thanks for the inspiration. It’s actually workign for me on PicoW. Remember to connect to the USB HID port. Though i’m not sure if the HID port has much less power or something but my wifi signal is really part when connected there.
I have a logitech bolt receiver as well and the KVM I received actually reads it correctly, to the point that I can reprogram it with solaar on linux. I wasn’t able to do this on the cheaper KVM from amazon.