Skip to content

Instantly share code, notes, and snippets.

@nicewrld
Created April 24, 2026 18:16
Show Gist options
  • Select an option

  • Save nicewrld/5773f284ae3f5d548fc00659323f63d8 to your computer and use it in GitHub Desktop.

Select an option

Save nicewrld/5773f284ae3f5d548fc00659323f63d8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import hid
import sys
import time
VENDOR_ID = 0x19F7
PID_STEREO = 0x0050
PID_UPDATE = 0x004F
def open_hid(product_id, timeout=5):
deadline = time.time() + timeout
while time.time() < deadline:
devs = hid.enumerate(vendor_id=VENDOR_ID, product_id=product_id)
devs = [d for d in devs if d["usage_page"] in (0xFF00, 0)]
if devs:
h = hid.device()
h.open_path(devs[0]["path"])
h.set_nonblocking(True)
return h
time.sleep(0.5)
return None
def send_cmd(dev, cmd_byte):
report = bytes([0x01, cmd_byte]) + b"\x00" * 62
dev.write(report)
def read_response(dev, timeout=5.0):
deadline = time.time() + timeout
while time.time() < deadline:
data = dev.read(256)
if data:
return bytes(data)
time.sleep(0.01)
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment