This file is indexed.

/usr/share/SuperCollider/HelpSource/Classes/HID.schelp is in supercollider-common 1:3.8.0~repack-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
TITLE:: HID
summary:: This class provides access to human input devices, or in short HID, such as joysticks, gamepads, mice, keyboard, and so on.
categories:: External Control>HID
related:: Classes/HIDFunc, Guides/Working_with_HID, Classes/HIDElement, Classes/HIDCollection, Classes/HIDUsage, Classes/HIDInfo

DESCRIPTION::
Human input devices can be used as controllers for making music. This class provides you with access to them in a simple and transparent way.

The development of this SuperCollider implementation of HID access was funded by the SuperCollider community and BEK, Bergen Elektronisk Kunst, Bergen, Norway, http://www.bek.no

SUBSECTION:: Introduction
In general using an Human Input Device follows this scheme:

DEFINITIONLIST::
	## Find available devices:
	|| code:: HID.findAvailable; ::
	## Print a readable list of available devices:
	|| code:: HID.postAvailable; ::
	## Open a specific device:
	|| code:: ~myhid = HID.open( 1103, 53251 ); ::
	## Set actions for specific elements:
	|| code:: ~myhid.elements[1].action = { |...args| args.postln; };
::

See LINK::Guides/Working_with_HID:: for a full introduction.

::


CLASSMETHODS::

PRIVATE:: doPrAction, prInitHID, prCloseAll, prOpenDevice, prCloseDevice, prHIDDeviceClosed, prGetDeviceInfo, prGetNumberOfCollections, prGetCollectionInfo, prGetNumberOfElements, prGetElementInfo, prSetElementOutput, prSetElementRepeat, prbuildDeviceList, deviceClosed, prHIDElementData, prHIDDeviceData, basicNew, mergeUsageDict, removeUsageDict

SUBSECTION:: Finding devices

METHOD:: findAvailable
queries the operating system which HID devices are attached to the system and can be accessed. When using HID this is the first method you need to execute, before you can access any device.

returns:: an IdentityDictionary of available devices

METHOD:: available
A dictionary of available devices, or rather info about them in an instance of LINK::Classes/HIDInfo::, populated by the method findAvailable

returns:: an IdentityDictionary

METHOD:: postAvailable
posts a human readable list of available HID devices and their properties (see also LINK::Classes/HIDInfo::)


METHOD:: findBy
Find devices in the available device dictionary by specifying one or more characteristics of the device

ARGUMENT:: vendorID
The vendor ID of the device, this is a number encoded by the device itself, and the same across platforms.

ARGUMENT:: productID
The product ID of the device, this is a number encoded by the device itself, and the same across platforms.

ARGUMENT:: path
The path of the device, this is a path defined by the operating system, and thus not the same across platforms, but essential to distinguish devices with the same vendor and product ID from each other.

ARGUMENT:: serial
The serial number of the device. This is dependent on the operating system, e.g. on Linux it is not set.

ARGUMENT:: releaseNumber
The release number of the device, this is a number encoded by the device itself, and the same across platforms.

returns:: an IdentityDictionary of devices the match the search query, or nil if no arguments are given


METHOD:: availableUsages
A dictionary of available usages from all HIDs, populated automatically when devices are opened and closed.

returns:: an IdentityDictionary


METHOD:: postAvailableUsages
posts a human readable list of available HID usages and their properties (see also LINK::Classes/HIDElement:: and LINK::Classes/HIDUsage::)


SUBSECTION:: Opening devices

METHOD:: open
Open a device with a given vendorID, product ID and optionally a path.

ARGUMENT:: vendorID
The vendor ID of the device

ARGUMENT:: productID
The product ID of the device

ARGUMENT:: path
(optional) The path in the operating system, e.g. "/dev/hidraw0" on Linux.
If not specified, the method will look for a matching device in the device list, and open the first match it finds.

returns:: The HID device - an instance of HID.

METHOD:: new
Same as HID.open


METHOD:: openPath
Open a device using its path in the operating system

ARGUMENT:: path
The path in the operating system, e.g. "/dev/hidraw0" on Linux

returns:: The HID device - an instance of HID.

METHOD:: openAt
Open a device using its index in the dictionary of available devices

ARGUMENT:: index
The index into the dictionary of available devices

returns:: The HID device - an instance of HID.


METHOD:: openDevices
A dictionary of the opened devices

returns:: an IdentityDictionary


SUBSECTION:: Adding functions to HID events

Whenever data comes in from an opened HID device, there are two types of actions fired. An action for the incoming element data and an action for the device, indicating that there has been a change in one of the elements. In most cases you will want to use the first action; only in cases where the order of parsing the element data is important, you may want to use the second type - e.g. when dealing with very accurately timed button press combinations.

There are three levels where you can set actions:
LIST::
	## at the global level - called for any HID device, for any element
	## at the device level - called for the specific device, for any element
	## at the element level - called for the specific element of the specific device
::

Alternately, you can also use the LINK::Classes/HIDFunc:: interface.



METHOD:: debug
When set to true, the incoming data from any opened HID device will be printed to the post window.



METHOD:: action
Set or get the action to be performed upon receiving element data from the device. The function will be passed the following arguments: the value (mapped between 0 and 1), the raw value, element usage page, the element usage, the element id, the device id, the device (an instance of HID).

ARGUMENT:: function
The function to be performed upon receiving element data from the device


METHOD:: addRecvFunc
add a function to the internal FunctionList that will be evaluated whenever element data comes in from an open device. The arguments passed to the function are as defined above.
Use this method if you want to add actions to HID functions from classes you write, so that you still keep the option to add an action on the fly from user code.

ARGUMENT:: function
The function to be added to the list.


METHOD:: removeRecvFunc
remove a function to the internal FunctionList that will be evaluated whenever data comes in from a device.


ARGUMENT:: function
The function to remove from the list, this must be a reference to the Function that was originally added to the list


METHOD:: deviceAction
set an action or function to be performed whenever there is an update to any device's elements.

ARGUMENT:: function
The function to be performed upon receiving data from the device


METHOD:: addDevFunc
add a function to the internal FunctionList that will be evaluated whenever data comes in from a device.

ARGUMENT:: function
The function to be performed upon receiving data from the device


METHOD:: removeDevFunc
remove a function to the internal FunctionList that will be evaluated whenever data comes in from a device.


ARGUMENT:: function
The function to remove from the list, this must be a reference to the Function that was originally added to the list




SUBSECTION:: Managing the HID subsystem

The following methods are used internally to initialize and finalize the HID subsystem, but in rare cases you may wish to manage these methods manually.

METHOD:: initializeHID
Initialize the HID subsystem, this method is called automatically when calling the method findAvailable.


METHOD:: running
Indicates whether or not the HID subsystem is running.


METHOD:: closeAll
This method is called automatically upon Shutdown, if the HID subsystem was initialized. It can be stopped manually, in order to save system resources. This method will close all opened HID devices.


INSTANCEMETHODS::

PRIVATE::init, getInfo, getElements, getElementInfo, getCollections, getCollectionInfo, getUsages, id, valueAction, valueDeviceAction, info_, prDeviceClosed


METHOD:: elements
An IdentityDictionary holding all the elements, i.e. controls, of the device


METHOD:: findElementWithUsage
Find all elements with a certain usage and usagePage.

ARGUMENT:: elUsage
The usage index of the element

ARGUMENT:: elUsagePage
The usage page of the element

returns:: an Array with the found elements


METHOD:: getElementWithID
Get the element with the given index

ARGUMENT:: elid
The index of the element

returns:: the HIDElement

METHOD:: close
Close the HID device, closing a device is asynchronous. You can set a closeAction (see below), which will be performed when the device closes.

METHOD:: isOpen
Returns true if the device is open, false if the device was closed.

returns: a Boolean


METHOD:: collections
An IdentityDictionary holding all the collections, i.e. groups of controls, of the device



SUBSECTION:: Adding functionality to the device

METHOD:: debug
When set to true, the incoming data from this HID device will be printed to the post window.


METHOD:: closeAction
Function to be performed when device is closed.


METHOD:: action
Set or get the action to be performed upon receiving element data from the device. The function will be passed the following arguments: the value (mapped between 0 and 1), the raw value, element usage page, the element usage, the element id

ARGUMENT:: function
The function to be performed upon receiving element data from the device


METHOD:: deviceAction
set an action or function to be performed whenever there is an update to any of the device's elements.

ARGUMENT:: function
The function to be performed upon receiving data from the device



SUBSECTION:: Posting human readable information about the device

METHOD:: postInfo
Post the HIDInfo of this device in a human readable format

METHOD:: postCollections
Post information about all the collections of this device in a human readable format

METHOD:: postElements
Post information about all the elements of this device in a human readable format

METHOD:: postInputElements
Post information about all the input elements of this device in a human readable format

METHOD:: postOutputElements
Post information about all the output elements of this device in a human readable format

METHOD:: postFeatureElements
Post information about all the feature elements of this device in a human readable format


METHOD:: postUsages
Post information about all the usages of this device in a human readable format


SUBSECTION:: Properties of the device

METHOD:: info
Retrieve the HIDInfo of this device

returns:: an instance of HIDInfo


METHOD:: usage
Retrieve the usage index of a collection of this device, or the main usage of the device (if called without an argument).

ARGUMENT:: collectionID
The collection of which to retrieve the usage. Default is 0, which should define the primary usage of the device.

returns:: the usage index of this device

METHOD:: usageName
Retrieve the usage name of a collection of this device, or the main usage of the device (if called without an argument). The name is looked up from the standardized HID usage tables using the usage index.

ARGUMENT:: collectionID
The collection of which to retrieve the usage. Default is 0, which should define the primary usage of the device.

returns:: the usage name of this device


METHOD:: usagePage
Retrieve the usage page index of a collection of this device, or the main page of the device (if called without an argument). The name is looked up from the standardized HID usage tables using the usage page index.

ARGUMENT:: collectionID
The collection of which to retrieve the usage page. Default is 0, which should define the primary usage of the device.

returns:: the usage page index of this device


METHOD:: pageName

Retrieve the page name of a collection of this device, or the main page of the device (if called without an argument). The name is looked up from the standardized HID usage tables using the usage page index.

ARGUMENT:: collectionID
The collection of which to retrieve the usage page name. Default is 0, which should define the primary usage of the device.

returns:: the usage page name of this device


METHOD:: vendor
Retrieve the vendor id of this device

returns:: the vendor id


METHOD:: product
Retrieve the product id of this device

returns:: the product id


METHOD:: usages
Retrieve the usages of the elements of this device.

returns:: an IdentityDictionary with usages as keys and lists of elements as corresponding elements



EXAMPLES::

code::
HID.findAvailable; // check which devices are attached
~myhid = HID.open( 1103, 53251 ); // open the Run'N' Drive game controller

s.boot; // boot the server

Ndef( \sinewave, { |freq=500, amp=0.1| SinOsc.ar( freq, 0, amp * 0.2 ) } );
Ndef( \sinewave ).play;

~freqRange = [500, 5000, \exponential].asSpec; // create a frequency range

HIDdef.usage( \freq, { |value| Ndef( \sinewave ).set( \freq, ~freqRange.map( value ) ); }, \X );
HIDdef.usage( \amp, { |value| Ndef( \sinewave ).set( \amp, value ); }, \Y );
::