[PD-cvs] SF.net SVN: pure-data: [9754] trunk/externals/hcs/usbhid

eighthave at users.sourceforge.net eighthave at users.sourceforge.net
Sat May 3 17:40:34 CEST 2008


Revision: 9754
          http://pure-data.svn.sourceforge.net/pure-data/?rev=9754&view=rev
Author:   eighthave
Date:     2008-05-03 08:40:34 -0700 (Sat, 03 May 2008)

Log Message:
-----------
first really working output example, using the iFeel mouse buzz, yay!

Modified Paths:
--------------
    trunk/externals/hcs/usbhid/Makefile
    trunk/externals/hcs/usbhid/usbhid-help.pd
    trunk/externals/hcs/usbhid/usbhid.c

Modified: trunk/externals/hcs/usbhid/Makefile
===================================================================
--- trunk/externals/hcs/usbhid/Makefile	2008-05-02 10:11:16 UTC (rev 9753)
+++ trunk/externals/hcs/usbhid/Makefile	2008-05-03 15:40:34 UTC (rev 9754)
@@ -15,10 +15,13 @@
 
 # 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 *.[ch] ../../../pd/src/*.[ch] \
+		~/code/libhid-svn/*/*.[ch] \
+		/sw/include/hid*.h /sw/include/usb*.h \
+		/System/Library/Frameworks/IOKit.framework/Headers/hid/*.h \
+		/Users/hans/Documents/Research/HID/example\ code/CrossHID/*/*.h \
+		/Users/hans/Documents/Research/HID/example\ code/CrossHID/*/*.cpp \
+		../hid/HID\ Utilities\ Source/*.[ch]
 
 #etags_Darwin:
 #	etags --append /sw/include/*.h /sw/include/*/*.h

Modified: trunk/externals/hcs/usbhid/usbhid-help.pd
===================================================================
--- trunk/externals/hcs/usbhid/usbhid-help.pd	2008-05-02 10:11:16 UTC (rev 9753)
+++ trunk/externals/hcs/usbhid/usbhid-help.pd	2008-05-03 15:40:34 UTC (rev 9754)
@@ -1,9 +1,9 @@
-#N canvas 677 22 710 687 10;
+#N canvas 866 22 710 687 10;
 #X obj 177 545 usbhid;
-#X msg 276 167 close;
+#X msg 269 173 close;
 #X msg 276 193 reset;
 #X msg 289 231 print;
-#X text 367 72 Gravis/Destroyer Tiltpad;
+#X text 367 62 Gravis/Destroyer Tiltpad;
 #N canvas 0 22 462 312 buttons 0;
 #X obj 99 36 inlet;
 #X obj 63 108 & 1;
@@ -48,47 +48,19 @@
 #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
+#X obj 42 155 metro 400;
+#X obj 44 129 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 msg 49 17 open vendorId productId;
+#X msg 226 61 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;
-#X obj 80 101 route float symbol;
-#X obj 80 190 mapping/tolist;
-#X obj 139 137 trigger symbol bang;
-#X msg 22 139 bang;
-#X obj 81 226 list trim;
-#X obj 241 312 print;
-#X obj 80 272 route path;
-#X obj 34 328 print path-------------;
-#X obj 78 31 list-abs/list-drip;
-#X obj 198 51 trigger bang bang;
-#X obj 247 89 print end---------;
-#X connect 0 0 9 0;
-#X connect 1 0 2 0;
-#X connect 1 1 3 0;
-#X connect 2 0 5 0;
-#X connect 3 0 2 0;
-#X connect 3 1 2 1;
-#X connect 4 0 2 0;
-#X connect 5 0 7 0;
-#X connect 7 0 8 0;
-#X connect 7 1 6 0;
-#X connect 9 0 1 0;
-#X connect 9 1 10 0;
-#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;
@@ -96,40 +68,75 @@
 ;
 #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;
-#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 obj 332 453 int;
-#X obj 335 434 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 10 -262144
+#X msg 213 39 open 0x046d 0xc01d;
+#X text 355 41 Logitech USB-PS/2 Optical Mouse;
+#X msg 206 15 open 0x1043 0x0015;
+#X text 344 16 CUI v1.0;
+#X msg 231 86 open 0x077d 0x0410;
+#X text 361 87 Griffin Technology PowerMate;
+#X text 362 106 Logitech RumblePad 2 USB;
+#X msg 240 106 open 0x046d 0xc218;
+#X obj 335 434 hsl 128 15 0 255 0 0 empty empty empty -2 -6 0 10 -262144
 -1 -1 0 1;
-#X obj 357 591 print ELSE;
+#X obj 281 585 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
+#X obj 283 376 hsl 128 15 0 255 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 obj 42 180 hradio 15 1 0 9 empty empty empty 0 -8 0 10 -262144 -1
+-1 0;
+#X msg 94 204 get \$1;
+#X floatatom 44 204 5 0 0 0 - - -;
+#X text 372 126 CUI I/O test;
+#X msg 250 126 open 0x0925 0x1299;
+#X obj 216 566 route open;
+#X obj 332 453 int;
+#X msg 332 473 write 0x01 0x05 0x01 \$1 0;
+#X symbolatom 383 454 10 0 0 0 - - -;
+#X text 384 148 Logitech Inc. iFeel Mouse;
+#X msg 260 147 open 0x046d 0xc030;
+#X msg 23 306 get 24;
+#X msg 301 290 path 0x00010002 0x00000000 0xff000002;
+#N canvas 0 22 450 300 pak 0;
+#X obj 45 15 inlet;
+#X obj 45 39 int;
+#X obj 48 265 outlet;
+#X obj 48 222 pack 0 0 0;
+#X obj 105 15 inlet;
+#X obj 105 39 int;
+#X obj 104 62 trigger bang 0;
+#X obj 205 15 inlet;
+#X obj 205 39 int;
+#X obj 204 62 trigger bang 0;
+#X connect 0 0 1 0;
+#X connect 1 0 3 0;
+#X connect 3 0 2 0;
+#X connect 4 0 5 0;
+#X connect 5 0 6 0;
+#X connect 6 0 3 0;
+#X connect 6 1 3 1;
+#X connect 7 0 8 0;
+#X connect 8 0 9 0;
+#X connect 9 0 3 0;
+#X connect 9 1 3 2;
+#X restore 320 394 pd pak;
+#X obj 423 376 hsl 128 15 0 255 0 0 empty empty empty -2 -6 0 10 -262144
+-1 -1 0 1;
+#X obj 563 376 hsl 128 15 0 255 0 0 empty empty empty -2 -6 0 10 -262144
+-1 -1 0 1;
+#X msg 320 415 set 0x11 0x0a \$1 \$2 0x00 \$3 0x00;
+#X text 537 290 iFeel buzz;
 #X connect 0 0 6 0;
 #X connect 0 0 17 0;
-#X connect 0 1 24 0;
+#X connect 0 1 49 0;
 #X connect 1 0 0 0;
 #X connect 2 0 0 0;
 #X connect 3 0 0 0;
@@ -138,30 +145,37 @@
 #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 7 0 44 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 45 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 19 0 0 0;
+#X connect 23 0 0 0;
+#X connect 24 0 0 0;
+#X connect 27 0 0 0;
+#X connect 30 0 0 0;
+#X connect 32 0 0 0;
 #X connect 34 0 0 0;
-#X connect 36 0 0 0;
-#X connect 38 0 0 0;
+#X connect 37 0 0 0;
+#X connect 38 0 50 0;
+#X connect 40 0 0 0;
 #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 43 0 57 0;
+#X connect 44 0 45 0;
+#X connect 44 0 46 0;
+#X connect 45 0 0 0;
 #X connect 48 0 0 0;
-#X connect 49 0 51 0;
-#X connect 50 0 49 0;
+#X connect 49 0 22 0;
+#X connect 49 1 39 0;
+#X connect 50 0 51 0;
 #X connect 51 0 0 0;
-#X connect 52 0 0 0;
+#X connect 52 0 51 0;
+#X connect 54 0 0 0;
+#X connect 55 0 0 0;
+#X connect 56 0 0 0;
+#X connect 57 0 60 0;
+#X connect 58 0 57 1;
+#X connect 59 0 57 2;
+#X connect 60 0 0 0;

Modified: trunk/externals/hcs/usbhid/usbhid.c
===================================================================
--- trunk/externals/hcs/usbhid/usbhid.c	2008-05-02 10:11:16 UTC (rev 9753)
+++ trunk/externals/hcs/usbhid/usbhid.c	2008-05-03 15:40:34 UTC (rev 9754)
@@ -96,8 +96,8 @@
 	t_int               x_device_number;
 	t_int               x_read_element_count;
 	t_int               *x_read_elements;
-	t_int               x_write_element_count;
-	t_int               *x_write_elements;
+	t_int               x_write_path_count;
+	t_int               *x_write_paths;
 	t_int               report_size;  // size in bytes of the HID report
 /* output */
 	t_atom              *output; // holder for a list of atoms to be outputted
@@ -271,26 +271,53 @@
 
 
 /* -------------------------------------------------------------------------- */
-static t_int* make_hid_path(t_int element_count, t_int argc, t_atom *argv)
+static long* make_hid_path(t_int argc, t_atom *argv)
 {
 	t_int i;
+    t_symbol *tmp_symbol;
 	t_int *return_array = NULL;
 	
-	post("element_count %d",element_count);
-	return_array = (t_int *) getbytes(sizeof(t_int) * element_count);
- 	for(i=0; i < element_count; ++i) 
-	{
-/*
- * A usbhid path component is 32 bits, the high 16 bits identify the usage page,
+    // TODO: free memory first
+	return_array = (t_int *) getbytes(sizeof(t_int) * argc);
+/* A usbhid path component is 32 bits, the high 16 bits identify the usage page,
  * and the low 16 bits the item number.
  */
-		return_array[i] = 
-			(atom_getintarg(i*2,argc,argv) << 16) + atom_getintarg(i*2+1,argc,argv);
 /* TODO: print error if a symbol is found in the data list */
-	}
+    for(i=0; i<argc; i++) {
+        tmp_symbol = atom_getsymbolarg(i, argc, argv);
+        if(tmp_symbol == &s_) // non-symbol is hopefully a float
+            return_array[i] = atom_getintarg(i, argc, argv);
+        else
+            return_array[i] = strtoul(tmp_symbol->s_name, 0, 16);
+        post("make_hid_path[%d]: 0x%08x %s", i, 
+             return_array[i], tmp_symbol->s_name);
+    }
 	return return_array;
 }
 
+static char* make_hid_packet(t_int argc, t_atom *argv)
+{
+	t_int i;
+    t_symbol *tmp_symbol;
+	char *return_array = NULL;
+	
+    // TODO: free memory first
+	return_array = (char *) getbytes(sizeof(char) * argc);
+/* A usbhid path component is 32 bits, the high 16 bits identify the usage page,
+ * and the low 16 bits the item number.
+ */
+/* TODO: print error if a symbol is found in the data list */
+    for(i=0; i<argc; i++) {
+        tmp_symbol = atom_getsymbolarg(i, argc, argv);
+        if(tmp_symbol == &s_) // non-symbol is hopefully a float
+            return_array[i] = (char) atom_getintarg(i, argc, argv);
+        else
+            return_array[i] = (char) strtoul(tmp_symbol->s_name, 0, 16);
+        post("make_hid_packet[%d]: 0x%02x %s", i, 
+             return_array[i], tmp_symbol->s_name);
+    }
+	return return_array;
+}
 
 static t_int get_device_string(HIDInterface *hidif, char *device_string)
 {
@@ -477,23 +504,44 @@
 
 
 /* -------------------------------------------------------------------------- */
-static void usbhid_set(t_usbhid *x, t_float length_arg)
+static void usbhid_path(t_usbhid *x,  t_symbol *s, int argc, t_atom *argv) 
 {
+	if(x->debug_level) post("usbhid_path");
+    int i;
+    t_symbol *tmp_symbol;
+
+	if(argc > x->x_write_path_count) {
+        if(x->debug_level) post("usbhid_path: freeing/allocating memory");
+        freebytes(x->x_write_paths, sizeof(t_int) * x->x_write_path_count);
+        x->x_write_paths = (t_int *) getbytes(sizeof(t_int) * argc);
+    }
+    
+    for(i=0; i<argc; i++) {
+        tmp_symbol = atom_getsymbolarg(i, argc, argv);
+        x->x_write_paths[i] = strtoul(tmp_symbol->s_name, 0, 16);
+        post("x->x_write_paths[%d]: 0x%08x %s", i, x->x_write_paths[i], tmp_symbol->s_name);
+    }
+}
+
+
+/* -------------------------------------------------------------------------- */
+static void usbhid_set(t_usbhid *x,  t_symbol *s, int argc, t_atom *argv) 
+{
 	if(x->debug_level) post("usbhid_set");
-	int packet_bytes = (int)length_arg;
-	char packet[packet_bytes];
+	char *packet;
 
  	if ( !hid_is_opened(x->x_hidinterface) )
 	{
 		error("[usbhid] device not open, can't set data");
 		return;
 	}
-/*	x->x_hid_return = hid_set_output_report(x->x_hidinterface, 
-										   x->x_write_elements, 
-										   x->x_write_element_count, 
-										   packet, 
-										   length_arg);
-*/
+    packet = make_hid_packet(argc, argv);
+	x->x_hid_return = hid_set_output_report(x->x_hidinterface, 
+                                            x->x_write_paths, 
+                                            x->x_write_path_count, 
+                                            packet, 
+                                            argc);
+
 	if (x->x_hid_return != HID_RET_SUCCESS) 
 	{
 		error("[usbhid] hid_get_input_report failed with return code %d\n", 
@@ -507,26 +555,34 @@
 
 
 /* -------------------------------------------------------------------------- */
+static void usbhid_read(t_usbhid *x)
+{
+	if(x->debug_level) post("usbhid_read");
+}
+
+
+/* -------------------------------------------------------------------------- */
 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
+//	int path[] = {0x00010005, 0x00010036};
+	int path[] = {0xffa00001, 0xffa00005};
+//    int *path;
+	unsigned int const depth = 2;  // number of 32bit chunks in the path
+	unsigned char const SEND_PACKET_LEN = 1; // number of bytes in packet
+	char const PACKET[] = { 0xff, 0xff }; // the data to write
+//    char const PACKET[] = { 0x00, 0x00 }; // the data to write
+//	char PACKET[] = { 0x00, 0x00 }; // the data to write
+    
 
  	if ( !hid_is_opened(x->x_hidinterface) )
 	{
 		error("[usbhid] device not open, can't set data");
 		return;
 	}
-
+/*
     path = getbytes(sizeof(int) * (argc - 1));
     depth = (argc - 1) / 2;
     for(i = 0; i < argc - 1; ++i)
@@ -535,10 +591,11 @@
             (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]);
+    SEND_PACKET_LEN = 2;
+    PACKET[1] = (unsigned short) atom_getfloat(argv + argc - 1);
+*/
+    post("depth: %d  SEND_PACKET_LEN: %d   PACKET[0]: %d  PACKET[1]: %d", 
+         depth, SEND_PACKET_LEN, PACKET[0], PACKET[1]);
     for(i = 0; i < (argc - 1) / 2; ++i)
     {
         post("path %d: 0x%08x", i, path[i]);
@@ -571,23 +628,7 @@
 	if( init_libhid(x) != HID_RET_SUCCESS ) return;
 }
 
-
 /* -------------------------------------------------------------------------- */
-/* set the HID packet for which elements to read */
-static void usbhid_set_read(t_usbhid *x, int argc, t_atom *argv)
-{
-	if(x->debug_level) post("usbhid_set_read");
-	t_int i;
-
-	x->x_read_element_count = argc / 2;
-	x->x_read_elements = make_hid_path(x->x_read_element_count, argc, argv);
-	post("x_read_element_count %d",x->x_read_element_count);
-	for(i=0;i<x->x_read_element_count;++i)
-		post("x_read_elements %d: %d",i,x->x_read_elements[i]);
-}
-
-
-/* -------------------------------------------------------------------------- */
 /* convert a list to a HID packet and set it */
 /* set the HID packet for which elements to write */
 static void usbhid_set_descriptor(t_usbhid *x, int argc, t_atom *argv)
@@ -597,11 +638,6 @@
 //	int const PATH_OUT[3] = { 0x00010002, 0x00010001, 0x00010030 };
 	t_int i;
 
-	x->x_write_element_count = argc / 2;
-	x->x_write_elements = make_hid_path(x->x_write_element_count, argc, argv);
-	post("x_write_element_count %d",x->x_write_element_count);
-	for(i=0;i<x->x_write_element_count;++i)
-		post("x_write_elements %d: %d",i,x->x_write_elements[i]);
 }
 
 
@@ -622,9 +658,10 @@
 	else 
 	{
 		post("[usbhid] parse tree of HIDInterface %s:\n", x->x_hidinterface->id);
-		reset_output(x);
+//		reset_output(x);
 		while (HIDParse(x->x_hidinterface->hid_parser, x->x_hidinterface->hid_data)) {
-			add_symbol_to_output(x, gensym("path"));
+            reset_output(x);
+//			add_symbol_to_output(x, gensym("path"));
 			switch(x->x_hidinterface->hid_data->Type)
 			{
 			case 0x80: 
@@ -644,25 +681,29 @@
 			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);
+//                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);
 			add_float_to_output(x, x->x_hidinterface->hid_data->LogMax);
+            outlet_anything(x->x_status_outlet, gensym("element"), 
+                            x->output_count, x->output);
 		}
-		add_symbol_to_output(x, gensym("totalSize"));
+		reset_output(x);
+//		add_symbol_to_output(x, gensym("totalSize"));
 		add_float_to_output(x, input_size);
 		add_float_to_output(x, output_size);
 		add_float_to_output(x, feature_size);
-		outlet_anything(x->x_status_outlet, gensym("device"), 
+		outlet_anything(x->x_status_outlet, gensym("totalSize"), 
 						x->output_count, x->output);
+//		outlet_anything(x->x_status_outlet, gensym("device"), 
+//						x->output_count, x->output);
 	}
 }
 
@@ -745,7 +786,7 @@
 	usbhid_close(x);
 
 	freebytes(x->x_read_elements,sizeof(t_int) * x->x_read_element_count);
-	freebytes(x->x_write_elements,sizeof(t_int) * x->x_write_element_count);
+	freebytes(x->x_write_paths,sizeof(t_int) * x->x_write_path_count);
 
 	if(x->debug_level) 
 		post("[usbhid] freeing instance %d",usbhid_instance_count);
@@ -797,9 +838,9 @@
 	matcher.vendor_id = HID_ID_MATCH_ANY;
 	matcher.product_id = HID_ID_MATCH_ANY;
 	matcher.matcher_fn = device_iterator;
+    x->x_write_path_count = 0;
 	
 	x->x_device_number = f;
-
 /* Open the device and save settings.  If there is an error, return the object
  * anyway, so that the inlets and outlets are created, thus not breaking the
  * patch.   */
@@ -825,22 +866,26 @@
 //	class_addbang(usbhid_class,(t_method) usbhid_bang);
 
 /* add inlet message methods */
-	class_addmethod(usbhid_class,(t_method) usbhid_print,gensym("print"),0);
-	class_addmethod(usbhid_class,(t_method) usbhid_reset,gensym("reset"),0);
-	class_addmethod(usbhid_class,(t_method) usbhid_refresh,gensym("refresh"),0);
-	class_addmethod(usbhid_class,(t_method) usbhid_debug,gensym("debug"),
+	class_addmethod(usbhid_class,(t_method)usbhid_print, gensym("print"), 0);
+	class_addmethod(usbhid_class,(t_method)usbhid_reset, gensym("reset"), 0);
+	class_addmethod(usbhid_class,(t_method)usbhid_refresh, gensym("refresh"), 0);
+	class_addmethod(usbhid_class,(t_method)usbhid_debug, gensym("debug"),
 					A_DEFFLOAT,0);
-	class_addmethod(usbhid_class,(t_method) usbhid_descriptor,gensym("descriptor"),
+	class_addmethod(usbhid_class,(t_method)usbhid_descriptor, gensym("descriptor"),
+					A_GIMME, 0);
+	class_addmethod(usbhid_class,(t_method)usbhid_path, gensym("path"),
+					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_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"),
+	class_addmethod(usbhid_class,(t_method)usbhid_read,gensym("read"), 
+                    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);
-	class_addmethod(usbhid_class,(t_method) usbhid_close,gensym("close"),0);
+	class_addmethod(usbhid_class,(t_method)usbhid_open,gensym("open"),
+					A_DEFSYM, A_DEFSYM, 0);
+	class_addmethod(usbhid_class,(t_method)usbhid_close,gensym("close"), 0);
 }
 
 #endif /* NOT _WIN32 */


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Pd-cvs mailing list