Skip to content

Commit

Permalink
Fixed random endpoint opened on macOS Ventura
Browse files Browse the repository at this point in the history
  • Loading branch information
flozz committed May 23, 2023
1 parent 9ed7367 commit 0ed4226
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rivalcfg/usbhid.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import os
import struct
import platform
from io import BytesIO

import hid
Expand All @@ -32,6 +33,11 @@
HID_REPORT_TYPE_FEATURE = 0x03


_IS_MACOS_VENTURA = (
platform.system() == "Darwin" and platform.mac_ver()[0].split(".")[0] == "13"
)


def is_device_plugged(vendor_id, product_id):
"""Returns ``True`` if the given HID device is plugged to the computer.
Expand Down Expand Up @@ -91,10 +97,11 @@ def open_device(vendor_id, product_id, endpoint):
# which one to use by looking at the usage page. Usage pages from 0xFF00 to
# 0xFFFF are vendor defined and seems to be used by SteelSeries to identify
# the control endpoint.
if not path:
if _IS_MACOS_VENTURA:
for interface in hid.enumerate(vendor_id, product_id):
if interface["interface_number"] == 0 and interface["usage_page"] >= 0xFF00:
path = interface["path"]
break

# Open the found device. This can raise an IOError.
if path:
Expand Down

0 comments on commit 0ed4226

Please sign in to comment.