Update hidapi, improve device detection via handshake
parent
deb9c7e08f
commit
139cfae374
|
|
@ -1,7 +1,7 @@
|
|||
altgraph==0.17
|
||||
fbs==0.9.0
|
||||
future==0.18.2
|
||||
hidapi==0.9.0.post3
|
||||
hidapi==0.10.1
|
||||
keyboard==0.13.5
|
||||
macholib==1.14
|
||||
pefile==2019.4.18
|
||||
|
|
|
|||
|
|
@ -187,8 +187,8 @@ class MainWindow(QMainWindow):
|
|||
outf.write(self.keymap_editor.save_layout())
|
||||
|
||||
def on_click_refresh(self):
|
||||
self.devices = find_vial_devices(self.via_stack_json, self.sideload_vid, self.sideload_pid)
|
||||
self.combobox_devices.clear()
|
||||
self.devices = find_vial_devices(self.via_stack_json, self.sideload_vid, self.sideload_pid)
|
||||
|
||||
for dev in self.devices:
|
||||
self.combobox_devices.addItem(dev.title())
|
||||
|
|
|
|||
|
|
@ -47,9 +47,27 @@ def hid_send(dev, msg, retries=1):
|
|||
return data
|
||||
|
||||
|
||||
def is_rawhid(dev):
|
||||
# TODO: this is only broken on linux, other platforms should be able to check usage_page
|
||||
return dev["interface_number"] == 1
|
||||
def is_rawhid(desc):
|
||||
if desc["usage_page"] != 0xFF60 or desc["usage"] != 0x61:
|
||||
return False
|
||||
|
||||
dev = hid.device()
|
||||
|
||||
try:
|
||||
dev.open_path(desc["path"])
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
# probe VIA version and ensure it is supported
|
||||
data = b""
|
||||
try:
|
||||
data = hid_send(dev, b"\x01", retries=3)
|
||||
except RuntimeError:
|
||||
pass
|
||||
dev.close()
|
||||
|
||||
# must have VIA protocol version = 9
|
||||
return data[0:3] == b"\x01\x00\x09"
|
||||
|
||||
|
||||
def find_vial_devices(via_stack_json, sideload_vid=None, sideload_pid=None):
|
||||
|
|
|
|||
Loading…
Reference in New Issue