HIDresponder
/**
2006 Till Bovermann, Alberto deCampo (IEM)
*/
Register a function to be called upon receiving a specific command from a specific HID location ID.
(
// plug in a HID device and start HIDDeviceService
q = q ? ();
HIDDeviceService.buildDeviceList;
// get first responding device
q.device = HIDDeviceService.devices.first
)
// HIDresponder seperates HIDs by their locID (which is a unique id of the USB port...)
q.device.locID;
/* load HID and run eventloop; Do _not_ unplug your HID device now until calling
HIDresponder.releaseAll
*/
HIDresponder.load;
HIDresponder.locDict.inspect
h = HIDresponder(q.device.locID, 4, { |val, spec, resp| [val, spec, resp].postcs }, [0, 100].asSpec);
h.add
h.remove
HIDresponder.respond(q.device.locID, 4, 1)
// use Specs
i = HIDresponder(q.device.locID, 4, { |val, spec| spec.unmap(val).postcs }, [1, 0].asSpec).add;
k = HIDresponder(q.device.locID, 17, { |val, spec| postf("upDown: %\n", spec.unmap(val)) }, [0, 255].asSpec).add;
k.add
// oneShot
j = HIDresponder(q.device.locID, 4, { |val, spec| postf("Boooom: %\n", spec.unmap(val)) }, [1, 0].asSpec).add.removeWhenDone;
HIDresponder.releaseAll
//////////////////////////////////////////
h = HIDresponder(123, 4, { |val, spec, resp| [val, spec, resp].postcs }, [0, 100].asSpec);
i = HIDresponder(123, 4);
h == i
h.value(1);
h = HIDresponder(123, 4, { |val, spec, resp| [val, spec, resp].postcs }, [0, 100].asSpec);
h.add
HIDresponder.respond(123, 5, 100);
HIDresponder.respond(123, 4, 100);
HIDresponder.locDict.inspect
///////////////////////////////////////
)