-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhidraw-help.pd
183 lines (183 loc) · 7.23 KB
/
hidraw-help.pd
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
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
#N canvas 190 29 895 670 12;
#X obj 86 453 hidraw;
#X obj 95 190 hradio 15 1 0 8 empty empty empty 0 -8 0 10 #fcfcfc #000000 #000000 0;
#X msg 17 65 listdevices;
#X listbox 118 538 57 0 0 0 - - - 0;
#X obj 70 575 unpack 0 0 0 0 0 0 0 0, f 55;
#X floatatom 70 620 5 0 0 0 - - - 0;
#X floatatom 124 620 5 0 0 0 - - - 0;
#X floatatom 179 621 5 0 0 0 - - - 0;
#X floatatom 233 621 5 0 0 0 - - - 0;
#X floatatom 288 622 5 0 0 0 - - - 0;
#X floatatom 342 622 5 0 0 0 - - - 0;
#X floatatom 397 622 5 0 0 0 - - - 0;
#X floatatom 452 622 5 0 0 0 - - - 0;
#X obj 86 512 route 0 1;
#X obj 86 482 list prepend 0;
#X obj 182 455 hradio 15 1 0 2 empty empty empty 0 -8 0 10 #fcfcfc #000000 #000000 0;
#N canvas 156 156 563 451 hid-permissions 0;
#X obj 63 61 inlet;
#X obj 107 361 pdcontrol;
#X msg 60 127 browse https://www.google.com/search?q=linux+hid+permissions;
#X msg 88 191 browse https://www.google.com/search?q=macos+hid+permissions;
#X obj 166 56 inlet;
#N canvas 407 159 645 318 hidrawonwindows 0;
#X text 80 129 On Windows [hidraw] can't read from "mouses" or "keyboards". Other HIDs (like "gamepads" or "joystcks") should work out of the box., f 66;
#X restore 256 368 pd hidrawonwindows;
#X f 19;
#X obj 270 54 inlet;
#X msg 257 314 vis 1;
#X obj 255 343 s pd-hidrawonwindows;
#X msg 137 258 browse https://github.com/Lucarda/pd-hidraw;
#X obj 143 227 r github;
#X connect 0 0 2 0;
#X connect 2 0 1 0;
#X connect 3 0 1 0;
#X connect 4 0 3 0;
#X connect 6 0 7 0;
#X connect 7 0 8 0;
#X connect 9 0 1 0;
#X connect 10 0 9 0;
#X restore 662 501 pd hid-permissions;
#X obj 662 420 bng 15 250 50 0 empty empty empty 17 7 0 10 #fcfcfc #000000 #000000;
#X text 742 443 macOS;
#X text 680 419 Linux;
#X obj 723 444 bng 15 250 50 0 empty empty empty 17 7 0 10 #fcfcfc #000000 #000000;
#X msg 342 415 poll 0;
#X text 361 385 poll every <n> milliseconds;
#X text 405 415 0 to stop polling;
#X msg 296 383 poll 5;
#X obj 785 466 bng 15 250 50 0 empty empty empty 17 7 0 10 #fcfcfc #000000 #000000;
#X text 804 465 Windows;
#X msg 95 234 open \$1;
#X msg 275 345 close;
#X msg 127 270 open-vidpid 2064 1;
#X text 107 65 <-- first this. it will give the "Pd device enum" to use with "open" \, (scroll the console)., f 95;
#X floatatom 95 212 5 0 0 0 - - - 0;
#X msg 193 344 open 0;
#X text 324 344 close hid;
#X text 248 344 or;
#X text 225 183 this opens the corresponding "path" to the "Pd device enum". Note that you have to do "listdevices" to fill the internal enumeration., f 43;
#X obj 171 23 cnv 10 300 6 empty empty hidraw 0 0 0 28 #dfdfdf #404040 0;
#X text 301 29 read raw bytes from HIDs;
#X obj 827 623 bng 15 250 50 0 github empty empty 17 7 0 10 #ffffff #000000 #000000;
#X text 717 621 github repo -->;
#X msg 63 137 list-vidpid 5050 23;
#N canvas 491 47 450 618 reference 0;
#X text 132 259 1st: <list> raw bytes;
#X text 131 285 2nd: <float>;
#X text 162 306 -1 = read error;
#X text 169 324 1 = waiting;
#X text 168 341 2 = read Ok;
#X text 88 235 outlets:;
#X text 82 46 inlet:;
#X text 120 73 listdevices;
#X text 120 112 open <float>;
#X text 121 134 open-vidpid <float> <float>;
#X text 121 179 close;
#X text 121 197 poll <float>;
#X text 125 12 -- hidraw reference --;
#X text 121 93 list-vidpid <float> <float>;
#X text 120 157 open-path <symbol>;
#X text 133 374 3th: <list>;
#X text 173 398 1st: <symbol> manufacturer;
#X text 173 417 2nd: <symbol> product;
#X text 172 435 3th: <symbol> serial number;
#X text 172 455 4th: <float> VID;
#X text 172 473 5th: <float> PID;
#X text 173 490 6th: <symbol> path;
#X text 99 533 optional creation args:;
#X text 161 557 -info: create 3th outlet;
#X restore 662 546 pd reference;
#N canvas 136 55 840 614 more-ways-to-open-devices 0;
#X msg 31 241 listdevices;
#X msg 54 282 list-vidpid 5050 23;
#X msg 118 349 clear;
#X floatatom 306 44 5 0 0 0 - - - 0;
#X listbox 430 382 21 0 0 0 - - - 0;
#X listbox 470 306 45 0 0 0 - - - 0;
#X msg 643 452 open-path \$1;
#X obj 643 498 hidraw;
#X obj 656 380 bng 19 250 50 0 empty empty empty 0 -10 0 12 #fcfcfc #000000 #000000;
#X obj 643 425 symbol;
#X obj 308 147 list split 1;
#X obj 349 178 list split 1;
#X obj 389 206 list split 1;
#X obj 430 240 list split 2;
#X listbox 389 435 26 0 0 0 - - - 0;
#X listbox 349 489 31 0 0 0 - - - 0;
#X listbox 308 547 36 0 0 0 - - - 0;
#X text 440 354 VID PID:;
#X text 484 279 path:;
#X text 359 470 product:;
#X text 315 527 manufacturer:;
#X text 399 410 serial number:;
#X obj 38 438 hidraw -info;
#X obj 37 320 t a b;
#X text 620 344 4) open the device with "open-path"., f 24;
#X text 351 41 3) then inspect each line of the populated [text]. do some logic if needed (not shown here).;
#X text 25 172 2) do "listdevices" to populate a [text] object with all the devices founded via the 3th outlet., f 36;
#X text 26 43 1) note creation argument "-info" in the [hidraw -info] object created below. this adds a 3th outlet that outputs a list on each founded device. also when created this way the object does not prints the device listing to the console., f 35;
#X obj 118 378 text define some-info;
#X obj 119 524 text insert some-info;
#X obj 306 117 text get some-info;
#X text 139 440 <-- see creation argument and 3th outlet, f 21;
#X connect 0 0 23 0;
#X connect 1 0 23 0;
#X connect 2 0 28 0;
#X connect 3 0 30 0;
#X connect 5 0 9 1;
#X connect 6 0 7 0;
#X connect 8 0 9 0;
#X connect 9 0 6 0;
#X connect 10 0 16 0;
#X connect 10 1 11 0;
#X connect 11 0 15 0;
#X connect 11 1 12 0;
#X connect 12 0 14 0;
#X connect 12 1 13 0;
#X connect 13 0 4 0;
#X connect 13 1 5 0;
#X connect 22 2 29 0;
#X connect 23 0 22 0;
#X connect 23 1 2 0;
#X connect 30 0 10 0;
#X restore 165 310 pd more-ways-to-open-devices;
#X text 654 384 see also:;
#X text 212 129 <-- optionally "enumerate" HIDs identified by VID PID. "0" acts as "no filter" for that field so that "list-vidpid 0 0" is the same as "listdevices". a VID PID enumerates only same manufacturer/model HIDs (useful if you have 2 same joysticks connected)., f 92;
#X text 270 263 open device via VID PID (shown in the console if you did "listdevices"). Note that this can be used without a prior "listdevices" message., f 74;
#N canvas 26 26 708 351 vid-pid-and-path-explained 0;
#X text 126 192 "path" is given by the OS when the device is plugged and depends on many variables as: order of connection \, number of connected devices \, etc.;
#X text 105 52 VID PID;
#X text 100 165 path;
#X text 243 13 VID PID and "path" explained;
#X text 125 84 VID PID stands for "Vendor Id" and "Product Id". these are 2 numeric values that are hard-coded on the device and are used to identify it. each time you connect the device you'll get these 2 hard-coded numbers no matter in what OS or app.;
#X restore 41 99 pd vid-pid-and-path-explained;
#X text 273 100 <-- important. read this., f 95;
#X text 374 306 <-- further interaction with the patch via a 3th outlet., f 38;
#X connect 0 0 14 0;
#X connect 1 0 31 0;
#X connect 2 0 0 0;
#X connect 4 0 5 0;
#X connect 4 1 6 0;
#X connect 4 2 7 0;
#X connect 4 3 8 0;
#X connect 4 4 9 0;
#X connect 4 5 10 0;
#X connect 4 6 11 0;
#X connect 4 7 12 0;
#X connect 13 0 4 0;
#X connect 13 1 3 0;
#X connect 14 0 13 0;
#X connect 15 0 14 1;
#X connect 17 0 16 0;
#X connect 20 0 16 1;
#X connect 21 0 0 0;
#X connect 24 0 0 0;
#X connect 25 0 16 2;
#X connect 27 0 0 0;
#X connect 28 0 0 0;
#X connect 29 0 0 0;
#X connect 31 0 27 0;
#X connect 32 0 0 0;
#X connect 40 0 0 0;