Hey list,below is a try to implement a HIDresponder by AdC and myself (it was a hot day on a lake...). Seems valuable to add it to the standard distro... any hints/objections/etc. are welcome
please try them
{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;\f1\fnil\fcharset77 Monaco;\f2\fswiss\fcharset77 Helvetica; } {\colortbl;\red255\green255\blue255;\red191\green0\blue0;\red0\green0\blue191;\red96\green96\blue96; } \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural \f0\b\fs44 \cf0 HIDresponder\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural \f1\b0\fs18 \cf2 /**\ 2006 Till Bovermann, Alberto deCampo (IEM)\ */\cf0 \ \ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \f2\fs24 \cf0 Register a function to be called upon receiving a specific command from a specific HID location ID.\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural \f1\fs18 \cf0 \ (\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural \cf2 // plug in a HID device and start HIDDeviceService\cf0 \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 q = q ? ();\ \cf3 HIDDeviceService\cf0 .buildDeviceList;\ \ \cf2 // get first responding device\cf0 \ q.device = \cf3 HIDDeviceService\cf0 .devices.first\ )\ \ \cf2 // HIDresponder seperates HIDs by their locID (which is a unique id of the USB port...)\cf0 \ q.device.locID;\ \ \cf2 /* load HID and run eventloop; Do _not_ unplug your HID device now until calling\ HIDresponder.releaseAll\ */\cf0 \ \cf3 HIDresponder\cf0 .load;\ \cf3 \ HIDresponder.locDict.inspect\cf0 \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural \cf0 \ h = \cf3 HIDresponder\cf0 (q.device.locID, 4, \{ \cf3 |val, spec, resp|\cf0 [val, spec, resp].postcs \}, [0, 100].asSpec);\ h.add\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 h.remove\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural \cf0 \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf3 HIDresponder.respond(q.device.locID, 4, 1)\cf0 \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural \cf0 \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural \cf2 // use Specs\cf0 \ i = \cf3 HIDresponder\cf0 (q.device.locID, 4, \{ \cf3 |val, spec|\cf0 spec.unmap(val).postcs \}, [1, 0].asSpec).add;\ \ k = \cf3 HIDresponder\cf0 (q.device.locID, 17, \{ \cf3 |val, spec|\cf0 postf(\cf4 "upDown: %\\n"\cf0 , spec.unmap(val)) \}, [0, 255].asSpec).add;\ k.add\ \cf2 // oneShot\cf0 \ j = \cf3 HIDresponder\cf0 (q.device.locID, 4, \{ \cf3 |val, spec|\cf0 postf(\cf4 "Boooom: %\\n"\cf0 , spec.unmap(val)) \}, [1, 0].asSpec).add.removeWhenDone;\ \ \ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural \cf3 HIDresponder.releaseAll\cf0 \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 \ \ \cf2 //////////////////////////////////////////\cf0 \ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural \cf0 h = \cf3 HIDresponder\cf0 (123, 4, \{ \cf3 |val, spec, resp|\cf0 [val, spec, resp].postcs \}, [0, 100].asSpec);\ i = \cf3 HIDresponder\cf0 (123, 4);\ h == i\ \ h.value(1);\ \ \ \ h = \cf3 HIDresponder\cf0 (123, 4, \{ \cf3 |val, spec, resp|\cf0 [val, spec, resp].postcs \}, [0, 100].asSpec);\ h.add\ \ \ \cf3 HIDresponder\cf0 .respond(123, 5, 100);\ \cf3 HIDresponder\cf0 .respond(123, 4, 100);\ \ \cf3 HIDresponder\cf0 .locDict.inspect\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural \cf2 ///////////////////////////////////////\cf0 \ )}
Attachment:
HIDresponder.sc
Description: Binary data
they're for now also part of the JInT Quark package Quarks.updateAll; Quarks.install("JInT"); regards Till