-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request
Description
Proposal
When initializing a Se2SpaceMouse
or Se3SpaceMouse
device, allow custom lookup product_strings. Also, sometimes hid
detects device is already open even when the device is not actually used by other processes, so maybe the runtime error here can be allowed.
For example, change the self._find_device(self)
(here) to:
def _find_device(self, product_string_lookup="SpaceMouse Compact"):
"""Find the device connected to computer."""
found = False
# implement a timeout for device search
for _ in range(5):
for device in hid.enumerate():
if device["product_string"] == product_string_lookup:
# set found flag
found = True
vendor_id = device["vendor_id"]
product_id = device["product_id"]
# connect to the device
try:
self._device.open(vendor_id, product_id)
except RuntimeError:
print("device already opened")
# check if device found
if not found:
time.sleep(1.0)
else:
break
# no device found: return false
if not found:
raise OSError("No device found by SpaceMouse. Is the device connected?")
Motivation
Current implementation assumes a fixed product_string device["product_string"] == "SpaceMouse Compact"
But other devices have different production strings, e.g. https://3dconnexion.com/us/ space mouse has "3Dconnexion Universal Receiver"
as product_string
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request
Type
Projects
Status
No status