Update of /cvsroot/pure-data/externals/hcs/hid In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21615
Modified Files: hid-help.pd hid.c hid.h hid_darwin.c Log Message: mice and joysticks work under MacOS X now, but there is much work left to be done in terms of translating HID Manager to Linux Input events.
Index: hid_darwin.c =================================================================== RCS file: /cvsroot/pure-data/externals/hcs/hid/hid_darwin.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** hid_darwin.c 4 Nov 2004 17:24:18 -0000 1.4 --- hid_darwin.c 6 Nov 2004 01:03:01 -0000 1.5 *************** *** 59,64 **** #include "hid.h"
! //#define DEBUG(x) ! #define DEBUG(x) x
/*============================================================================== --- 59,64 ---- #include "hid.h"
! #define DEBUG(x) ! //#define DEBUG(x) x
/*============================================================================== *************** *** 82,87 **** --- 82,100 ---- *============================================================================== */ + + /* conversion functions */ char *convertEventsFromDarwinToLinux(pRecElement element);
+ /* IOKit HID Utilities functions from SC_HID.cpp */ + void releaseHIDDevices(void); + int prHIDBuildElementList(t_hid *x); + int prHIDBuildDeviceList(void); + int prHIDGetValue(void); + void PushQueueEvents_RawValue(void); + void PushQueueEvents_CalibratedValue(void); + int prHIDReleaseDeviceList(void); + //int prHIDRunEventLoop(void); + //int prHIDStopEventLoop(void); + /*============================================================================== * EVENT TYPE/CODE CONVERSION FUNCTIONS *************** *** 89,96 **** */
! char *convertDarwinToLinuxType(IOHIDElementType type) { - char *returnType = ""; - switch (type) { --- 102,107 ---- */
! void convertDarwinToLinuxType(IOHIDElementType type, char *returnType) { switch (type) { *************** *** 120,129 **** sprintf(returnType, "unknown"); }
! return(returnType); }
/* ============================================================================== */ /* Pd [hid] FUNCTIONS */ /* ============================================================================== */ --- 131,224 ---- sprintf(returnType, "unknown"); } + }
! void convertAxis(pRecElement element, char *linux_type, char *linux_code, char axis) ! { ! if (element->relative) ! { ! sprintf(linux_type,"ev_rel"); ! sprintf(linux_code,"rel_%c",axis); ! } ! else ! { ! sprintf(linux_type,"ev_abs"); ! sprintf(linux_code,"abs_%c",axis); ! } ! } ! ! void convertDarwinElementToLinuxTypeCode(pRecElement element, char *linux_type, char *linux_code) ! { ! t_int button_offset = 0; ! ! switch(element->type) ! { ! case kIOHIDElementTypeInput_Button: ! sprintf(linux_type, "ev_key"); ! break; ! } ! ! switch (element->usagePage) ! { ! case kHIDPage_GenericDesktop: ! switch (element->usage) ! { ! case kHIDUsage_GD_X: convertAxis(element, linux_type, linux_code, 'x'); break; ! case kHIDUsage_GD_Y: convertAxis(element, linux_type, linux_code, 'y'); break; ! case kHIDUsage_GD_Z: convertAxis(element, linux_type, linux_code, 'z'); break; ! case kHIDUsage_GD_Rx: convertAxis(element, linux_type, linux_code, 'x'); break; ! case kHIDUsage_GD_Ry: convertAxis(element, linux_type, linux_code, 'y'); break; ! case kHIDUsage_GD_Rz: convertAxis(element, linux_type, linux_code, 'z'); break; ! } ! break; ! case kHIDPage_Button: ! sprintf(linux_type, "ev_key"); ! sprintf(linux_code, "btn_%ld", element->usage); ! break; ! } }
/* ============================================================================== */ + /* DARWIN-SPECIFIC SUPPORT FUNCTIONS */ + /* ============================================================================== */ + + t_int hid_build_element_list(t_hid *x) + { + DEBUG(post("hid_build_element_list");); + + UInt32 i; + pRecElement devElement; + pRecDevice pCurrentHIDDevice; + UInt32 numElements; + char cstrElementName[256]; + + // look for the right device using locID + pCurrentHIDDevice = HIDGetFirstDevice (); + while (pCurrentHIDDevice && (pCurrentHIDDevice->locID != x->x_locID)) + pCurrentHIDDevice = HIDGetNextDevice (pCurrentHIDDevice); + if(!pCurrentHIDDevice) return (1); + + devElement = HIDGetFirstDeviceElement(pCurrentHIDDevice, kHIDElementTypeInput); + numElements = HIDCountDeviceElements(pCurrentHIDDevice, kHIDElementTypeInput); + + post("[hid] found %d elements:",numElements); + + for(i=0; i<numElements; i++) + { + //type + HIDGetTypeName((IOHIDElementType) devElement->type, cstrElementName); + post(" Type: %s %d 0x%x",cstrElementName,devElement->type,devElement->type); + convertDarwinToLinuxType((IOHIDElementType) devElement->type, cstrElementName); + post(" Type: %s %d 0x%x",cstrElementName,devElement->type,devElement->type); + //usage + HIDGetUsageName (devElement->usagePage, devElement->usage, cstrElementName); + post(" Usage/Code: %s %d 0x%x",cstrElementName,devElement->usage,devElement->usage); + + devElement = HIDGetNextDeviceElement (devElement, kHIDElementTypeInput); + } + return (0); + } + + /* ============================================================================== */ /* Pd [hid] FUNCTIONS */ /* ============================================================================== */ *************** *** 136,143 **** pRecDevice pCurrentHIDDevice; pRecElement pCurrentHIDElement; ! // char *type = ""; ! // char *code = ""; t_atom event_data[4];
// look for the right device: pCurrentHIDDevice = HIDGetFirstDevice (); --- 231,243 ---- pRecDevice pCurrentHIDDevice; pRecElement pCurrentHIDElement; ! IOHIDEventStruct event; ! char type[256]; ! char code[256]; ! char event_output_string[256]; t_atom event_data[4];
+ int event_counter = 0; + Boolean result; + // look for the right device: pCurrentHIDDevice = HIDGetFirstDevice (); *************** *** 146,186 **** if(!pCurrentHIDDevice) return (1);
! ! /* get the first element */ ! pCurrentHIDElement = HIDGetFirstDeviceElement (pCurrentHIDDevice, kHIDElementTypeIO); ! /* cycle thru all elements */ ! while (pCurrentHIDElement) { ! value = HIDGetElementValue (pCurrentHIDDevice, pCurrentHIDElement); ! if (pCurrentHIDElement) ! { ! value = HIDGetElementValue (pCurrentHIDDevice, pCurrentHIDElement); ! // if it's not a button and it's not a hatswitch then calibrate ! /* if(( pCurrentHIDElement->type != kIOHIDElementTypeInput_Button ) && */ ! /* ( pCurrentHIDElement->usagePage == 0x01 && pCurrentHIDElement->usage != kHIDUsage_GD_Hatswitch)) */ ! /* value = HIDCalibrateValue ( value, pCurrentHIDElement ); */
! /* type */ ! // HIDGetTypeName(pCurrentHIDElement->type,type); ! // SETSYMBOL(event_data, gensym(type)); ! /* code */ ! // HIDGetUsageName(pCurrentHIDElement->usagePage, pCurrentHIDElement->usage, code); ! // SETSYMBOL(event_data + 1, gensym(code)); ! /* value */ ! // SETFLOAT(event_data + 2, (t_float)value); ! /* time */ ! // TODO temp space filler for testing, got to find where I get the event time ! // SETFLOAT(event_data + 3, (t_float)value); ! // SETFLOAT(event_data + 3, (t_float)(hid_input_event.time).tv_sec); ! // outlet_anything(x->x_obj.te_outlet,atom_gensym(event_data),3,event_data+1); ! } ! pCurrentHIDElement = HIDGetNextDeviceElement (pCurrentHIDElement, kHIDElementTypeIO); } return (0); }
- t_int hid_open_device(t_hid *x, t_int device_number) { --- 246,325 ---- if(!pCurrentHIDDevice) return (1);
! // result = HIDGetEvent(pCurrentHIDDevice, (void*) &event); ! // if(result) ! while( (HIDGetEvent(pCurrentHIDDevice, (void*) &event)) && (event_counter < 64) ) { ! value = event.value; ! //post("found event: %d",value); ! IOHIDElementCookie cookie = (IOHIDElementCookie) event.elementCookie; ! ! // find the pRecElement using the cookie ! pCurrentHIDElement = HIDGetFirstDeviceElement (pCurrentHIDDevice, kHIDElementTypeIO); ! while (pCurrentHIDElement && (pCurrentHIDElement->cookie != cookie)) ! pCurrentHIDElement = HIDGetNextDeviceElement (pCurrentHIDElement, kHIDElementTypeIO); ! // convertDarwinToLinuxType((IOHIDElementType) pCurrentHIDElement->type, event_output_string); ! HIDGetUsageName(pCurrentHIDElement->usagePage, pCurrentHIDElement->usage, event_output_string);
! HIDGetElementNameFromVendorProductCookie( ! pCurrentHIDDevice->vendorID, pCurrentHIDDevice->productID, ! (long) pCurrentHIDElement->cookie, event_output_string); ! ! convertDarwinElementToLinuxTypeCode(pCurrentHIDElement,type,code); ! DEBUG(post("type: %s code: %s event name: %s",type,code,event_output_string);); ! SETSYMBOL(event_data, gensym(type)); ! /* code */ ! SETSYMBOL(event_data + 1, gensym(code)); ! /* value */ ! SETFLOAT(event_data + 2, (t_float)value); ! /* time */ ! // TODO: convert this to a common time format, i.e. Linux struct timeval ! SETFLOAT(event_data + 3, (t_float)(event.timestamp).lo); ! ! outlet_anything(x->x_obj.te_outlet,atom_gensym(event_data),3,event_data+1); ! ! ++event_counter; } + DEBUG( + if(event_counter) + post("output %d events",event_counter); + ); + /* /* get the first element */ */ + /* pCurrentHIDElement = HIDGetFirstDeviceElement (pCurrentHIDDevice, kHIDElementTypeIO); */ + /* /* cycle thru all elements */ */ + /* while (pCurrentHIDElement) */ + /* { */ + /* //value = HIDGetElementValue (pCurrentHIDDevice, pCurrentHIDElement); */ + + /* if (pCurrentHIDElement) */ + /* { */ + /* value = HIDGetElementValue (pCurrentHIDDevice, pCurrentHIDElement); */ + /* post("current value: %d", value); */ + /* // if it's not a button and it's not a hatswitch then calibrate */ + /* /* if(( pCurrentHIDElement->type != kIOHIDElementTypeInput_Button ) && */ */ + /* /* ( pCurrentHIDElement->usagePage == 0x01 && pCurrentHIDElement->usage != kHIDUsage_GD_Hatswitch)) */ */ + /* /* value = HIDCalibrateValue ( value, pCurrentHIDElement ); */ */ + + /* /* type */ */ + /* //HIDGetTypeName(pCurrentHIDElement->type,type); */ + /* convertDarwinToLinuxType((IOHIDElementType) pCurrentHIDElement->type, event_output_string); */ + /* SETSYMBOL(event_data, gensym(event_output_string)); */ + /* /* code */ */ + /* HIDGetUsageName(pCurrentHIDElement->usagePage, pCurrentHIDElement->usage, event_output_string); */ + /* SETSYMBOL(event_data + 1, gensym(event_output_string)); */ + /* /* value */ */ + /* SETFLOAT(event_data + 2, (t_float)value); */ + /* /* time */ */ + /* // TODO temp space filler for testing, got to find where I get the event time */ + /* SETFLOAT(event_data + 3, (t_float)value); */ + /* // SETFLOAT(event_data + 3, (t_float)(hid_input_event.time).tv_sec); */ + /* outlet_anything(x->x_obj.te_outlet,atom_gensym(event_data),3,event_data+1); */ + /* } */ + /* pCurrentHIDElement = HIDGetNextDeviceElement (pCurrentHIDElement, kHIDElementTypeIO); */ + /* } */ return (0); }
t_int hid_open_device(t_hid *x, t_int device_number) { *************** *** 216,225 ****
x->x_locID = currentDevice->locID; - // TODO: buildElementList(), outputting text to console - // TODO: queue all elements except absolute axes
post("[hid] opened device %d: %s %s", device_number, currentDevice->manufacturer, currentDevice->product);
return (0); } --- 355,367 ----
x->x_locID = currentDevice->locID;
post("[hid] opened device %d: %s %s", device_number, currentDevice->manufacturer, currentDevice->product);
+ hid_build_element_list(x); + + HIDQueueDevice(currentDevice); + // TODO: queue all elements except absolute axes + return (0); } *************** *** 230,235 **** DEBUG(post("hid_close_device"););
! post("close_device %d",x->x_device_number); ! releaseHIDDevices();
return (0); --- 372,379 ---- DEBUG(post("hid_close_device"););
! post("[hid] close_device %d",x->x_device_number); ! HIDReleaseAllDeviceQueues(); ! HIDReleaseDeviceList(); ! gNumberOfHIDDevices = 0;
return (0); *************** *** 241,245 ****
/* the device list should be refreshed here */ ! if ( (prHIDBuildDeviceList()) && (prHIDBuildElementList()) ) return (0); else --- 385,389 ----
/* the device list should be refreshed here */ ! if ( (prHIDBuildDeviceList()) && (prHIDBuildElementList(x)) ) return (0); else *************** *** 250,254 ****
/*============================================================================== ! * HID UTILIES FUNCTIONS *============================================================================== */ --- 394,398 ----
/*============================================================================== ! * HID UTILIES FUNCTIONS FROM SC_HID.cpp *============================================================================== */ *************** *** 268,277 **** }
! int prHIDBuildElementList(void) { DEBUG(post("prHIDBuildElementList"););
int locID = NULL; - int cookieNum = NULL; UInt32 i; pRecElement devElement; --- 412,420 ---- }
! int prHIDBuildElementList(t_hid *x) { DEBUG(post("prHIDBuildElementList"););
int locID = NULL; UInt32 i; pRecElement devElement; *************** *** 285,289 **** // look for the right device using locID pCurrentHIDDevice = HIDGetFirstDevice (); ! while (pCurrentHIDDevice && (pCurrentHIDDevice->locID !=locID)) pCurrentHIDDevice = HIDGetNextDevice (pCurrentHIDDevice); if(!pCurrentHIDDevice) return (1); --- 428,432 ---- // look for the right device using locID pCurrentHIDDevice = HIDGetFirstDevice (); ! while (pCurrentHIDDevice && (pCurrentHIDDevice->locID != x->x_locID)) pCurrentHIDDevice = HIDGetNextDevice (pCurrentHIDDevice); if(!pCurrentHIDDevice) return (1); *************** *** 306,313 **** //SetObject(devElementArray->slots+devElementArray->size++, devstring); //g->gc->GCWrite(devElementArray, (PyrObject*) devstring); - //cookie - post("Cookie: %d %d %d",devElement->cookie,devElement->min,devElement->max); ! devElement = HIDGetNextDeviceElement (devElement, kHIDElementTypeInput); } return (0); --- 449,454 ---- //SetObject(devElementArray->slots+devElementArray->size++, devstring); //g->gc->GCWrite(devElementArray, (PyrObject*) devstring); ! devElement = HIDGetNextDeviceElement (devElement, kHIDElementTypeInput); } return (0); *************** *** 537,646 **** /* } */
- - int prHIDQueueDevice(void) - { - DEBUG(post("prHIDQueueDevice");); - - int locID = NULL; - int cookieNum = NULL; - - //PyrSlot *a = g->sp - 1; //class - //PyrSlot *b = g->sp; //locID device - //int err = slotIntVal(b, &locID); - //if (err) return err; - //look for the right device: - pRecDevice pCurrentHIDDevice = HIDGetFirstDevice (); - while (pCurrentHIDDevice && (pCurrentHIDDevice->locID !=locID)) - pCurrentHIDDevice = HIDGetNextDevice (pCurrentHIDDevice); - if(!pCurrentHIDDevice) return (1); - HIDQueueDevice(pCurrentHIDDevice); - return (0); - } - - - int prHIDQueueElement(void) - { - DEBUG(post("prHIDQueueElement");); - - int locID = NULL; - int cookieNum = NULL; - - //PyrSlot *a = g->sp - 2; //class - //PyrSlot *b = g->sp - 1; //locID device - //PyrSlot *c = g->sp; //element cookie - //int err = slotIntVal(b, &locID); - //if (err) return err; - //err = slotIntVal(c, &cookieNum); - //if (err) return err; - IOHIDElementCookie cookie = (IOHIDElementCookie) cookieNum; - //look for the right device: - pRecDevice pCurrentHIDDevice = HIDGetFirstDevice (); - while (pCurrentHIDDevice && (pCurrentHIDDevice->locID !=locID)) - pCurrentHIDDevice = HIDGetNextDevice (pCurrentHIDDevice); - if(!pCurrentHIDDevice) return (1); - //look for the right element: - pRecElement pCurrentHIDElement = HIDGetFirstDeviceElement (pCurrentHIDDevice, kHIDElementTypeIO); - // use gElementCookie to find current element - while (pCurrentHIDElement && (pCurrentHIDElement->cookie != cookie)) - pCurrentHIDElement = HIDGetNextDeviceElement (pCurrentHIDElement, kHIDElementTypeIO); - if(!pCurrentHIDElement) return (1); - HIDQueueElement(pCurrentHIDDevice, pCurrentHIDElement); - return (0); - } - - - int prHIDDequeueElement(void) - { - DEBUG(post("prHIDDequeueElement");); - - int locID = NULL; - int cookieNum = NULL; - - //PyrSlot *a = g->sp - 2; //class - //PyrSlot *b = g->sp - 1; //locID device - //PyrSlot *c = g->sp; //element cookie - //int err = slotIntVal(b, &locID); - //if (err) return err; - //err = slotIntVal(c, &cookieNum); - //if (err) return err; - IOHIDElementCookie cookie = (IOHIDElementCookie) cookieNum; - //look for the right device: - pRecDevice pCurrentHIDDevice = HIDGetFirstDevice (); - while (pCurrentHIDDevice && (pCurrentHIDDevice->locID !=locID)) - pCurrentHIDDevice = HIDGetNextDevice (pCurrentHIDDevice); - if(!pCurrentHIDDevice) return (1); - //look for the right element: - pRecElement pCurrentHIDElement = HIDGetFirstDeviceElement (pCurrentHIDDevice, kHIDElementTypeIO); - while (pCurrentHIDElement && (pCurrentHIDElement->cookie != cookie)) - pCurrentHIDElement = HIDGetNextDeviceElement (pCurrentHIDElement, kHIDElementTypeIO); - if(!pCurrentHIDElement) return (1); - HIDDequeueElement(pCurrentHIDDevice, pCurrentHIDElement); - return (0); - } - - - int prHIDDequeueDevice(void) - { - DEBUG(post("prHIDDequeueDevice");); - - int locID = NULL; - int cookieNum = NULL; - - /* - PyrSlot *a = g->sp - 1; //class - PyrSlot *b = g->sp; //locID device - int err = slotIntVal(b, &locID); - if (err) return err; - */ - //look for the right device: - pRecDevice pCurrentHIDDevice = HIDGetFirstDevice (); - while (pCurrentHIDDevice && (pCurrentHIDDevice->locID !=locID)) - pCurrentHIDDevice = HIDGetNextDevice (pCurrentHIDDevice); - if(!pCurrentHIDDevice) return (1); - HIDDequeueDevice(pCurrentHIDDevice); - return (0); - } - - /* int prHIDStopEventLoop(void) */ /* { */ --- 678,681 ---- *************** *** 655,671 **** /* this is just a rough sketch */
- /* getEvents(t_hid *x) { */ - /* pRecDevice pCurrentHIDDevice = GetSetCurrentDevice (gWindow); */ - /* pRecElement pCurrentHIDElement = GetSetCurrenstElement (gWindow); */ - - /* // if we have a good device and element which is not a collecion */ - /* if (pCurrentHIDDevice && pCurrentHIDElement && (pCurrentHIDElement->type != kIOHIDElementTypeCollection)) */ - /* { */ - /* SInt32 value = HIDGetElementValue (pCurrentHIDDevice, pCurrentHIDElement); */ - /* SInt32 valueCal = HIDCalibrateValue (value, pCurrentHIDElement); */ - /* SInt32 valueScale = HIDScaleValue (valueCal, pCurrentHIDElement); */ - /* } */ - /* } */ -
//void HIDGetUsageName (const long valueUsagePage, const long valueUsage, char * cstrName) --- 690,693 ----
Index: hid.h =================================================================== RCS file: /cvsroot/pure-data/externals/hcs/hid/hid.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** hid.h 4 Nov 2004 17:24:18 -0000 1.5 --- hid.h 6 Nov 2004 01:03:00 -0000 1.6 *************** *** 30,36 **** t_int x_delay; long x_locID; - /* these two are probably unnecessary */ - long x_vendorID; - long x_productID; } t_hid;
--- 30,33 ---- *************** *** 40,44 **** */
! /* what are these for again? */ char *deviceList[64]; char *typeList[256]; --- 37,41 ---- */
! /* TODO: what are these for again? */ char *deviceList[64]; char *typeList[256]; *************** *** 55,80 **** t_int hid_output_events(t_hid *x) ;
- - - - - #ifdef __APPLE__ - void releaseHIDDevices(void); - int prHIDBuildElementList(void); - int prHIDBuildDeviceList(void); - int prHIDGetValue(void); - void PushQueueEvents_RawValue(void); - void PushQueueEvents_CalibratedValue(void); - int prHIDReleaseDeviceList(void); - //int prHIDRunEventLoop(void); - int prHIDQueueDevice(void); - int prHIDQueueElement(void); - int prHIDDequeueElement(void); - int prHIDDequeueDevice(void); - //int prHIDStopEventLoop(void); - #endif /* #ifdef __APPLE__ */ - - - - #endif /* #ifndef _HID_H */ --- 52,54 ----
Index: hid-help.pd =================================================================== RCS file: /cvsroot/pure-data/externals/hcs/hid/hid-help.pd,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** hid-help.pd 4 Nov 2004 17:24:17 -0000 1.5 --- hid-help.pd 6 Nov 2004 01:03:00 -0000 1.6 *************** *** 1,4 **** ! #N canvas 124 73 912 605 10; ! #X msg 390 265 ev_key btn_left 0 1.09868e+09; #X obj 390 244 prepend set; #X obj 149 473 route rel_x rel_y; --- 1,4 ---- ! #N canvas 143 45 911 634 10; ! #X msg 390 265 ev_abs abs_x 117 1.13626e+09; #X obj 390 244 prepend set; #X obj 149 473 route rel_x rel_y; *************** *** 7,29 **** #X msg 148 77 start; #X msg 174 96 stop; ! #X floatatom 494 384 12 0 0 1 time - -; ! #X obj 401 364 unpack s s f f; ! #X msg 241 29 open 0; ! #X msg 248 47 open 1; ! #X msg 255 65 open 2; ! #X msg 261 83 open 3; ! #X msg 267 101 open 4; #X floatatom 206 454 7 0 0 0 - - -; #X floatatom 264 454 7 0 0 0 - - -; ! #X obj 206 433 route abs_x abs_y; ! #X obj 86 81 tgl 35 0 empty empty empty 0 -6 0 8 -24198 -1 -1 0 1; ! #X floatatom 463 401 12 0 0 1 value - -; ! #X symbolatom 431 418 10 0 0 1 eventcode - -; ! #X symbolatom 401 437 15 0 0 1 eventtype - -; #X floatatom 93 536 5 0 0 0 - - -; #X floatatom 168 537 5 0 0 0 - - -; #X obj 93 514 route key_f key_leftctrl btn_left; #X floatatom 243 537 5 0 0 0 - - -; ! #X obj 61 219 bng 35 250 50 0 empty empty event_received 38 18 1 8 -225280 -1 -1; #X obj 2 2 cnv 15 900 20 empty empty [hid] 2 11 1 18 -233017 -66577 --- 7,28 ---- #X msg 148 77 start; #X msg 174 96 stop; ! #X floatatom 531 375 12 0 0 1 time - -; ! #X obj 438 355 unpack s s f f; ! #X msg 239 57 open 0; ! #X msg 246 75 open 1; ! #X msg 253 93 open 2; ! #X msg 259 111 open 3; ! #X msg 265 129 open 4; #X floatatom 206 454 7 0 0 0 - - -; #X floatatom 264 454 7 0 0 0 - - -; ! #X obj 86 81 tgl 35 0 empty empty empty 0 -6 0 8 -24198 -1 -1 1 1; ! #X floatatom 500 392 12 0 0 1 value - -; ! #X symbolatom 468 409 10 0 0 1 eventcode - -; ! #X symbolatom 438 428 15 0 0 1 eventtype - -; #X floatatom 93 536 5 0 0 0 - - -; #X floatatom 168 537 5 0 0 0 - - -; #X obj 93 514 route key_f key_leftctrl btn_left; #X floatatom 243 537 5 0 0 0 - - -; ! #X obj 71 241 bng 35 250 50 0 empty empty event_received 38 18 1 9 -225280 -1 -1; #X obj 2 2 cnv 15 900 20 empty empty [hid] 2 11 1 18 -233017 -66577 *************** *** 52,104 **** #X obj 262 397 +; #X msg 262 377 1; ! #X msg 317 149 close; ! #X msg 374 178 delay 20; ! #X msg 312 177 delay 2; ! #X msg 441 178 delay 200; #X text 383 40 new possibilities:; #X msg 391 62 poll; #X msg 431 62 poll 20; #X msg 499 61 nopoll; ! #X text 361 149 probably not needed; ! #X msg 282 127 refresh; ! #X text 343 125 refresh device list; ! #X obj 248 209 hid 2; #X connect 1 0 0 0; #X connect 2 0 3 0; #X connect 2 1 4 0; ! #X connect 5 0 60 0; ! #X connect 6 0 60 0; ! #X connect 8 0 20 0; ! #X connect 8 1 19 0; ! #X connect 8 2 18 0; #X connect 8 3 7 0; ! #X connect 9 0 60 0; ! #X connect 10 0 60 0; ! #X connect 11 0 60 0; ! #X connect 12 0 60 0; ! #X connect 13 0 60 0; ! #X connect 16 0 14 0; ! #X connect 16 1 15 0; ! #X connect 17 0 60 0; ! #X connect 23 0 21 0; ! #X connect 23 1 22 0; ! #X connect 23 2 24 0; ! #X connect 43 0 42 0; ! #X connect 44 0 43 1; ! #X connect 45 0 23 0; ! #X connect 45 1 2 0; ! #X connect 45 2 16 0; ! #X connect 45 3 48 0; ! #X connect 46 0 47 1; #X connect 47 0 46 0; ! #X connect 48 0 47 0; ! #X connect 49 0 60 0; ! #X connect 50 0 60 0; ! #X connect 51 0 60 0; ! #X connect 52 0 60 0; ! #X connect 58 0 60 0; ! #X connect 60 0 43 0; ! #X connect 60 0 25 0; ! #X connect 60 0 45 0; ! #X connect 60 0 1 0; ! #X connect 60 0 8 0; --- 51,120 ---- #X obj 262 397 +; #X msg 262 377 1; ! #X msg 336 152 close; ! #X msg 398 180 delay 20; ! #X msg 336 180 delay 2; ! #X msg 465 180 delay 200; #X text 383 40 new possibilities:; #X msg 391 62 poll; #X msg 431 62 poll 20; #X msg 499 61 nopoll; ! #X text 380 152 probably not needed; ! #X msg 336 129 refresh; ! #X text 397 127 refresh device list; ! #X obj 248 225 hid 2; ! #X obj 590 143 loadbang; ! #X obj 337 514 unpack s f f; ! #X obj 376 532 tgl 25 0 empty empty any_button 27 13 1 9 -195568 -1 ! -1 0 1; ! #X obj 740 511 all_about_hid; ! #X text 631 512 For more info:; ! #X text 49 588 (C) Copyright 2004 Hans-Christoph Steiner hans@at.or.at ! ; ! #X text 266 602 released under the GNU GPL; ! #X text 472 589 $Revision$$Date$; ! #X text 473 602 $Author$; ! #X obj 206 433 route abs_x abs_y abs_z; ! #X floatatom 322 454 7 0 0 0 - - -; #X connect 1 0 0 0; #X connect 2 0 3 0; #X connect 2 1 4 0; ! #X connect 5 0 59 0; ! #X connect 6 0 59 0; ! #X connect 8 0 19 0; ! #X connect 8 1 18 0; ! #X connect 8 2 17 0; #X connect 8 3 7 0; ! #X connect 9 0 59 0; ! #X connect 10 0 59 0; ! #X connect 11 0 59 0; ! #X connect 12 0 59 0; ! #X connect 13 0 59 0; ! #X connect 16 0 59 0; ! #X connect 22 0 20 0; ! #X connect 22 1 21 0; ! #X connect 22 2 23 0; ! #X connect 22 3 61 0; ! #X connect 42 0 41 0; ! #X connect 43 0 42 1; ! #X connect 44 0 22 0; ! #X connect 44 1 2 0; ! #X connect 44 2 69 0; ! #X connect 44 3 47 0; ! #X connect 45 0 46 1; ! #X connect 46 0 45 0; #X connect 47 0 46 0; ! #X connect 48 0 59 0; ! #X connect 49 0 59 0; ! #X connect 50 0 59 0; ! #X connect 51 0 59 0; ! #X connect 57 0 59 0; ! #X connect 59 0 42 0; ! #X connect 59 0 24 0; ! #X connect 59 0 44 0; ! #X connect 59 0 1 0; ! #X connect 59 0 8 0; ! #X connect 60 0 51 0; ! #X connect 61 1 62 0; ! #X connect 69 0 14 0; ! #X connect 69 1 15 0; ! #X connect 69 2 70 0;
Index: hid.c =================================================================== RCS file: /cvsroot/pure-data/externals/hcs/hid/hid.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** hid.c 4 Nov 2004 17:24:17 -0000 1.8 --- hid.c 6 Nov 2004 01:03:00 -0000 1.9 *************** *** 36,39 **** --- 36,51 ----
/*------------------------------------------------------------------------------ + * FUNCTION PROTOTYPES + */ + + void hid_start(t_hid *x); + void hid_stop(t_hid *x); + t_int hid_open(t_hid *x, t_float f); + t_int hid_close(t_hid *x); + t_int hid_read(t_hid *x,int fd); + void hid_delay(t_hid *x, t_float f); + static void hid_float(t_hid* x, t_floatarg f); + + /*------------------------------------------------------------------------------ * IMPLEMENTATION */ *************** *** 69,72 **** --- 81,87 ---- { DEBUG(post("hid_open");); + + /* store running state so that it can be restored after the device has been opened */ + t_int started = x->x_started; hid_close(x); *************** *** 83,90 **** { error("[hid] can not open device %d",x->x_device_number); ! post("\================================ [hid] ================================/\n"); return (1); }
post("\================================ [hid] ================================/\n"); return (0); --- 98,110 ---- { error("[hid] can not open device %d",x->x_device_number); ! post("\================================ [hid] ================================/\n"); return (1); }
+ /* restore the polling state so that when I [tgl] is used to start/stop [hid], + * the [tgl]'s state will continue to accurately reflect [hid]'s state + */ + hid_float(x,started); + post("\================================ [hid] ================================/\n"); return (0);