[PD-cvs] externals/hcs/usbhid usbhid-help.pd, 1.4, 1.5 usbhid.c, 1.3, 1.4

Hans-Christoph Steiner eighthave at users.sourceforge.net
Sun Dec 9 22:55:49 CET 2007


Update of /cvsroot/pure-data/externals/hcs/usbhid
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2032

Modified Files:
	usbhid-help.pd usbhid.c 
Log Message:
added the ability to set the HID path in the [write( message

Index: usbhid-help.pd
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/usbhid/usbhid-help.pd,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** usbhid-help.pd	30 Jul 2007 22:50:13 -0000	1.4
--- usbhid-help.pd	9 Dec 2007 21:55:47 -0000	1.5
***************
*** 1,7 ****
! #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;
--- 1,7 ----
! #N canvas 677 22 710 687 10;
! #X obj 177 545 usbhid;
! #X msg 276 167 close;
! #X msg 276 193 reset;
! #X msg 289 231 print;
  #X text 367 72 Gravis/Destroyer Tiltpad;
  #N canvas 0 22 462 312 buttons 0;
***************
*** 48,52 ****
  #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
--- 48,52 ----
  #X connect 16 0 9 0;
  #X restore 115 655 pd buttons test;
! #X obj 177 613 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
***************
*** 58,65 ****
  #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;
--- 58,65 ----
  #X msg 226 71 open 0x047D 0x4008;
  #X floatatom 175 636 5 0 0 0 - - -;
! #X msg 314 347 debug \$1;
! #X obj 314 325 hradio 15 1 0 10 empty empty empty 0 -6 0 8 -262144
  -1 -1 0;
! #X obj 77 592 print data;
  #N canvas 458 151 458 489 parsing 0;
  #X obj 77 6 inlet;
***************
*** 89,110 ****
  #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;
--- 89,110 ----
  #X connect 10 0 2 1;
  #X connect 10 1 11 0;
! #X restore 271 587 pd parsing;
  #X text 58 222 how many bytes to read;
! #X msg 286 212 refresh;
! #X text 351 213 reinit and refresh device list;
! #X text 325 193 resets device (don't really know what that does tho)
  ;
! #X obj 216 588 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1
  1;
! #X obj 216 566 route open device;
  #X msg 132 237 get 2;
! #X msg 294 256 descriptor;
! #X text 373 256 get descriptor;
! #X msg 301 290 descriptor 1 30 1 31 1 38;
! #X text 480 289 [descriptor page# usage# ...(;
! #X text 300 274 for writing to the device:;
  #X msg 75 308 set 2;
! #X text 228 551 <- status outlet;
! #X text 66 552 data outlet ->;
  #X msg 213 49 open 0x046d 0xc01d;
  #X text 355 49 Logitech USB-PS/2 Optical Mouse;
***************
*** 116,127 ****
  #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;
--- 116,131 ----
  #X msg 253 125 open 0x046d 0xc218;
  #X msg 94 204 get 8;
! #X obj 332 453 int;
! #X obj 335 434 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 10 -262144
  -1 -1 0 1;
! #X obj 357 591 print ELSE;
! #X msg 421 501 write 0x0001 0x0004 5;
! #X msg 419 521 write 0xff00 0x0001 5;
! #X msg 419 541 write 0xff00 0x0002 5;
! #X obj 320 395 int;
! #X obj 323 376 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 10 -262144
! -1 -1 0 1;
! #X msg 320 415 write 0x01 0x04 0x0 0x0 0xff00 0x02 \$1;
! #X msg 332 473 write 0x01 0x04 0x00 0x00 0xff00 0x01 \$1;
  #X connect 0 0 6 0;
  #X connect 0 0 17 0;
***************
*** 143,147 ****
  #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;
--- 147,151 ----
  #X connect 24 0 23 0;
  #X connect 24 1 18 0;
! #X connect 24 2 45 0;
  #X connect 25 0 0 0;
  #X connect 26 0 0 0;
***************
*** 153,160 ****
  #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;
--- 157,167 ----
  #X connect 41 0 0 0;
  #X connect 42 0 0 0;
! #X connect 43 0 52 0;
  #X connect 44 0 43 0;
! #X connect 46 0 0 0;
  #X connect 47 0 0 0;
  #X connect 48 0 0 0;
! #X connect 49 0 51 0;
! #X connect 50 0 49 0;
! #X connect 51 0 0 0;
! #X connect 52 0 0 0;

Index: usbhid.c
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/usbhid/usbhid.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** usbhid.c	30 Jul 2007 22:50:13 -0000	1.3
--- usbhid.c	9 Dec 2007 21:55:47 -0000	1.4
***************
*** 508,521 ****
  
  /* -------------------------------------------------------------------------- */
! 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) )
--- 508,524 ----
  
  /* -------------------------------------------------------------------------- */
! static void usbhid_write(t_usbhid *x,  t_symbol *s, int argc, t_atom *argv) 
  {
! 	if(x->debug_level) post("usbhid_write");
!     int i;
! //	const int path[] = {0x000c0001, 0x000c0001};
! //	int path[] = {0xff000002};
!     int *path;
! //	unsigned int const depth = 2;  // number of 32bit chunks in the path
! //	unsigned char const SEND_PACKET_LEN = 2; // number of bytes in packet
! //	char const PACKET[] = { 0x50 }; // the data to write
! 	unsigned int depth;  // number of 32bit chunks in the path
! 	unsigned char SEND_PACKET_LEN; // number of bytes in packet
! 	char PACKET[] = { 0x50 }; // the data to write
  
   	if ( !hid_is_opened(x->x_hidinterface) )
***************
*** 524,547 ****
  		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) 
--- 527,550 ----
  		return;
  	}
! 
!     path = getbytes(sizeof(int) * (argc - 1));
!     depth = (argc - 1) / 2;
!     for(i = 0; i < argc - 1; ++i)
!     {
!         path[(i+1)/2] = (strtol(atom_getsymbol(argv + i)->s_name, NULL, 16) << 16) + 
!             (strtol(atom_getsymbol(argv + i + 1)->s_name, NULL, 16) & 0x0000ffff);
!         ++i;
!     }
!     SEND_PACKET_LEN = 1;
!     PACKET[0] = (unsigned short) atom_getfloat(argv + argc - 1);
!     post("depth: %d  SEND_PACKET_LEN: %d   PACKET[0]: %d", 
!          depth, SEND_PACKET_LEN, PACKET[0]);
!     for(i = 0; i < (argc - 1) / 2; ++i)
!     {
!         post("path %d: 0x%08x", i, path[i]);
!     }
!     
  	x->x_hid_return = hid_set_output_report(x->x_hidinterface, 
! 											path, depth, PACKET,
  											SEND_PACKET_LEN);
  	if (x->x_hid_return != HID_RET_SUCCESS) 
***************
*** 612,615 ****
--- 615,619 ----
  	t_int output_size = 0;
  	t_int feature_size = 0;
+     char buf[MAXPDSTRING];
  
  	if (!hid_is_opened(x->x_hidinterface)) {
***************
*** 640,654 ****
  			add_float_to_output(x, x->x_hidinterface->hid_data->Size);
  			add_float_to_output(x, x->x_hidinterface->hid_data->Offset);
  			for (i = 0; i < x->x_hidinterface->hid_data->Path.Size; ++i) {
! 				add_symbol_to_output(x, gensym("usage"));
! 				add_float_to_output(x, x->x_hidinterface->hid_data->Path.Node[i].UPage);
! 				add_float_to_output(x, x->x_hidinterface->hid_data->Path.Node[i].Usage);
! 				post("page: 0x%04x\t%d\t\tusage: 0x%04x\t%d",
! 					 x->x_hidinterface->hid_data->Path.Node[i].UPage,
! 					 x->x_hidinterface->hid_data->Path.Node[i].UPage,
! 					 x->x_hidinterface->hid_data->Path.Node[i].Usage,
! 					 x->x_hidinterface->hid_data->Path.Node[i].Usage);
  			}
- 			post("type: 0x%02x\n", x->x_hidinterface->hid_data->Type);
  			add_symbol_to_output(x, gensym("logical"));
  			add_float_to_output(x, x->x_hidinterface->hid_data->LogMin);
--- 644,657 ----
  			add_float_to_output(x, x->x_hidinterface->hid_data->Size);
  			add_float_to_output(x, x->x_hidinterface->hid_data->Offset);
+             add_symbol_to_output(x, gensym("path"));
+             post("path");
  			for (i = 0; i < x->x_hidinterface->hid_data->Path.Size; ++i) {
!                 sprintf(buf, "0x%04x", x->x_hidinterface->hid_data->Path.Node[i].UPage);
! 				add_symbol_to_output(x, gensym(buf));
!                 sprintf(buf, "0x%04x", x->x_hidinterface->hid_data->Path.Node[i].Usage);
! 				add_symbol_to_output(x, gensym(buf));
!                 post("0x%04x%04x",x->x_hidinterface->hid_data->Path.Node[i].UPage,
!                      x->x_hidinterface->hid_data->Path.Node[i].Usage);
  			}
  			add_symbol_to_output(x, gensym("logical"));
  			add_float_to_output(x, x->x_hidinterface->hid_data->LogMin);
***************
*** 835,839 ****
  					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);
--- 838,842 ----
  					A_DEFFLOAT,0);
  	class_addmethod(usbhid_class,(t_method) usbhid_write,gensym("write"),
! 					A_GIMME, 0);
  	class_addmethod(usbhid_class,(t_method) usbhid_open,gensym("open"),
  					A_DEFSYM,A_DEFSYM,0);





More information about the Pd-cvs mailing list