-
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy path05_discovery.py
More file actions
58 lines (48 loc) · 1.74 KB
/
05_discovery.py
File metadata and controls
58 lines (48 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""Device discovery example: List and inspect available devices.
This example shows how to discover what SpaceMouse devices are
connected and what device types are supported.
"""
import pyspacemouse
def main():
print("=" * 60)
print("PySpaceMouse Device Discovery")
print("=" * 60)
print()
# 1. List connected SpaceMouse devices
print("Connected SpaceMouse devices:")
connected = pyspacemouse.get_connected_devices()
connected_names = [name for _, name in connected]
if connected:
for name in connected_names:
print(f" ✓ {name}")
else:
print(" (none found)")
print()
# 2. List all supported device types
print("Supported device types:")
supported = pyspacemouse.get_supported_devices()
for name, vid, pid in supported:
# Check if this device type is connected
is_connected = name in connected_names
status = "✓" if is_connected else " "
print(f" [{status}] {name} (VID: {vid:#06x}, PID: {pid:#06x})")
print()
# 3. List ALL HID devices (for debugging)
print("All HID devices on system:")
all_hid = pyspacemouse.get_all_hid_devices()
if all_hid:
for product, manufacturer, vid, pid in all_hid:
product = product or "Unknown"
manufacturer = manufacturer or "Unknown"
print(f" - {product} by {manufacturer}")
print(f" VID: {vid:#06x}, PID: {pid:#06x}")
else:
print(" (none found - is hidapi installed?)")
print()
# 4. Show device specs (advanced)
print("Device specifications loaded from TOML:")
specs = pyspacemouse.get_device_specs()
print(f" {len(specs)} device types configured")
print()
if __name__ == "__main__":
main()