Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Nice project.

I wrote sth similar for myself, without requirement of USB switch or other hardware. it sends DDC command to HDMI/USB-C monitor and HID++ byte code to Logi MX keyboard and mouse.

Code is too messy to share but here's snippet if anyone want to write their own:

    hid_devices = [
        {
            'name': 'Logi Bolt Receiver',
            'receivers': hid.enumerate(0x046D, 0xC548),
            'command': [  # MX Keys Mini as first device on the receiver
                bytes([0x11, 0x01, 0x09, 0x1A, 0x00] + [0] * 15),  # change host to 1
                bytes([0x11, 0x01, 0x09, 0x1F, 0x01] + [0] * 15),  # change host to 2
                bytes([0x11, 0x01, 0x09, 0x1D, 0x02] + [0] * 15)]  # change host to 3
        }, {
            'name': 'Logitech Unified Receiver',
            'receivers': hid.enumerate(0x046D, 0xC52B),
            'command': [  # MX Anywhere 3 as first device on the receiver
                bytes([0x11, 0x01, 0x0A, 0x1A, 0x00] + [0] * 15),  # change host to 1
                bytes([0x11, 0x01, 0x0A, 0x1E, 0x01] + [0] * 15),  # change host to 2
                bytes([0x11, 0x01, 0x0A, 0x19, 0x02] + [0] * 15)]  # change host to 3
        }, {
            'name': 'MX Keys Mini Bluetooth',
            'receivers': hid.enumerate(0x046D, 0xB36E),
            'command': [
                bytes([0x11, 0xFF, 0x09, 0x1E, 0x00] + [0] * 15),  # change host to 1
                bytes([0x11, 0x01, 0x09, 0x1F, 0x01] + [0] * 15),  # change host to 2
                bytes([0x11, 0xFF, 0x09, 0x1D, 0x02] + [0] * 15)]  # change host to 3
        }, {
            'name': 'MX Anywhere 3 Bluetooth',
            'receivers': hid.enumerate(0x046D, 0xB025),
            'command': [
                bytes([0x11, 0xFF, 0x0A, 0x1A, 0x00] + [0] * 15),  # change host to 1
                bytes([0x11, 0x01, 0x0A, 0x1E, 0x01] + [0] * 15),  # change host to 2
                bytes([0x11, 0xFF, 0x0A, 0x19, 0x02] + [0] * 15)]  # change host to 3
        }
    ]


Where could I explore this further? Are these sequences specific to the device?

My current setup includes two Dell monitors (U2415 with 2x HDMI "MHL" inputs and built in USB-3 hubs.) I'm using these with a Linux X86_64 desktop. I also use Logi vertical mouse and ATK (A.JAZZ) keyboard, both on Bluetooth and both also have dongles.

I would dearly love to use the keyboard/monitor/mouse on a Raspberry Pi 5 (BT and two micro-HDMI ports) with a pure S/W based solution rather than spending $$$ for a H/W KVM switch.

Thanks!

Edit: WRT messy code - no judgement, no shaming here. BTDT.


This works for me:

  import hid

  VID = 0x046D
  HID = 0xB023 # 0xB35B

  if __name__ == "__main__":
      h = hid.device()
      h.open(VID, HID)
      h.set_nonblocking(1)

      # this works for keyboard
      # h.write([0x11, 0x01, 0x09, 0x1F, 0x01] + [0] * 15)

      # this works for mouse
      h.write([0x11, 0x01, 0x0A, 0x1E, 0x01] + [0] * 15)
      h.close()


Nice!!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: