Revision: 9766 http://pure-data.svn.sourceforge.net/pure-data/?rev=9766&view=rev Author: eighthave Date: 2008-05-05 09:12:32 -0700 (Mon, 05 May 2008)
Log Message: ----------- - Got the symbolic usage page/usage tags in the write message working
- sketched out the possibility of numeric-only write messages, and write messages using a symbolic usage page and a numeric usage.
Modified Paths: -------------- trunk/externals/io/hidio/hidio-help.pd trunk/externals/io/hidio/hidio.c trunk/externals/io/hidio/hidio.h trunk/externals/io/hidio/hidio_darwin.c
Modified: trunk/externals/io/hidio/hidio-help.pd =================================================================== --- trunk/externals/io/hidio/hidio-help.pd 2008-05-05 16:09:32 UTC (rev 9765) +++ trunk/externals/io/hidio/hidio-help.pd 2008-05-05 16:12:32 UTC (rev 9766) @@ -1,8 +1,8 @@ #N canvas 726 139 886 611 10; #X floatatom 27 445 5 0 0 0 - - -; #X floatatom 83 445 5 0 0 0 - - -; -#X obj 191 164 tgl 35 0 empty empty empty 0 -6 0 8 -24198 -1 -1 0 25 -; +#X obj 191 164 tgl 35 0 empty empty empty 0 -6 0 8 -24198 -1 -1 25 +25; #X floatatom 765 335 5 0 0 1 value - -; #X symbolatom 631 360 15 0 0 1 event_code - -; #X symbolatom 544 377 15 0 0 1 event_type - -; @@ -507,24 +507,45 @@ #X msg 262 104 open 0; #N canvas 121 220 450 300 output 1; #X obj 93 235 outlet; -#X obj 57 71 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 1 -; #X msg 112 70 255; #X obj 108 112 pack 0 16; #X obj 159 92 + 16; #X obj 157 68 hradio 15 1 0 8 empty empty empty 0 -8 0 10 -262144 -1 -1 0; #X floatatom 171 114 5 0 0 0 - - -; -#X msg 108 143 write 0xFACE 0xFACE $2 $1; #X obj 125 175 pddp/print; -#X connect 1 0 3 0; -#X connect 2 0 3 0; -#X connect 3 0 7 0; -#X connect 4 0 3 1; -#X connect 4 0 6 0; -#X connect 5 0 4 0; -#X connect 7 0 0 0; -#X connect 7 0 8 0; +#X msg 77 71 127; +#X msg 47 71 0; +#X obj 50 36 select 1 0; +#X obj 49 13 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1 +; +#X msg 108 143 write 1 1 $2 $1; +#X msg 366 86 255; +#X msg 331 87 127; +#X msg 301 87 0; +#X obj 304 52 select 1 0; +#X obj 303 29 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +1; +#X msg 261 143 write led power 0 $1; +#X connect 1 0 2 0; +#X connect 2 0 11 0; +#X connect 3 0 2 1; +#X connect 3 0 5 0; +#X connect 4 0 3 0; +#X connect 7 0 2 0; +#X connect 8 0 2 0; +#X connect 9 0 8 0; +#X connect 9 1 1 0; +#X connect 10 0 9 0; +#X connect 11 0 0 0; +#X connect 11 0 6 0; +#X connect 12 0 17 0; +#X connect 13 0 17 0; +#X connect 14 0 17 0; +#X connect 15 0 14 0; +#X connect 15 1 12 0; +#X connect 16 0 15 0; +#X connect 17 0 0 0; #X restore 373 211 pd output support; #X connect 2 0 60 0; #X connect 8 0 60 0;
Modified: trunk/externals/io/hidio/hidio.c =================================================================== --- trunk/externals/io/hidio/hidio.c 2008-05-05 16:09:32 UTC (rev 9765) +++ trunk/externals/io/hidio/hidio.c 2008-05-05 16:12:32 UTC (rev 9766) @@ -302,6 +302,45 @@ output_element->output_message); }
+void hidio_write_event(t_hidio *x, t_symbol *s, int argc, t_atom *argv) +{ + debug_post(LOG_DEBUG,"hidio_write_event_symbols"); + t_symbol *first_argument; + t_symbol *second_argument; + + if(argc == 4) + { + first_argument = atom_getsymbolarg(0,argc,argv); + if(first_argument == &s_) + { // first float arg means all float message + debug_post(LOG_DEBUG,"first_argument == &s_"); + hidio_write_event_ints(x, atom_getintarg(0,argc,argv), atom_getintarg(1,argc,argv), + atom_getintarg(2,argc,argv), atom_getintarg(3,argc,argv)); + } + else + { + second_argument = atom_getsymbolarg(1,argc,argv); + if(second_argument == &s_) + { // symbol page and float usage + debug_post(LOG_DEBUG,"second_argument == &s_"); + hidio_write_event_symbol_int(x, first_argument, + atom_getintarg(1,argc,argv), + atom_getintarg(2,argc,argv), + atom_getintarg(3,argc,argv)); + } + else + { // symbol page and usage + hidio_write_event_symbols(x, first_argument, second_argument, + atom_getintarg(2,argc,argv), atom_getintarg(3,argc,argv)); + } + } + + } + else + { + pd_error(x, "[hidio] write message format not supported"); + } +}
/* stop polling the device */ static void hidio_stop_poll(t_hidio* x) @@ -589,8 +628,7 @@ class_addmethod(hidio_class,(t_method) hidio_poll,gensym("poll"),A_DEFFLOAT,0);
/* test function for output support */ - class_addmethod(hidio_class,(t_method) hidio_write_event, gensym("write"), - A_DEFSYMBOL, A_DEFSYMBOL, A_FLOAT, A_FLOAT ,0); + class_addmethod(hidio_class,(t_method) hidio_write_event, gensym("write"), A_GIMME ,0);
post("[hidio] %d.%d, written by Hans-Christoph Steiner hans@eds.org",
Modified: trunk/externals/io/hidio/hidio.h =================================================================== --- trunk/externals/io/hidio/hidio.h 2008-05-05 16:09:32 UTC (rev 9765) +++ trunk/externals/io/hidio/hidio.h 2008-05-05 16:12:32 UTC (rev 9766) @@ -186,8 +186,12 @@ extern t_int hidio_close_device(t_hidio *x); extern void hidio_build_device_list(void); extern void hidio_get_events(t_hidio *x); -extern void hidio_write_event(t_hidio *x, t_symbol *type, t_symbol *code, - t_float instance, t_float value); +extern void hidio_write_event_symbol_int(t_hidio *x, t_symbol *type, t_int code, + t_int instance, t_int value); +extern void hidio_write_event_symbols(t_hidio *x, t_symbol *type, t_symbol *code, + t_int instance, t_int value); +extern void hidio_write_event_ints(t_hidio *x, t_int type, t_int code, + t_int instance, t_int value); extern void hidio_print(t_hidio* x); /* print info to the console */ extern void hidio_platform_specific_info(t_hidio *x); /* device info on the status outlet */ extern void hidio_platform_specific_free(t_hidio *x);
Modified: trunk/externals/io/hidio/hidio_darwin.c =================================================================== --- trunk/externals/io/hidio/hidio_darwin.c 2008-05-05 16:09:32 UTC (rev 9765) +++ trunk/externals/io/hidio/hidio_darwin.c 2008-05-05 16:12:32 UTC (rev 9766) @@ -713,12 +713,46 @@ } }
-void hidio_write_event(t_hidio *x, t_symbol *type, t_symbol *code, - t_float instance, t_float value) +void hidio_write_event_symbol_int(t_hidio *x, t_symbol *type, t_int code, + t_int instance, t_int value) { - debug_post(LOG_DEBUG,"hidio_write_event"); + debug_post(LOG_DEBUG,"hidio_write_event_symbol_float"); +} + +void hidio_write_event_symbols(t_hidio *x, t_symbol *type, t_symbol *code, + t_int instance, t_int value) +{ + /* TODO handle multiple instances of the same usage, i.e. arrays */ + debug_post(LOG_DEBUG,"hidio_write_event_symbols"); + int i; + t_hid_element *current_element; IOHIDEventStruct event; + int cookie = (int) instance; pRecDevice pCurrentHIDDevice = device_pointer[x->x_device_number]; + pRecElement pCurrentHIDElement; + for(i=0; i<element_count[x->x_device_number]; i++) + { + current_element = element[x->x_device_number][i]; + if((current_element->type == type) && (current_element->name == code)) + { + pCurrentHIDElement = current_element->pHIDElement; + break; + } + } + post("element usage page and usage: 0x%04x 0x%04x", pCurrentHIDElement->usagePage, pCurrentHIDElement->usage); + event.elementCookie = (IOHIDElementCookie)pCurrentHIDElement->cookie; + event.value = (SInt32)value; + post("pCurrentHIDElement->cookie, cookie, event.value, value: %d %d %d %f", + pCurrentHIDElement->cookie, cookie, event.value, value); + HIDSetElementValue(pCurrentHIDDevice, pCurrentHIDElement, &event); +} + +void hidio_write_event_ints(t_hidio *x, t_int type, t_int code, + t_int instance, t_int value) +{ + debug_post(LOG_DEBUG,"hidio_write_event_floats"); + IOHIDEventStruct event; + pRecDevice pCurrentHIDDevice = device_pointer[x->x_device_number]; pRecElement elem = HIDGetFirstDeviceElement(pCurrentHIDDevice, kHIDElementTypeOutput); int cookie = (int) instance; while(elem && ((int)elem->cookie != cookie))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.