hid 1.0.5__tar.gz → 1.0.6__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.
- hid-1.0.6/LICENSE +21 -0
- {hid-1.0.5 → hid-1.0.6}/MANIFEST.in +2 -1
- hid-1.0.6/PKG-INFO +106 -0
- {hid-1.0.5 → hid-1.0.6}/README.md +90 -90
- {hid-1.0.5 → hid-1.0.6}/hid/__init__.py +266 -224
- hid-1.0.6/hid.egg-info/PKG-INFO +106 -0
- {hid-1.0.5 → hid-1.0.6}/hid.egg-info/SOURCES.txt +1 -0
- {hid-1.0.5 → hid-1.0.6}/hid.egg-info/dependency_links.txt +0 -0
- {hid-1.0.5 → hid-1.0.6}/hid.egg-info/not-zip-safe +0 -0
- {hid-1.0.5 → hid-1.0.6}/hid.egg-info/top_level.txt +0 -0
- {hid-1.0.5 → hid-1.0.6}/setup.cfg +0 -0
- {hid-1.0.5 → hid-1.0.6}/setup.py +31 -33
- hid-1.0.5/PKG-INFO +0 -108
- hid-1.0.5/hid.egg-info/PKG-INFO +0 -108
hid-1.0.6/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Austin Morton
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
include README.md
|
|
1
|
+
include README.md
|
|
2
|
+
include LICENSE
|
hid-1.0.6/PKG-INFO
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: hid
|
|
3
|
+
Version: 1.0.6
|
|
4
|
+
Summary: ctypes bindings for hidapi
|
|
5
|
+
Home-page: https://github.com/apmorton/pyhidapi
|
|
6
|
+
Author: Austin Morton
|
|
7
|
+
Author-email: amorton@juvsoft.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
|
|
17
|
+
# Installing pyhidapi
|
|
18
|
+
pyhidapi is available on [PyPI](https://pypi.org/project/hid/) and can be installed using pip.
|
|
19
|
+
```
|
|
20
|
+
pip install hid
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
pyhidapi is dependant upon the [hidapi library](https://github.com/libusb/hidapi), which must be installed separately.
|
|
24
|
+
|
|
25
|
+
# Installing hidapi
|
|
26
|
+
|
|
27
|
+
## Linux
|
|
28
|
+
Installation procedures vary depending on your distribution.
|
|
29
|
+
|
|
30
|
+
### Arch Linux
|
|
31
|
+
Binary distributions are available in the community repository.
|
|
32
|
+
|
|
33
|
+
1. Enable the community repository in `/etc/pacman.conf`
|
|
34
|
+
```
|
|
35
|
+
[community]
|
|
36
|
+
Include = /etc/pacman.d/mirrorlist
|
|
37
|
+
```
|
|
38
|
+
2. Install hidapi
|
|
39
|
+
```
|
|
40
|
+
pacman -Sy hidapi
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### CentOS/RHEL
|
|
44
|
+
Binary distributions are available through [EPEL](https://fedoraproject.org/wiki/EPEL).
|
|
45
|
+
```
|
|
46
|
+
yum install hidapi
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Fedora
|
|
50
|
+
Binary distributions are available.
|
|
51
|
+
```
|
|
52
|
+
dnf install hidapi
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Ubuntu/Debian
|
|
56
|
+
Binary distributions are available.
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
apt install libhidapi-hidraw0
|
|
60
|
+
```
|
|
61
|
+
or
|
|
62
|
+
```
|
|
63
|
+
apt install libhidapi-libusb0
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Others
|
|
67
|
+
Binary distributions may be available in your package repositories. If not, you can build from source as described [in the libusb/hidapi README](https://github.com/libusb/hidapi#build-instructions).
|
|
68
|
+
|
|
69
|
+
## Windows
|
|
70
|
+
Installation procedure for Windows is described [in the libusb/hidapi README](https://github.com/libusb/hidapi#building-on-windows)
|
|
71
|
+
|
|
72
|
+
Binary distributions are provided by [libusb/hidapi](https://github.com/libusb/hidapi/releases)
|
|
73
|
+
|
|
74
|
+
## OSX
|
|
75
|
+
There are currently no official binary distributions for Mac, so you must build hidapi yourself.
|
|
76
|
+
|
|
77
|
+
Installation instructions are described [in the libusb/hidapi README](https://github.com/libusb/hidapi#mac)
|
|
78
|
+
|
|
79
|
+
You can also use brew:
|
|
80
|
+
```
|
|
81
|
+
brew install hidapi
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## FreeBSD
|
|
85
|
+
Binary distributions are available.
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
pkg install -g 'py3*-hid'
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
# Sample usage code
|
|
92
|
+
|
|
93
|
+
The details about a HID device can be printed with following code:
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
import hid
|
|
97
|
+
|
|
98
|
+
vid = 0x046d # Change it for your device
|
|
99
|
+
pid = 0xc534 # Change it for your device
|
|
100
|
+
|
|
101
|
+
with hid.Device(vid, pid) as h:
|
|
102
|
+
print(f'Device manufacturer: {h.manufacturer}')
|
|
103
|
+
print(f'Product: {h.product}')
|
|
104
|
+
print(f'Serial Number: {h.serial}')
|
|
105
|
+
```
|
|
106
|
+
|
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
# Installing pyhidapi
|
|
2
|
-
pyhidapi is available on [PyPI](https://pypi.org/project/hid/) and can be installed using pip.
|
|
3
|
-
```
|
|
4
|
-
pip install hid
|
|
5
|
-
```
|
|
6
|
-
|
|
7
|
-
pyhidapi is dependant upon the [hidapi library](https://github.com/libusb/hidapi), which must be installed separately.
|
|
8
|
-
|
|
9
|
-
# Installing hidapi
|
|
10
|
-
|
|
11
|
-
## Linux
|
|
12
|
-
Installation procedures vary depending on your distribution.
|
|
13
|
-
|
|
14
|
-
### Arch Linux
|
|
15
|
-
Binary distributions are available in the community repository.
|
|
16
|
-
|
|
17
|
-
1. Enable the community repository in `/etc/pacman.conf`
|
|
18
|
-
```
|
|
19
|
-
[community]
|
|
20
|
-
Include = /etc/pacman.d/mirrorlist
|
|
21
|
-
```
|
|
22
|
-
2. Install hidapi
|
|
23
|
-
```
|
|
24
|
-
pacman -Sy hidapi
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### CentOS/RHEL
|
|
28
|
-
Binary distributions are available through [EPEL](https://fedoraproject.org/wiki/EPEL).
|
|
29
|
-
```
|
|
30
|
-
yum install hidapi
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### Fedora
|
|
34
|
-
Binary distributions are available.
|
|
35
|
-
```
|
|
36
|
-
dnf install hidapi
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### Ubuntu/Debian
|
|
40
|
-
Binary distributions are available.
|
|
41
|
-
|
|
42
|
-
```
|
|
43
|
-
apt install libhidapi-hidraw0
|
|
44
|
-
```
|
|
45
|
-
or
|
|
46
|
-
```
|
|
47
|
-
apt install libhidapi-libusb0
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### Others
|
|
51
|
-
Binary distributions may be available in your package repositories. If not, you can build from source as described [in the libusb/hidapi README](https://github.com/libusb/hidapi#build-instructions).
|
|
52
|
-
|
|
53
|
-
## Windows
|
|
54
|
-
Installation procedure for Windows is described [in the libusb/hidapi README](https://github.com/libusb/hidapi#building-on-windows)
|
|
55
|
-
|
|
56
|
-
Binary distributions are provided by [libusb/hidapi](https://github.com/libusb/hidapi/releases)
|
|
57
|
-
|
|
58
|
-
## OSX
|
|
59
|
-
There are currently no official binary distributions for Mac, so you must build hidapi yourself.
|
|
60
|
-
|
|
61
|
-
Installation instructions are described [in the libusb/hidapi README](https://github.com/libusb/hidapi#mac)
|
|
62
|
-
|
|
63
|
-
You can also use brew:
|
|
64
|
-
```
|
|
65
|
-
brew install hidapi
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## FreeBSD
|
|
69
|
-
Binary distributions are available.
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
-
pkg install -g 'py3*-hid'
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
# Sample usage code
|
|
76
|
-
|
|
77
|
-
The details about a HID device can be printed with following code:
|
|
78
|
-
|
|
79
|
-
```python
|
|
80
|
-
import hid
|
|
81
|
-
|
|
82
|
-
vid = 0x046d # Change it for your device
|
|
83
|
-
pid = 0xc534 # Change it for your device
|
|
84
|
-
|
|
85
|
-
with hid.Device(vid, pid) as h:
|
|
86
|
-
print(f'Device manufacturer: {h.manufacturer}')
|
|
87
|
-
print(f'Product: {h.product}')
|
|
88
|
-
print(f'Serial Number: {h.serial}')
|
|
89
|
-
```
|
|
90
|
-
|
|
1
|
+
# Installing pyhidapi
|
|
2
|
+
pyhidapi is available on [PyPI](https://pypi.org/project/hid/) and can be installed using pip.
|
|
3
|
+
```
|
|
4
|
+
pip install hid
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
pyhidapi is dependant upon the [hidapi library](https://github.com/libusb/hidapi), which must be installed separately.
|
|
8
|
+
|
|
9
|
+
# Installing hidapi
|
|
10
|
+
|
|
11
|
+
## Linux
|
|
12
|
+
Installation procedures vary depending on your distribution.
|
|
13
|
+
|
|
14
|
+
### Arch Linux
|
|
15
|
+
Binary distributions are available in the community repository.
|
|
16
|
+
|
|
17
|
+
1. Enable the community repository in `/etc/pacman.conf`
|
|
18
|
+
```
|
|
19
|
+
[community]
|
|
20
|
+
Include = /etc/pacman.d/mirrorlist
|
|
21
|
+
```
|
|
22
|
+
2. Install hidapi
|
|
23
|
+
```
|
|
24
|
+
pacman -Sy hidapi
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### CentOS/RHEL
|
|
28
|
+
Binary distributions are available through [EPEL](https://fedoraproject.org/wiki/EPEL).
|
|
29
|
+
```
|
|
30
|
+
yum install hidapi
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Fedora
|
|
34
|
+
Binary distributions are available.
|
|
35
|
+
```
|
|
36
|
+
dnf install hidapi
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Ubuntu/Debian
|
|
40
|
+
Binary distributions are available.
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
apt install libhidapi-hidraw0
|
|
44
|
+
```
|
|
45
|
+
or
|
|
46
|
+
```
|
|
47
|
+
apt install libhidapi-libusb0
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Others
|
|
51
|
+
Binary distributions may be available in your package repositories. If not, you can build from source as described [in the libusb/hidapi README](https://github.com/libusb/hidapi#build-instructions).
|
|
52
|
+
|
|
53
|
+
## Windows
|
|
54
|
+
Installation procedure for Windows is described [in the libusb/hidapi README](https://github.com/libusb/hidapi#building-on-windows)
|
|
55
|
+
|
|
56
|
+
Binary distributions are provided by [libusb/hidapi](https://github.com/libusb/hidapi/releases)
|
|
57
|
+
|
|
58
|
+
## OSX
|
|
59
|
+
There are currently no official binary distributions for Mac, so you must build hidapi yourself.
|
|
60
|
+
|
|
61
|
+
Installation instructions are described [in the libusb/hidapi README](https://github.com/libusb/hidapi#mac)
|
|
62
|
+
|
|
63
|
+
You can also use brew:
|
|
64
|
+
```
|
|
65
|
+
brew install hidapi
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## FreeBSD
|
|
69
|
+
Binary distributions are available.
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
pkg install -g 'py3*-hid'
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
# Sample usage code
|
|
76
|
+
|
|
77
|
+
The details about a HID device can be printed with following code:
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
import hid
|
|
81
|
+
|
|
82
|
+
vid = 0x046d # Change it for your device
|
|
83
|
+
pid = 0xc534 # Change it for your device
|
|
84
|
+
|
|
85
|
+
with hid.Device(vid, pid) as h:
|
|
86
|
+
print(f'Device manufacturer: {h.manufacturer}')
|
|
87
|
+
print(f'Product: {h.product}')
|
|
88
|
+
print(f'Serial Number: {h.serial}')
|
|
89
|
+
```
|
|
90
|
+
|
|
@@ -1,224 +1,266 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import ctypes
|
|
3
|
-
import atexit
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
'libhidapi-hidraw.so
|
|
12
|
-
'libhidapi-
|
|
13
|
-
'libhidapi-libusb.so
|
|
14
|
-
'libhidapi-
|
|
15
|
-
'libhidapi-iohidmanager.so
|
|
16
|
-
'libhidapi.
|
|
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
|
-
class
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
return
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
1
|
+
import os
|
|
2
|
+
import ctypes
|
|
3
|
+
import atexit
|
|
4
|
+
import enum
|
|
5
|
+
|
|
6
|
+
__all__ = ['HIDException', 'DeviceInfo', 'Device', 'enumerate', 'BusType']
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
hidapi = None
|
|
10
|
+
library_paths = (
|
|
11
|
+
'libhidapi-hidraw.so',
|
|
12
|
+
'libhidapi-hidraw.so.0',
|
|
13
|
+
'libhidapi-libusb.so',
|
|
14
|
+
'libhidapi-libusb.so.0',
|
|
15
|
+
'libhidapi-iohidmanager.so',
|
|
16
|
+
'libhidapi-iohidmanager.so.0',
|
|
17
|
+
'libhidapi.dylib',
|
|
18
|
+
'hidapi.dll',
|
|
19
|
+
'libhidapi-0.dll'
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
for lib in library_paths:
|
|
23
|
+
try:
|
|
24
|
+
hidapi = ctypes.cdll.LoadLibrary(lib)
|
|
25
|
+
break
|
|
26
|
+
except OSError:
|
|
27
|
+
pass
|
|
28
|
+
else:
|
|
29
|
+
error = "Unable to load any of the following libraries:{}"\
|
|
30
|
+
.format(' '.join(library_paths))
|
|
31
|
+
raise ImportError(error)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
hidapi.hid_init()
|
|
35
|
+
atexit.register(hidapi.hid_exit)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class HIDException(Exception):
|
|
39
|
+
pass
|
|
40
|
+
|
|
41
|
+
class APIVersion(ctypes.Structure):
|
|
42
|
+
_fields_ = [
|
|
43
|
+
('major', ctypes.c_int),
|
|
44
|
+
('minor', ctypes.c_int),
|
|
45
|
+
('patch', ctypes.c_int),
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
try:
|
|
49
|
+
hidapi.hid_version.argtypes = []
|
|
50
|
+
hidapi.hid_version.restype = ctypes.POINTER(APIVersion)
|
|
51
|
+
|
|
52
|
+
version = hidapi.hid_version()
|
|
53
|
+
version = (
|
|
54
|
+
version.contents.major,
|
|
55
|
+
version.contents.minor,
|
|
56
|
+
version.contents.patch,
|
|
57
|
+
)
|
|
58
|
+
except AttributeError:
|
|
59
|
+
#
|
|
60
|
+
# hid_version API was added in
|
|
61
|
+
# https://github.com/libusb/hidapi/commit/8f72236099290345928e646d2f2c48f0187ac4af
|
|
62
|
+
# so if it is missing we are dealing with hidapi 0.8.0 or older
|
|
63
|
+
#
|
|
64
|
+
version = (0, 8, 0)
|
|
65
|
+
|
|
66
|
+
if version >= (0, 13, 0):
|
|
67
|
+
bus_type = [
|
|
68
|
+
('bus_type', ctypes.c_int),
|
|
69
|
+
]
|
|
70
|
+
else:
|
|
71
|
+
bus_type = []
|
|
72
|
+
|
|
73
|
+
class BusType(enum.Enum):
|
|
74
|
+
UNKNOWN = 0x00
|
|
75
|
+
USB = 0x01
|
|
76
|
+
BLUETOOTH = 0x02
|
|
77
|
+
I2C = 0x03
|
|
78
|
+
SPI = 0x04
|
|
79
|
+
|
|
80
|
+
class DeviceInfo(ctypes.Structure):
|
|
81
|
+
def as_dict(self):
|
|
82
|
+
ret = {}
|
|
83
|
+
for name, type in self._fields_:
|
|
84
|
+
if name == 'next':
|
|
85
|
+
continue
|
|
86
|
+
ret[name] = getattr(self, name, None)
|
|
87
|
+
|
|
88
|
+
if name == 'bus_type':
|
|
89
|
+
ret[name] = BusType(ret[name])
|
|
90
|
+
|
|
91
|
+
return ret
|
|
92
|
+
|
|
93
|
+
DeviceInfo._fields_ = [
|
|
94
|
+
('path', ctypes.c_char_p),
|
|
95
|
+
('vendor_id', ctypes.c_ushort),
|
|
96
|
+
('product_id', ctypes.c_ushort),
|
|
97
|
+
('serial_number', ctypes.c_wchar_p),
|
|
98
|
+
('release_number', ctypes.c_ushort),
|
|
99
|
+
('manufacturer_string', ctypes.c_wchar_p),
|
|
100
|
+
('product_string', ctypes.c_wchar_p),
|
|
101
|
+
('usage_page', ctypes.c_ushort),
|
|
102
|
+
('usage', ctypes.c_ushort),
|
|
103
|
+
('interface_number', ctypes.c_int),
|
|
104
|
+
('next', ctypes.POINTER(DeviceInfo)),
|
|
105
|
+
] + bus_type
|
|
106
|
+
|
|
107
|
+
hidapi.hid_init.argtypes = []
|
|
108
|
+
hidapi.hid_init.restype = ctypes.c_int
|
|
109
|
+
hidapi.hid_exit.argtypes = []
|
|
110
|
+
hidapi.hid_exit.restype = ctypes.c_int
|
|
111
|
+
hidapi.hid_enumerate.argtypes = [ctypes.c_ushort, ctypes.c_ushort]
|
|
112
|
+
hidapi.hid_enumerate.restype = ctypes.POINTER(DeviceInfo)
|
|
113
|
+
hidapi.hid_free_enumeration.argtypes = [ctypes.POINTER(DeviceInfo)]
|
|
114
|
+
hidapi.hid_free_enumeration.restype = None
|
|
115
|
+
hidapi.hid_open.argtypes = [ctypes.c_ushort, ctypes.c_ushort, ctypes.c_wchar_p]
|
|
116
|
+
hidapi.hid_open.restype = ctypes.c_void_p
|
|
117
|
+
hidapi.hid_open_path.argtypes = [ctypes.c_char_p]
|
|
118
|
+
hidapi.hid_open_path.restype = ctypes.c_void_p
|
|
119
|
+
hidapi.hid_write.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_size_t]
|
|
120
|
+
hidapi.hid_write.restype = ctypes.c_int
|
|
121
|
+
hidapi.hid_read_timeout.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_size_t, ctypes.c_int]
|
|
122
|
+
hidapi.hid_read_timeout.restype = ctypes.c_int
|
|
123
|
+
hidapi.hid_read.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_size_t]
|
|
124
|
+
hidapi.hid_read.restype = ctypes.c_int
|
|
125
|
+
hidapi.hid_get_input_report.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_size_t]
|
|
126
|
+
hidapi.hid_get_input_report.restype = ctypes.c_int
|
|
127
|
+
hidapi.hid_set_nonblocking.argtypes = [ctypes.c_void_p, ctypes.c_int]
|
|
128
|
+
hidapi.hid_set_nonblocking.restype = ctypes.c_int
|
|
129
|
+
hidapi.hid_send_feature_report.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_int]
|
|
130
|
+
hidapi.hid_send_feature_report.restype = ctypes.c_int
|
|
131
|
+
hidapi.hid_get_feature_report.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_size_t]
|
|
132
|
+
hidapi.hid_get_feature_report.restype = ctypes.c_int
|
|
133
|
+
hidapi.hid_close.argtypes = [ctypes.c_void_p]
|
|
134
|
+
hidapi.hid_close.restype = None
|
|
135
|
+
hidapi.hid_get_manufacturer_string.argtypes = [ctypes.c_void_p, ctypes.c_wchar_p, ctypes.c_size_t]
|
|
136
|
+
hidapi.hid_get_manufacturer_string.restype = ctypes.c_int
|
|
137
|
+
hidapi.hid_get_product_string.argtypes = [ctypes.c_void_p, ctypes.c_wchar_p, ctypes.c_size_t]
|
|
138
|
+
hidapi.hid_get_product_string.restype = ctypes.c_int
|
|
139
|
+
hidapi.hid_get_serial_number_string.argtypes = [ctypes.c_void_p, ctypes.c_wchar_p, ctypes.c_size_t]
|
|
140
|
+
hidapi.hid_get_serial_number_string.restype = ctypes.c_int
|
|
141
|
+
hidapi.hid_get_indexed_string.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.c_wchar_p, ctypes.c_size_t]
|
|
142
|
+
hidapi.hid_get_indexed_string.restype = ctypes.c_int
|
|
143
|
+
hidapi.hid_error.argtypes = [ctypes.c_void_p]
|
|
144
|
+
hidapi.hid_error.restype = ctypes.c_wchar_p
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def enumerate(vid=0, pid=0):
|
|
148
|
+
ret = []
|
|
149
|
+
info = hidapi.hid_enumerate(vid, pid)
|
|
150
|
+
c = info
|
|
151
|
+
|
|
152
|
+
while c:
|
|
153
|
+
ret.append(c.contents.as_dict())
|
|
154
|
+
c = c.contents.next
|
|
155
|
+
|
|
156
|
+
hidapi.hid_free_enumeration(info)
|
|
157
|
+
|
|
158
|
+
return ret
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
class Device(object):
|
|
162
|
+
def __init__(self, vid=None, pid=None, serial=None, path=None):
|
|
163
|
+
if path:
|
|
164
|
+
self.__dev = hidapi.hid_open_path(path)
|
|
165
|
+
elif serial:
|
|
166
|
+
serial = ctypes.create_unicode_buffer(serial)
|
|
167
|
+
self.__dev = hidapi.hid_open(vid, pid, serial)
|
|
168
|
+
elif vid and pid:
|
|
169
|
+
self.__dev = hidapi.hid_open(vid, pid, None)
|
|
170
|
+
else:
|
|
171
|
+
raise ValueError('specify vid/pid or path')
|
|
172
|
+
|
|
173
|
+
if not self.__dev:
|
|
174
|
+
raise HIDException('unable to open device')
|
|
175
|
+
|
|
176
|
+
def __enter__(self):
|
|
177
|
+
return self
|
|
178
|
+
|
|
179
|
+
def __exit__(self, exc_type, exc_value, exc_traceback):
|
|
180
|
+
self.close()
|
|
181
|
+
|
|
182
|
+
def __hidcall(self, function, *args, **kwargs):
|
|
183
|
+
if not self.__dev:
|
|
184
|
+
raise HIDException('device closed')
|
|
185
|
+
|
|
186
|
+
ret = function(*args, **kwargs)
|
|
187
|
+
|
|
188
|
+
if ret == -1:
|
|
189
|
+
err = hidapi.hid_error(self.__dev)
|
|
190
|
+
raise HIDException(err)
|
|
191
|
+
return ret
|
|
192
|
+
|
|
193
|
+
def __readstring(self, function, max_length=255):
|
|
194
|
+
buf = ctypes.create_unicode_buffer(max_length)
|
|
195
|
+
self.__hidcall(function, self.__dev, buf, max_length)
|
|
196
|
+
return buf.value
|
|
197
|
+
|
|
198
|
+
def write(self, data):
|
|
199
|
+
return self.__hidcall(hidapi.hid_write, self.__dev, data, len(data))
|
|
200
|
+
|
|
201
|
+
def read(self, size, timeout=None):
|
|
202
|
+
data = ctypes.create_string_buffer(size)
|
|
203
|
+
|
|
204
|
+
if timeout is None:
|
|
205
|
+
size = self.__hidcall(hidapi.hid_read, self.__dev, data, size)
|
|
206
|
+
else:
|
|
207
|
+
size = self.__hidcall(
|
|
208
|
+
hidapi.hid_read_timeout, self.__dev, data, size, timeout)
|
|
209
|
+
|
|
210
|
+
return data.raw[:size]
|
|
211
|
+
|
|
212
|
+
def get_input_report(self, report_id, size):
|
|
213
|
+
data = ctypes.create_string_buffer(size)
|
|
214
|
+
|
|
215
|
+
# Pass the id of the report to be read.
|
|
216
|
+
data[0] = bytearray((report_id,))
|
|
217
|
+
|
|
218
|
+
size = self.__hidcall(
|
|
219
|
+
hidapi.hid_get_input_report, self.__dev, data, size)
|
|
220
|
+
return data.raw[:size]
|
|
221
|
+
|
|
222
|
+
def send_feature_report(self, data):
|
|
223
|
+
return self.__hidcall(hidapi.hid_send_feature_report,
|
|
224
|
+
self.__dev, data, len(data))
|
|
225
|
+
|
|
226
|
+
def get_feature_report(self, report_id, size):
|
|
227
|
+
data = ctypes.create_string_buffer(size)
|
|
228
|
+
|
|
229
|
+
# Pass the id of the report to be read.
|
|
230
|
+
data[0] = bytearray((report_id,))
|
|
231
|
+
|
|
232
|
+
size = self.__hidcall(
|
|
233
|
+
hidapi.hid_get_feature_report, self.__dev, data, size)
|
|
234
|
+
return data.raw[:size]
|
|
235
|
+
|
|
236
|
+
def close(self):
|
|
237
|
+
if self.__dev:
|
|
238
|
+
hidapi.hid_close(self.__dev)
|
|
239
|
+
self.__dev = None
|
|
240
|
+
|
|
241
|
+
@property
|
|
242
|
+
def nonblocking(self):
|
|
243
|
+
return getattr(self, '_nonblocking', 0)
|
|
244
|
+
|
|
245
|
+
@nonblocking.setter
|
|
246
|
+
def nonblocking(self, value):
|
|
247
|
+
self.__hidcall(hidapi.hid_set_nonblocking, self.__dev, value)
|
|
248
|
+
setattr(self, '_nonblocking', value)
|
|
249
|
+
|
|
250
|
+
@property
|
|
251
|
+
def manufacturer(self):
|
|
252
|
+
return self.__readstring(hidapi.hid_get_manufacturer_string)
|
|
253
|
+
|
|
254
|
+
@property
|
|
255
|
+
def product(self):
|
|
256
|
+
return self.__readstring(hidapi.hid_get_product_string)
|
|
257
|
+
|
|
258
|
+
@property
|
|
259
|
+
def serial(self):
|
|
260
|
+
return self.__readstring(hidapi.hid_get_serial_number_string)
|
|
261
|
+
|
|
262
|
+
def get_indexed_string(self, index, max_length=255):
|
|
263
|
+
buf = ctypes.create_unicode_buffer(max_length)
|
|
264
|
+
self.__hidcall(hidapi.hid_get_indexed_string,
|
|
265
|
+
self.__dev, index, buf, max_length)
|
|
266
|
+
return buf.value
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: hid
|
|
3
|
+
Version: 1.0.6
|
|
4
|
+
Summary: ctypes bindings for hidapi
|
|
5
|
+
Home-page: https://github.com/apmorton/pyhidapi
|
|
6
|
+
Author: Austin Morton
|
|
7
|
+
Author-email: amorton@juvsoft.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
|
|
17
|
+
# Installing pyhidapi
|
|
18
|
+
pyhidapi is available on [PyPI](https://pypi.org/project/hid/) and can be installed using pip.
|
|
19
|
+
```
|
|
20
|
+
pip install hid
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
pyhidapi is dependant upon the [hidapi library](https://github.com/libusb/hidapi), which must be installed separately.
|
|
24
|
+
|
|
25
|
+
# Installing hidapi
|
|
26
|
+
|
|
27
|
+
## Linux
|
|
28
|
+
Installation procedures vary depending on your distribution.
|
|
29
|
+
|
|
30
|
+
### Arch Linux
|
|
31
|
+
Binary distributions are available in the community repository.
|
|
32
|
+
|
|
33
|
+
1. Enable the community repository in `/etc/pacman.conf`
|
|
34
|
+
```
|
|
35
|
+
[community]
|
|
36
|
+
Include = /etc/pacman.d/mirrorlist
|
|
37
|
+
```
|
|
38
|
+
2. Install hidapi
|
|
39
|
+
```
|
|
40
|
+
pacman -Sy hidapi
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### CentOS/RHEL
|
|
44
|
+
Binary distributions are available through [EPEL](https://fedoraproject.org/wiki/EPEL).
|
|
45
|
+
```
|
|
46
|
+
yum install hidapi
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Fedora
|
|
50
|
+
Binary distributions are available.
|
|
51
|
+
```
|
|
52
|
+
dnf install hidapi
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Ubuntu/Debian
|
|
56
|
+
Binary distributions are available.
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
apt install libhidapi-hidraw0
|
|
60
|
+
```
|
|
61
|
+
or
|
|
62
|
+
```
|
|
63
|
+
apt install libhidapi-libusb0
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Others
|
|
67
|
+
Binary distributions may be available in your package repositories. If not, you can build from source as described [in the libusb/hidapi README](https://github.com/libusb/hidapi#build-instructions).
|
|
68
|
+
|
|
69
|
+
## Windows
|
|
70
|
+
Installation procedure for Windows is described [in the libusb/hidapi README](https://github.com/libusb/hidapi#building-on-windows)
|
|
71
|
+
|
|
72
|
+
Binary distributions are provided by [libusb/hidapi](https://github.com/libusb/hidapi/releases)
|
|
73
|
+
|
|
74
|
+
## OSX
|
|
75
|
+
There are currently no official binary distributions for Mac, so you must build hidapi yourself.
|
|
76
|
+
|
|
77
|
+
Installation instructions are described [in the libusb/hidapi README](https://github.com/libusb/hidapi#mac)
|
|
78
|
+
|
|
79
|
+
You can also use brew:
|
|
80
|
+
```
|
|
81
|
+
brew install hidapi
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## FreeBSD
|
|
85
|
+
Binary distributions are available.
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
pkg install -g 'py3*-hid'
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
# Sample usage code
|
|
92
|
+
|
|
93
|
+
The details about a HID device can be printed with following code:
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
import hid
|
|
97
|
+
|
|
98
|
+
vid = 0x046d # Change it for your device
|
|
99
|
+
pid = 0xc534 # Change it for your device
|
|
100
|
+
|
|
101
|
+
with hid.Device(vid, pid) as h:
|
|
102
|
+
print(f'Device manufacturer: {h.manufacturer}')
|
|
103
|
+
print(f'Product: {h.product}')
|
|
104
|
+
print(f'Serial Number: {h.serial}')
|
|
105
|
+
```
|
|
106
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hid-1.0.5 → hid-1.0.6}/setup.py
RENAMED
|
@@ -1,33 +1,31 @@
|
|
|
1
|
-
from setuptools import setup, find_packages
|
|
2
|
-
import os
|
|
3
|
-
|
|
4
|
-
here = os.path.abspath(os.path.dirname(__file__))
|
|
5
|
-
README = open(os.path.join(here, 'README.md')).read()
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
version = '1.0.
|
|
9
|
-
|
|
10
|
-
setup(
|
|
11
|
-
name='hid',
|
|
12
|
-
version=version,
|
|
13
|
-
description='ctypes bindings for hidapi',
|
|
14
|
-
long_description=README,
|
|
15
|
-
long_description_content_type='text/markdown',
|
|
16
|
-
classifiers=[
|
|
17
|
-
'Intended Audience :: Developers',
|
|
18
|
-
'License :: OSI Approved :: MIT License',
|
|
19
|
-
'Operating System :: OS Independent',
|
|
20
|
-
'Programming Language :: Python',
|
|
21
|
-
'Programming Language :: Python ::
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
test_suite='nose.collector'
|
|
33
|
-
)
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
here = os.path.abspath(os.path.dirname(__file__))
|
|
5
|
+
README = open(os.path.join(here, 'README.md')).read()
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
version = '1.0.6'
|
|
9
|
+
|
|
10
|
+
setup(
|
|
11
|
+
name='hid',
|
|
12
|
+
version=version,
|
|
13
|
+
description='ctypes bindings for hidapi',
|
|
14
|
+
long_description=README,
|
|
15
|
+
long_description_content_type='text/markdown',
|
|
16
|
+
classifiers=[
|
|
17
|
+
'Intended Audience :: Developers',
|
|
18
|
+
'License :: OSI Approved :: MIT License',
|
|
19
|
+
'Operating System :: OS Independent',
|
|
20
|
+
'Programming Language :: Python',
|
|
21
|
+
'Programming Language :: Python :: 3',
|
|
22
|
+
],
|
|
23
|
+
keywords='',
|
|
24
|
+
author='Austin Morton',
|
|
25
|
+
author_email='amorton@juvsoft.com',
|
|
26
|
+
url='https://github.com/apmorton/pyhidapi',
|
|
27
|
+
license='MIT',
|
|
28
|
+
packages=find_packages(),
|
|
29
|
+
zip_safe=False,
|
|
30
|
+
test_suite='nose.collector'
|
|
31
|
+
)
|
hid-1.0.5/PKG-INFO
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: hid
|
|
3
|
-
Version: 1.0.5
|
|
4
|
-
Summary: ctypes bindings for hidapi
|
|
5
|
-
Home-page: https://github.com/apmorton/pyhidapi
|
|
6
|
-
Author: Austin Morton
|
|
7
|
-
Author-email: amorton@juvsoft.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Description: # Installing pyhidapi
|
|
10
|
-
pyhidapi is available on [PyPI](https://pypi.org/project/hid/) and can be installed using pip.
|
|
11
|
-
```
|
|
12
|
-
pip install hid
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
pyhidapi is dependant upon the [hidapi library](https://github.com/libusb/hidapi), which must be installed separately.
|
|
16
|
-
|
|
17
|
-
# Installing hidapi
|
|
18
|
-
|
|
19
|
-
## Linux
|
|
20
|
-
Installation procedures vary depending on your distribution.
|
|
21
|
-
|
|
22
|
-
### Arch Linux
|
|
23
|
-
Binary distributions are available in the community repository.
|
|
24
|
-
|
|
25
|
-
1. Enable the community repository in `/etc/pacman.conf`
|
|
26
|
-
```
|
|
27
|
-
[community]
|
|
28
|
-
Include = /etc/pacman.d/mirrorlist
|
|
29
|
-
```
|
|
30
|
-
2. Install hidapi
|
|
31
|
-
```
|
|
32
|
-
pacman -Sy hidapi
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### CentOS/RHEL
|
|
36
|
-
Binary distributions are available through [EPEL](https://fedoraproject.org/wiki/EPEL).
|
|
37
|
-
```
|
|
38
|
-
yum install hidapi
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Fedora
|
|
42
|
-
Binary distributions are available.
|
|
43
|
-
```
|
|
44
|
-
dnf install hidapi
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### Ubuntu/Debian
|
|
48
|
-
Binary distributions are available.
|
|
49
|
-
|
|
50
|
-
```
|
|
51
|
-
apt install libhidapi-hidraw0
|
|
52
|
-
```
|
|
53
|
-
or
|
|
54
|
-
```
|
|
55
|
-
apt install libhidapi-libusb0
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### Others
|
|
59
|
-
Binary distributions may be available in your package repositories. If not, you can build from source as described [in the libusb/hidapi README](https://github.com/libusb/hidapi#build-instructions).
|
|
60
|
-
|
|
61
|
-
## Windows
|
|
62
|
-
Installation procedure for Windows is described [in the libusb/hidapi README](https://github.com/libusb/hidapi#building-on-windows)
|
|
63
|
-
|
|
64
|
-
Binary distributions are provided by [libusb/hidapi](https://github.com/libusb/hidapi/releases)
|
|
65
|
-
|
|
66
|
-
## OSX
|
|
67
|
-
There are currently no official binary distributions for Mac, so you must build hidapi yourself.
|
|
68
|
-
|
|
69
|
-
Installation instructions are described [in the libusb/hidapi README](https://github.com/libusb/hidapi#mac)
|
|
70
|
-
|
|
71
|
-
You can also use brew:
|
|
72
|
-
```
|
|
73
|
-
brew install hidapi
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## FreeBSD
|
|
77
|
-
Binary distributions are available.
|
|
78
|
-
|
|
79
|
-
```
|
|
80
|
-
pkg install -g 'py3*-hid'
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
# Sample usage code
|
|
84
|
-
|
|
85
|
-
The details about a HID device can be printed with following code:
|
|
86
|
-
|
|
87
|
-
```python
|
|
88
|
-
import hid
|
|
89
|
-
|
|
90
|
-
vid = 0x046d # Change it for your device
|
|
91
|
-
pid = 0xc534 # Change it for your device
|
|
92
|
-
|
|
93
|
-
with hid.Device(vid, pid) as h:
|
|
94
|
-
print(f'Device manufacturer: {h.manufacturer}')
|
|
95
|
-
print(f'Product: {h.product}')
|
|
96
|
-
print(f'Serial Number: {h.serial}')
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
Platform: UNKNOWN
|
|
101
|
-
Classifier: Intended Audience :: Developers
|
|
102
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
103
|
-
Classifier: Operating System :: OS Independent
|
|
104
|
-
Classifier: Programming Language :: Python
|
|
105
|
-
Classifier: Programming Language :: Python :: 2.6
|
|
106
|
-
Classifier: Programming Language :: Python :: 2.7
|
|
107
|
-
Classifier: Programming Language :: Python :: 3
|
|
108
|
-
Description-Content-Type: text/markdown
|
hid-1.0.5/hid.egg-info/PKG-INFO
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: hid
|
|
3
|
-
Version: 1.0.5
|
|
4
|
-
Summary: ctypes bindings for hidapi
|
|
5
|
-
Home-page: https://github.com/apmorton/pyhidapi
|
|
6
|
-
Author: Austin Morton
|
|
7
|
-
Author-email: amorton@juvsoft.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Description: # Installing pyhidapi
|
|
10
|
-
pyhidapi is available on [PyPI](https://pypi.org/project/hid/) and can be installed using pip.
|
|
11
|
-
```
|
|
12
|
-
pip install hid
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
pyhidapi is dependant upon the [hidapi library](https://github.com/libusb/hidapi), which must be installed separately.
|
|
16
|
-
|
|
17
|
-
# Installing hidapi
|
|
18
|
-
|
|
19
|
-
## Linux
|
|
20
|
-
Installation procedures vary depending on your distribution.
|
|
21
|
-
|
|
22
|
-
### Arch Linux
|
|
23
|
-
Binary distributions are available in the community repository.
|
|
24
|
-
|
|
25
|
-
1. Enable the community repository in `/etc/pacman.conf`
|
|
26
|
-
```
|
|
27
|
-
[community]
|
|
28
|
-
Include = /etc/pacman.d/mirrorlist
|
|
29
|
-
```
|
|
30
|
-
2. Install hidapi
|
|
31
|
-
```
|
|
32
|
-
pacman -Sy hidapi
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### CentOS/RHEL
|
|
36
|
-
Binary distributions are available through [EPEL](https://fedoraproject.org/wiki/EPEL).
|
|
37
|
-
```
|
|
38
|
-
yum install hidapi
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Fedora
|
|
42
|
-
Binary distributions are available.
|
|
43
|
-
```
|
|
44
|
-
dnf install hidapi
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### Ubuntu/Debian
|
|
48
|
-
Binary distributions are available.
|
|
49
|
-
|
|
50
|
-
```
|
|
51
|
-
apt install libhidapi-hidraw0
|
|
52
|
-
```
|
|
53
|
-
or
|
|
54
|
-
```
|
|
55
|
-
apt install libhidapi-libusb0
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### Others
|
|
59
|
-
Binary distributions may be available in your package repositories. If not, you can build from source as described [in the libusb/hidapi README](https://github.com/libusb/hidapi#build-instructions).
|
|
60
|
-
|
|
61
|
-
## Windows
|
|
62
|
-
Installation procedure for Windows is described [in the libusb/hidapi README](https://github.com/libusb/hidapi#building-on-windows)
|
|
63
|
-
|
|
64
|
-
Binary distributions are provided by [libusb/hidapi](https://github.com/libusb/hidapi/releases)
|
|
65
|
-
|
|
66
|
-
## OSX
|
|
67
|
-
There are currently no official binary distributions for Mac, so you must build hidapi yourself.
|
|
68
|
-
|
|
69
|
-
Installation instructions are described [in the libusb/hidapi README](https://github.com/libusb/hidapi#mac)
|
|
70
|
-
|
|
71
|
-
You can also use brew:
|
|
72
|
-
```
|
|
73
|
-
brew install hidapi
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## FreeBSD
|
|
77
|
-
Binary distributions are available.
|
|
78
|
-
|
|
79
|
-
```
|
|
80
|
-
pkg install -g 'py3*-hid'
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
# Sample usage code
|
|
84
|
-
|
|
85
|
-
The details about a HID device can be printed with following code:
|
|
86
|
-
|
|
87
|
-
```python
|
|
88
|
-
import hid
|
|
89
|
-
|
|
90
|
-
vid = 0x046d # Change it for your device
|
|
91
|
-
pid = 0xc534 # Change it for your device
|
|
92
|
-
|
|
93
|
-
with hid.Device(vid, pid) as h:
|
|
94
|
-
print(f'Device manufacturer: {h.manufacturer}')
|
|
95
|
-
print(f'Product: {h.product}')
|
|
96
|
-
print(f'Serial Number: {h.serial}')
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
Platform: UNKNOWN
|
|
101
|
-
Classifier: Intended Audience :: Developers
|
|
102
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
103
|
-
Classifier: Operating System :: OS Independent
|
|
104
|
-
Classifier: Programming Language :: Python
|
|
105
|
-
Classifier: Programming Language :: Python :: 2.6
|
|
106
|
-
Classifier: Programming Language :: Python :: 2.7
|
|
107
|
-
Classifier: Programming Language :: Python :: 3
|
|
108
|
-
Description-Content-Type: text/markdown
|