1 /* Wrapper for LID for General HID support */
5 classvar <debug = false;
8 // dummy action, not used, but here for compatibility with osx
12 if ( \LID.asClass.notNil, {
13 Class.initClassTree( Event );
14 extraClasses = Event.new;
15 Class.initClassTree( GeneralHID );
16 GeneralHID.add( this );
22 *put { arg key, object;
23 extraClasses.put( key, object );
26 *doesNotUnderstand { arg selector ... args;
27 ^extraClasses.perform( selector, *args );
30 // ------------ functions ------------
33 deviceList = LID.buildDeviceList.collect{ |dev,i|
34 [ dev[0], this.getInfo( dev ) ]
40 "HID devices at your disposal:".postln;
41 deviceList.do{ |dev,i|
42 "\t%:\t[%], vendor: %, product: %, locID: [\"%\"], path: [\"%\"]\n".postf( i, dev[1].name, dev[1].vendor, dev[1].product, dev[1].physical, dev[0] );
46 *postDevicesAndProperties {
47 LID.deviceList.do({arg dev;
49 if ( dev[1].isKindOf( LIDInfo ), {
51 [ dev[1].vendor, dev[1].asString, dev[0]].postcs;
52 //[dev[0], dev[1].name, dev[1].product, dev[1].vendor, dev[1].version].postcs;
53 dev[2].keysValuesDo{ |key,slotgroup,i|
54 ("\t"++key+LIDSlot.slotTypeStrings[key]).postln;
57 if ( slot.isKindOf( LIDAbsSlot ),{
58 [ slot.type, LIDSlot.slotTypeStrings[slot.type], slot.code, slot.info.asString ].postcs;
60 [ slot.type, LIDSlot.slotTypeStrings[slot.type], slot.code ].postcs;
70 *startEventLoop{ |rate|
71 // event loop starts at startup with LID
75 // event loop is stopped at shutdown with LID
79 ^LID.eventLoopIsRunning;
87 ^super.new.init( dev );
92 if ( dev[1].isKindOf( LIDInfo ), {
93 info = GeneralHIDInfo.new(
103 info = GeneralHIDInfo.new( "could not open device" );
113 if ( dev[1].isKindOf( LIDInfo ) or: dev[1].isKindOf( GeneralHIDInfo ),
115 device = LID.new( dev[0] );
116 ^GeneralHIDDevice.new( this );
118 "not a valid device or could not open device".warn;
125 info = GeneralHIDInfo.new(
131 device.info.physical,
138 var mySlots = IdentityDictionary.new;
139 var devSlots = device.slots;
140 devSlots.keysValuesDo{ |key,value,i|
141 // (""++i+"key"+key+"value"+value).postcs;
142 mySlots[key] = IdentityDictionary.new;
143 value.keysValuesDo{ |key2,value2,i2|
144 mySlots[key][key2] = GeneralHIDSlot.new( key, key2, device, value2 );