Update of /cvsroot/pure-data/externals/hcs/usbhid In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14113
Modified Files: Makefile usbhid-help.pd usbhid.c Log Message: got strtol working (baby steps), but I can't find the magic combo to get output working
Index: usbhid-help.pd =================================================================== RCS file: /cvsroot/pure-data/externals/hcs/usbhid/usbhid-help.pd,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** usbhid-help.pd 30 Jul 2007 18:15:46 -0000 1.3 --- usbhid-help.pd 30 Jul 2007 22:50:13 -0000 1.4 *************** *** 1,9 **** ! #N canvas 127 169 633 586 10; ! #X obj 132 406 usbhid; ! #X msg 194 120 close; ! #X msg 194 146 reset; ! #X text 240 337 GARBAGE FOR TESTING; ! #X msg 207 184 print; ! #X text 317 72 Gravis/Destroyer Tiltpad; #N canvas 0 22 462 312 buttons 0; #X obj 99 36 inlet; --- 1,8 ---- ! #N canvas 5 85 797 703 10; ! #X obj 182 516 usbhid; ! #X msg 284 190 close; ! #X msg 284 216 reset; ! #X msg 297 254 print; ! #X text 367 72 Gravis/Destroyer Tiltpad; #N canvas 0 22 462 312 buttons 0; #X obj 99 36 inlet; *************** *** 22,26 **** 32; #X obj 263 130 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 ! 1; #X obj 303 130 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 128; --- 21,25 ---- 32; #X obj 263 130 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 ! 64; #X obj 303 130 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 128; *************** *** 48,66 **** #X connect 15 0 8 0; #X connect 16 0 9 0; ! #X restore 65 545 pd buttons test; ! #X obj 127 492 unpack float float float float; ! #X obj 44 113 metro 400; ! #X obj 46 87 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 ; ! #X floatatom 186 529 5 0 0 0 - - -; ! #X floatatom 256 530 5 0 0 0 - - -; ! #X floatatom 336 525 5 0 0 0 - - -; ! #X msg 20 5 open vendorId productId; ! #X msg 176 71 open 0x047D 0x4008; ! #X floatatom 125 526 5 0 0 0 - - -; ! #X msg 239 303 debug $1; ! #X obj 239 281 hradio 15 1 0 10 empty empty empty 0 -6 0 8 -262144 -1 -1 0; ! #X obj 27 471 print data; #N canvas 458 151 458 489 parsing 0; #X obj 77 6 inlet; --- 47,65 ---- #X connect 15 0 8 0; #X connect 16 0 9 0; ! #X restore 115 655 pd buttons test; ! #X obj 177 602 unpack float float float float; ! #X obj 94 183 metro 400; ! #X obj 96 157 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 ; ! #X floatatom 236 639 5 0 0 0 - - -; ! #X floatatom 306 640 5 0 0 0 - - -; ! #X floatatom 386 635 5 0 0 0 - - -; ! #X msg 70 5 open vendorId productId; ! #X msg 226 71 open 0x047D 0x4008; ! #X floatatom 175 636 5 0 0 0 - - -; ! #X msg 329 373 debug $1; ! #X obj 329 351 hradio 15 1 0 10 empty empty empty 0 -6 0 8 -262144 -1 -1 0; ! #X obj 77 581 print data; #N canvas 458 151 458 489 parsing 0; #X obj 77 6 inlet; *************** *** 90,145 **** #X connect 10 0 2 1; #X connect 10 1 11 0; ! #X restore 226 448 pd parsing; ! #X text 8 152 how many bytes to read; ! #X msg 204 165 refresh; ! #X text 269 166 reinit and refresh device list; ! #X text 243 146 resets device (don't really know what that does tho) ; ! #X obj 171 449 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1; ! #X obj 171 427 route open device; ! #X msg 44 134 get 4; ! #X msg 82 167 get 2; ! #X msg 212 209 descriptor; ! #X text 291 209 get descriptor; ! #X msg 219 243 descriptor 1 30 1 31 1 38; ! #X text 398 242 [descriptor page# usage# ...(; ! #X text 218 227 for writing to the device:; ! #X msg 25 238 set 2; ! #X msg 237 353 close , open 0x045e 0x0039 , descriptor; ! #X text 183 412 <- status outlet; ! #X text 21 413 data outlet ->; ! #X msg 163 49 open 0x046d 0xc01d; ! #X text 305 49 Logitech USB-PS/2 Optical Mouse; ! #X msg 156 25 open 0x1043 0x0015; ! #X text 294 26 CUI v1.0; ! #X msg 181 96 open 0x077d 0x0410; ! #X text 311 97 Griffin Technology PowerMate; ! #X connect 0 0 7 0; ! #X connect 0 0 18 0; ! #X connect 0 1 25 0; #X connect 1 0 0 0; #X connect 2 0 0 0; ! #X connect 4 0 0 0; ! #X connect 7 0 6 0; ! #X connect 7 0 15 0; ! #X connect 7 1 10 0; ! #X connect 7 2 11 0; ! #X connect 7 3 12 0; ! #X connect 8 0 26 0; ! #X connect 9 0 8 0; ! #X connect 14 0 0 0; ! #X connect 16 0 0 0; ! #X connect 17 0 16 0; ! #X connect 21 0 0 0; ! #X connect 25 0 24 0; ! #X connect 25 1 19 0; #X connect 26 0 0 0; - #X connect 27 0 0 0; #X connect 28 0 0 0; ! #X connect 30 0 0 0; ! #X connect 33 0 0 0; #X connect 34 0 0 0; ! #X connect 37 0 0 0; ! #X connect 39 0 0 0; #X connect 41 0 0 0; --- 89,160 ---- #X connect 10 0 2 1; #X connect 10 1 11 0; ! #X restore 276 558 pd parsing; ! #X text 58 222 how many bytes to read; ! #X msg 294 235 refresh; ! #X text 359 236 reinit and refresh device list; ! #X text 333 216 resets device (don't really know what that does tho) ; ! #X obj 221 559 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1; ! #X obj 221 537 route open device; ! #X msg 132 237 get 2; ! #X msg 302 279 descriptor; ! #X text 381 279 get descriptor; ! #X msg 309 313 descriptor 1 30 1 31 1 38; ! #X text 488 312 [descriptor page# usage# ...(; ! #X text 308 297 for writing to the device:; ! #X msg 75 308 set 2; ! #X text 233 522 <- status outlet; ! #X text 71 523 data outlet ->; ! #X msg 213 49 open 0x046d 0xc01d; ! #X text 355 49 Logitech USB-PS/2 Optical Mouse; ! #X msg 206 25 open 0x1043 0x0015; ! #X text 344 26 CUI v1.0; ! #X msg 231 96 open 0x077d 0x0410; ! #X text 361 97 Griffin Technology PowerMate; ! #X text 375 125 Logitech RumblePad 2 USB; ! #X msg 253 125 open 0x046d 0xc218; ! #X msg 94 204 get 8; ! #X msg 392 431 write 0x0 0x0 $1; ! #X obj 390 409 int; ! #X obj 394 387 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 10 -262144 ! -1 -1 0 1; ! #X obj 362 562 print ELSE; ! #X msg 451 459 write 0x0001 0x0004 5; ! #X msg 449 479 write 0xff00 0x0001 5; ! #X msg 449 499 write 0xff00 0x0002 5; ! #X connect 0 0 6 0; ! #X connect 0 0 17 0; ! #X connect 0 1 24 0; #X connect 1 0 0 0; #X connect 2 0 0 0; ! #X connect 3 0 0 0; ! #X connect 6 0 5 0; ! #X connect 6 0 14 0; ! #X connect 6 1 9 0; ! #X connect 6 2 10 0; ! #X connect 6 3 11 0; ! #X connect 7 0 42 0; ! #X connect 8 0 7 0; ! #X connect 13 0 0 0; ! #X connect 15 0 0 0; ! #X connect 16 0 15 0; ! #X connect 20 0 0 0; ! #X connect 24 0 23 0; ! #X connect 24 1 18 0; ! #X connect 24 2 46 0; ! #X connect 25 0 0 0; #X connect 26 0 0 0; #X connect 28 0 0 0; ! #X connect 31 0 0 0; #X connect 34 0 0 0; ! #X connect 36 0 0 0; ! #X connect 38 0 0 0; #X connect 41 0 0 0; + #X connect 42 0 0 0; + #X connect 43 0 0 0; + #X connect 44 0 43 0; + #X connect 45 0 44 0; + #X connect 47 0 0 0; + #X connect 48 0 0 0; + #X connect 49 0 0 0;
Index: Makefile =================================================================== RCS file: /cvsroot/pure-data/externals/hcs/usbhid/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile 30 Jul 2007 18:15:46 -0000 1.2 --- Makefile 30 Jul 2007 22:50:13 -0000 1.3 *************** *** 14,18 **** make -C $(EXTERNALS_ROOT) test_locations
etags: ! etags *.[ch] ../../../pd/src/*.[ch] libhid-svn/*/*.? \ ! /usr/include/*.h /usr/include/sys/*.h --- 14,29 ---- make -C $(EXTERNALS_ROOT) test_locations
+ # for emacs etags: ! etags --language=c *.[ch] ../../../pd/src/*.[ch] \ ! /usr/include/*.h /usr/include/sys/*.h \ ! /sw/include/*.h /sw/include/*/*.h \ ! libhid-svn/*/*.? ! ! #etags_Darwin: ! # etags --append /sw/include/*.h /sw/include/*/*.h ! ! etags_Linux: ! etags --append libhid-svn/*/*.? ! !
Index: usbhid.c =================================================================== RCS file: /cvsroot/pure-data/externals/hcs/usbhid/usbhid.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** usbhid.c 30 Jul 2007 18:15:46 -0000 1.2 --- usbhid.c 30 Jul 2007 22:50:13 -0000 1.3 *************** *** 30,33 **** --- 30,35 ---- #include <hid.h> #include <stdio.h> + #include <stdlib.h> + #include <errno.h> #include <string.h> #include <float.h> *************** *** 487,495 **** return; } ! x->x_hid_return = hid_set_output_report(x->x_hidinterface, x->x_write_elements, x->x_write_element_count, packet, length_arg); if (x->x_hid_return != HID_RET_SUCCESS) { --- 489,498 ---- return; } ! /* x->x_hid_return = hid_set_output_report(x->x_hidinterface, x->x_write_elements, x->x_write_element_count, packet, length_arg); + */ if (x->x_hid_return != HID_RET_SUCCESS) { *************** *** 498,504 **** reset_output(x); add_float_to_output(x, x->x_hid_return); ! outlet_anything(x->x_status_outlet, gensym("setError"), x->output_count, x->output); } }
--- 501,558 ---- reset_output(x); add_float_to_output(x, x->x_hid_return); ! outlet_anything(x->x_status_outlet, gensym("set_error"), ! x->output_count, x->output); ! } ! } ! ! ! /* -------------------------------------------------------------------------- */ ! static void usbhid_write(t_usbhid *x, t_symbol *usage_page_symbol, ! t_symbol *usage_symbol, t_float value) ! { ! if(x->debug_level) post("usbhid_set"); ! // const char* path[] = {0x00010004, 0xff000002}; ! long path_element; ! int path[] = {0xff000002}; ! unsigned int const depth = 1; ! unsigned char const SEND_PACKET_LEN = 1; ! char const PACKET[] = { 0x50 }; ! ! if ( !hid_is_opened(x->x_hidinterface) ) ! { ! error("[usbhid] device not open, can't set data"); ! return; ! } ! path_element = (strtol(usage_page_symbol->s_name, NULL, 16) << 16) + ! (strtol(usage_symbol->s_name, NULL, 16) & 0x0000ffff); ! if (path_element == 0) ! switch (errno) ! { ! case EINVAL: ! post("strtol EINVAL error %d", errno); ! break; ! case ERANGE: ! post("strtol ERANGE error %d", errno); ! break; ! default: ! post("strtol error %d", errno); ! } ! post("path: 0x%08x", path_element); ! path[0] = path_element; ! x->x_hid_return = hid_set_output_report(x->x_hidinterface, ! &path_element, ! depth, ! PACKET, ! SEND_PACKET_LEN); ! if (x->x_hid_return != HID_RET_SUCCESS) ! { ! error("[usbhid] hid_set_output_report failed with return code %d", ! x->x_hid_return); ! reset_output(x); ! add_float_to_output(x, x->x_hid_return); ! outlet_anything(x->x_status_outlet, gensym("get_error"), x->output_count, x->output); } + post("wrote"); }
*************** *** 776,783 **** class_addmethod(usbhid_class,(t_method) usbhid_descriptor,gensym("descriptor"), A_GIMME,0); - class_addmethod(usbhid_class,(t_method) usbhid_set,gensym("set"), - A_DEFFLOAT,0); class_addmethod(usbhid_class,(t_method) usbhid_get,gensym("get"), A_DEFFLOAT,0); class_addmethod(usbhid_class,(t_method) usbhid_open,gensym("open"), A_DEFSYM,A_DEFSYM,0); --- 830,839 ---- class_addmethod(usbhid_class,(t_method) usbhid_descriptor,gensym("descriptor"), A_GIMME,0); class_addmethod(usbhid_class,(t_method) usbhid_get,gensym("get"), A_DEFFLOAT,0); + class_addmethod(usbhid_class,(t_method) usbhid_set,gensym("set"), + A_DEFFLOAT,0); + class_addmethod(usbhid_class,(t_method) usbhid_write,gensym("write"), + A_DEFSYM, A_DEFSYM, A_DEFFLOAT, 0); class_addmethod(usbhid_class,(t_method) usbhid_open,gensym("open"), A_DEFSYM,A_DEFSYM,0);