sclang: ServerShmInterface - try to avoid multiple destructor calls
[supercollider.git] / HelpSource / Classes / Phid.schelp
blob827e6dde92640d6ca83c5cead4b4e9677e5fb127
1 class:: Phid
2 summary:: pattern that polls values from an OSX hid device
3 related:: Classes/PhidKey, Classes/PhidSlot
4 categories:: Streams-Patterns-Events>Patterns>User Input
6 description::
8 note::
9 This class is OSX specific. Please use the cross platform versions (based on link::Classes/GeneralHID::), link::Classes/PhidKey:: or link::Classes/PhidSlot::, instead.
12 ClassMethods::
14 method::new
16 argument::element
17 one element of the interface of the device, like a button or an axis. Can be an index or, if the devicespec is present, also a symbol.
19 argument::locID
20 the index of the device, defaults to 0 (first device).
22 argument::repeats
23 number of values to return.
25 Examples::
27 code::
28 // while this is running, test your device
30 a = Phid(0,0);
31 x = a.asStream;
33 Routine({ loop({
34         x.next.postln;
35         0.2.wait;
36 }) }).play;
39 // using devicespecs:
40 // for example wingman. for other specs see HIDDeviceService
42 HIDDeviceService.deviceSpecs.put('WingMan Action Pad',
43         IdentityDictionary[
44                 // buttons
45                 \a -> 0, \b-> 1, \c-> 2,
46                 \x-> 3, \y-> 4, \z-> 5,
47                 \l-> 6,                 //front left
48                 \r-> 7,                 //front right
49                 \s-> 8,
50                 \mode-> 9,
51                 \xx-> 10,               //analog controller x axis
52                 \yy-> 11,               //analog controller y axis
53                 \slider-> 12,
54                 \hat-> 13
55         ])
59 // then you can use the named key:
61 a = Phid(\x, 0, inf);
62 x = a.asStream;
64 Routine({ loop({
65         x.next.postln;
66         0.2.wait;
67 }) }).play;
71 // 'musical' example:
73         Pbind(
74                 \freq, Pseq([Phid(\x,0,8),Phid(\y,0,8)],inf) * 500 + 200,
75                 \dur, Phid(\slider) + 0.02,
76                 \pan, Phid(\hat) * 2 - 1
77         ).play;