AnalogSensePy 1.0.4__tar.gz → 1.0.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {analogsensepy-1.0.4 → analogsensepy-1.0.5}/AnalogSensePy.egg-info/PKG-INFO +3 -2
- analogsensepy-1.0.5/AnalogSensePy.egg-info/requires.txt +6 -0
- {analogsensepy-1.0.4 → analogsensepy-1.0.5}/PKG-INFO +3 -2
- {analogsensepy-1.0.4 → analogsensepy-1.0.5}/README.md +16 -0
- {analogsensepy-1.0.4 → analogsensepy-1.0.5}/analogsense/analogsense.py +25 -9
- {analogsensepy-1.0.4 → analogsensepy-1.0.5}/pyproject.toml +5 -2
- analogsensepy-1.0.4/AnalogSensePy.egg-info/requires.txt +0 -1
- {analogsensepy-1.0.4 → analogsensepy-1.0.5}/AnalogSensePy.egg-info/SOURCES.txt +0 -0
- {analogsensepy-1.0.4 → analogsensepy-1.0.5}/AnalogSensePy.egg-info/dependency_links.txt +0 -0
- {analogsensepy-1.0.4 → analogsensepy-1.0.5}/AnalogSensePy.egg-info/top_level.txt +0 -0
- {analogsensepy-1.0.4 → analogsensepy-1.0.5}/LICENSE +0 -0
- {analogsensepy-1.0.4 → analogsensepy-1.0.5}/analogsense/__init__.py +0 -0
- {analogsensepy-1.0.4 → analogsensepy-1.0.5}/analogsense/keymaps.py +0 -0
- {analogsensepy-1.0.4 → analogsensepy-1.0.5}/analogsense/layouts.py +0 -0
- {analogsensepy-1.0.4 → analogsensepy-1.0.5}/analogsense/providers.py +0 -0
- {analogsensepy-1.0.4 → analogsensepy-1.0.5}/setup.cfg +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: AnalogSensePy
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.5
|
|
4
4
|
Requires-Python: >=3.10
|
|
5
5
|
License-File: LICENSE
|
|
6
|
-
Requires-Dist:
|
|
6
|
+
Requires-Dist: hid; sys_platform == "linux"
|
|
7
|
+
Requires-Dist: hidapi; sys_platform != "linux"
|
|
7
8
|
Dynamic: license-file
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: AnalogSensePy
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.5
|
|
4
4
|
Requires-Python: >=3.10
|
|
5
5
|
License-File: LICENSE
|
|
6
|
-
Requires-Dist:
|
|
6
|
+
Requires-Dist: hid; sys_platform == "linux"
|
|
7
|
+
Requires-Dist: hidapi; sys_platform != "linux"
|
|
7
8
|
Dynamic: license-file
|
|
@@ -27,8 +27,24 @@ Python port of [AnalogSense.js](https://github.com/AnalogSense/JavaScript-SDK/)
|
|
|
27
27
|
```bash
|
|
28
28
|
pip install AnalogSensePy
|
|
29
29
|
```
|
|
30
|
+
|
|
30
31
|
On Linux you may need udev rules or `sudo` for hid
|
|
32
|
+
```bash
|
|
33
|
+
printf '%s\n' \
|
|
34
|
+
'KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0660", GROUP="input"' \
|
|
35
|
+
'SUBSYSTEM=="usb", ATTRS{idVendor}=="31e3", MODE="0660", GROUP="input"' \
|
|
36
|
+
'SUBSYSTEM=="usb", ATTRS{idVendor}=="03eb", MODE="0660", GROUP="input"' \
|
|
37
|
+
'SUBSYSTEM=="usb", ATTRS{idVendor}=="1532", MODE="0660", GROUP="input"' \
|
|
38
|
+
'SUBSYSTEM=="usb", ATTRS{idVendor}=="19f5", MODE="0660", GROUP="input"' \
|
|
39
|
+
'SUBSYSTEM=="usb", ATTRS{idVendor}=="352d", MODE="0660", GROUP="input"' \
|
|
40
|
+
'SUBSYSTEM=="usb", ATTRS{idVendor}=="3434", MODE="0660", GROUP="input"' \
|
|
41
|
+
'SUBSYSTEM=="usb", ATTRS{idVendor}=="362d", MODE="0660", GROUP="input"' \
|
|
42
|
+
'SUBSYSTEM=="usb", ATTRS{idVendor}=="373b", MODE="0660", GROUP="input"' \
|
|
43
|
+
'SUBSYSTEM=="usb", ATTRS{idVendor}=="372e", MODE="0660", GROUP="input"' \
|
|
44
|
+
| sudo tee /etc/udev/rules.d/99-analogsense.rules
|
|
31
45
|
|
|
46
|
+
sudo udevadm control --reload-rules && sudo udevadm trigger
|
|
47
|
+
```
|
|
32
48
|
## Usage
|
|
33
49
|
```python
|
|
34
50
|
from analogsense import AnalogSense
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
+
import sys
|
|
2
3
|
import warnings
|
|
3
4
|
|
|
4
5
|
from .providers import ALL_PROVIDERS, AsProvider
|
|
@@ -10,7 +11,10 @@ try:
|
|
|
10
11
|
_HID_AVAILABLE = True
|
|
11
12
|
except ImportError:
|
|
12
13
|
_HID_AVAILABLE = False
|
|
13
|
-
|
|
14
|
+
if sys.platform == "linux":
|
|
15
|
+
warnings.warn("'hid' is not installed. you can install it with: pip install hid")
|
|
16
|
+
else:
|
|
17
|
+
warnings.warn("'hidapi' is not installed. you can install it with: pip install hidapi")
|
|
14
18
|
|
|
15
19
|
|
|
16
20
|
class DeviceHandle:
|
|
@@ -44,11 +48,10 @@ class AnalogSense:
|
|
|
44
48
|
seen = set()
|
|
45
49
|
for provider_cls in self.providers:
|
|
46
50
|
for f in provider_cls.FILTERS:
|
|
47
|
-
kwargs = {}
|
|
48
|
-
if "vendor_id" in f: kwargs["vendor_id"] = f["vendor_id"]
|
|
49
|
-
if "product_id" in f: kwargs["product_id"] = f["product_id"]
|
|
50
51
|
try:
|
|
51
|
-
|
|
52
|
+
vendor_id = f.get("vendor_id", 0)
|
|
53
|
+
product_id = f.get("product_id", 0)
|
|
54
|
+
for info in _hid.enumerate(vendor_id, product_id):
|
|
52
55
|
dedup_key = (info["vendor_id"], info["product_id"], info.get("usage_page", 0), info.get("usage", 0))
|
|
53
56
|
if dedup_key in seen: continue
|
|
54
57
|
if "usage_page" in f and info.get("usage_page") != f["usage_page"]: continue
|
|
@@ -59,13 +62,26 @@ class AnalogSense:
|
|
|
59
62
|
return candidates
|
|
60
63
|
|
|
61
64
|
def _open(self, info, provider_cls):
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
try:
|
|
66
|
+
if sys.platform == "linux":
|
|
67
|
+
dev = _hid.Device(path=info["path"])
|
|
68
|
+
else:
|
|
69
|
+
dev = _hid.device()
|
|
70
|
+
dev.open_path(info["path"])
|
|
71
|
+
return provider_cls(DeviceHandle(dev, info))
|
|
72
|
+
except Exception as e:
|
|
73
|
+
if "Permission denied" in str(e):
|
|
74
|
+
warnings.warn(
|
|
75
|
+
f"Permission denied opening {info.get('product_string', info['path'])}. "
|
|
76
|
+
"On Linux, udev rules are required. See: https://github.com/girlglock/AnalogSense-Python-SDK#installation"
|
|
77
|
+
)
|
|
78
|
+
else:
|
|
79
|
+
warnings.warn(f"Failed to open device: {e}")
|
|
80
|
+
return None
|
|
65
81
|
|
|
66
82
|
def get_devices(self):
|
|
67
83
|
if not _HID_AVAILABLE: return []
|
|
68
|
-
return [self._open(info, cls) for info, cls in self._collect_candidates()]
|
|
84
|
+
return [dev for dev in (self._open(info, cls) for info, cls in self._collect_candidates()) if dev is not None]
|
|
69
85
|
|
|
70
86
|
def open_device(self, vendor_id, product_id):
|
|
71
87
|
if not _HID_AVAILABLE: return None
|
|
@@ -4,6 +4,9 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "AnalogSensePy"
|
|
7
|
-
version = "1.0.
|
|
7
|
+
version = "1.0.5"
|
|
8
8
|
requires-python = ">=3.10"
|
|
9
|
-
dependencies = [
|
|
9
|
+
dependencies = [
|
|
10
|
+
"hid; sys_platform == 'linux'",
|
|
11
|
+
"hidapi; sys_platform != 'linux'",
|
|
12
|
+
]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
hidapi
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|