[PD-cvs] SF.net SVN: pure-data: [9764] trunk/externals/io/hidio

eighthave at users.sourceforge.net eighthave at users.sourceforge.net
Mon May 5 16:51:13 CEST 2008


Revision: 9764
          http://pure-data.svn.sourceforge.net/pure-data/?rev=9764&view=rev
Author:   eighthave
Date:     2008-05-05 07:51:12 -0700 (Mon, 05 May 2008)

Log Message:
-----------
very basic output using Apple HID Utilities to a CUI IO v1.0 firmware, I got the LED to toggle properly

Modified Paths:
--------------
    trunk/externals/io/hidio/Makefile
    trunk/externals/io/hidio/hidio-help.pd
    trunk/externals/io/hidio/hidio_darwin.c

Modified: trunk/externals/io/hidio/Makefile
===================================================================
--- trunk/externals/io/hidio/Makefile	2008-05-05 13:57:23 UTC (rev 9763)
+++ trunk/externals/io/hidio/Makefile	2008-05-05 14:51:12 UTC (rev 9764)
@@ -26,6 +26,8 @@
 		/System/Library/Frameworks/CoreServices.framework/Headers/*.h  \
 		/System/Library/Frameworks/IOKit.framework/Headers/*.[ch] \
 		/System/Library/Frameworks/IOKit.framework/Headers/hid*/*.[ch] \
+		/Users/hans/Documents/Research/HID/example\ code/CrossHID/*/*.h \
+		/Users/hans/Documents/Research/HID/example\ code/CrossHID/*/*.cpp \
 		/usr/include/mach/*.h
 
 etags_Linux:

Modified: trunk/externals/io/hidio/hidio-help.pd
===================================================================
--- trunk/externals/io/hidio/hidio-help.pd	2008-05-05 13:57:23 UTC (rev 9763)
+++ trunk/externals/io/hidio/hidio-help.pd	2008-05-05 14:51:12 UTC (rev 9764)
@@ -1,4 +1,4 @@
-#N canvas 637 32 886 611 10;
+#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
@@ -9,9 +9,9 @@
 #X obj 2 2 cnv 15 900 20 empty empty [hidio] 2 11 1 18 -233017 -66577
 0;
 #X text 224 324 outlet message format:;
-#X msg 374 140 close;
-#X msg 374 119 refresh;
-#X text 435 117 refresh device list;
+#X msg 374 130 close;
+#X msg 374 109 refresh;
+#X text 435 107 refresh device list;
 #X text 537 487 For more info:;
 #X text 266 557 released under the GNU GPL;
 #X text 472 544 $Revision: 1.6 $$Date: 2007-07-26 07:31:38 $;
@@ -223,9 +223,9 @@
 -66577 0;
 #X restore 698 114 pd Event_Values;
 #X floatatom 140 445 5 0 0 0 - - -;
-#X msg 374 161 print;
-#X text 437 141 close the device;
-#X text 437 162 print the device and element lists;
+#X msg 374 151 print;
+#X text 437 131 close the device;
+#X text 437 152 print the device and element lists;
 #X text 9 212 Any non-zero value starts polling \,;
 #X text 8 225 0 stops the polling. If the number;
 #X text 9 238 is greater than 1 \, then the poll;
@@ -268,7 +268,7 @@
 #X obj 459 508 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
 66455;
 #X msg 25 155 debug 9;
-#X msg 298 145 info;
+#X msg 298 135 info;
 #N canvas 743 25 411 235 see 0;
 #N canvas 108 318 543 264 route 0;
 #X obj 27 14 inlet;
@@ -422,10 +422,10 @@
 #X coords 0 -1 1 1 165 17 1 60 60;
 #X restore 25 134 pd serin;
 #N canvas 162 133 570 420 serin 0;
-#X obj 286 61 cnv 15 30 15 empty \$0-open-canvas 2 4 8 0 14 -233017
+#X obj 286 61 cnv 15 30 15 empty \$0-open-canvas 0 4 8 0 14 -233017
 -1 0;
 #X obj 60 61 hradio 15 1 1 15 empty empty empty 0 -6 0 8 -225271 -1
--1 2;
+-1 0;
 #X obj 60 13 inlet;
 #X msg 200 202 label \$1;
 #X obj 200 180 makefilename %d;
@@ -448,9 +448,9 @@
 #X connect 9 0 7 0;
 #X connect 10 0 8 0;
 #X coords 0 -1 1 1 257 17 1 60 60;
-#X restore 262 93 pd serin;
+#X restore 262 83 pd serin;
 #X obj 646 486 pddp/open all_about_hid;
-#X obj 306 235 hidio;
+#X obj 306 244 hidio;
 #X obj 226 290 flatspace/prepend set;
 #X obj 544 315 unpack symbol symbol float float;
 #X floatatom 683 336 2 0 0 1 instance - -;
@@ -485,7 +485,7 @@
 #X obj 189 192 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
 1;
 #X obj 292 122 spigot;
-#X obj 333 99 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1
+#X obj 333 99 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
 ;
 #X obj 354 45 inlet;
 #X obj 290 162 print RAW;
@@ -502,40 +502,30 @@
 #X connect 10 0 9 0;
 #X restore 408 294 pd raw;
 #X floatatom 63 401 6 0 0 0 - - -;
-#X obj 455 295 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1
+#X obj 455 295 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
 1;
-#X msg 262 114 open 2;
-#N canvas 0 0 450 300 output 1;
-#X obj 170 265 outlet;
-#X msg 228 233 write 0x11 0x01 0 \$1;
-#X obj 228 212 tgl 15 0 empty empty empty 0 -6 0 10 -262144 -1 -1 0
-1;
-#X obj 213 171 tgl 15 0 empty empty empty 0 -6 0 10 -262144 -1 -1 0
-1;
-#X msg 213 192 write 0x11 0x00 0 \$1;
-#X text 344 190 numlock;
-#X text 359 231 capslock;
-#X msg 163 134 write 0x15 \$1 0 \$2;
-#X obj 161 97 pack symbol float;
-#X symbolatom 171 65 10 0 0 0 - - -;
-#X obj 151 40 makefilename 0x%d;
-#X obj 154 13 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 10 -262144
--1 -1 1000 1;
-#X obj 260 68 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 10 -262144
--1 -1 1200 1;
-#X floatatom 277 89 5 0 0 0 - - -;
-#X connect 1 0 0 0;
-#X connect 2 0 1 0;
-#X connect 3 0 4 0;
-#X connect 4 0 0 0;
+#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 8 0 7 0;
-#X connect 10 0 9 0;
-#X connect 10 0 8 0;
-#X connect 11 0 10 0;
-#X connect 12 0 8 1;
-#X connect 12 0 13 0;
-#X restore 372 210 pd output support;
+#X connect 7 0 8 0;
+#X restore 373 211 pd output support;
 #X connect 2 0 60 0;
 #X connect 8 0 60 0;
 #X connect 9 0 60 0;

Modified: trunk/externals/io/hidio/hidio_darwin.c
===================================================================
--- trunk/externals/io/hidio/hidio_darwin.c	2008-05-05 13:57:23 UTC (rev 9763)
+++ trunk/externals/io/hidio/hidio_darwin.c	2008-05-05 14:51:12 UTC (rev 9764)
@@ -98,7 +98,7 @@
 static void convert_axis_to_symbols(pRecElement pCurrentHIDElement, 
 									t_hid_element *new_element, int array_index)
 {
-	if (pCurrentHIDElement->relative) 
+	if (pCurrentHIDElement->relative)
 	{ 
 		new_element->type = ps_relative; 
 		new_element->name = relative_symbols[array_index];
@@ -395,7 +395,7 @@
 	pRecElement pCurrentHIDElement;
 	pRecDevice pCurrentHIDDevice = device_pointer[x->x_device_number];
 	t_hid_element *new_element;
-  
+
 	element_count[x->x_device_number] = 0;
 	if( HIDIsValidDevice(pCurrentHIDDevice) ) 
 	{
@@ -403,8 +403,7 @@
 		 * try queuing the whole device, then removing specific elements from
 		 * the queue */
 		HIDQueueDevice(pCurrentHIDDevice);
-		pCurrentHIDElement = HIDGetFirstDeviceElement( pCurrentHIDDevice,
-													   kHIDElementTypeInput );
+		pCurrentHIDElement = HIDGetFirstDeviceElement( pCurrentHIDDevice, kHIDElementTypeIO );
 
 		/* TODO: axes should be the first elements in the array since they
 		 * produce many more events than buttons.  This will save loop cycles
@@ -476,7 +475,7 @@
 						pCurrentHIDElement->min,pCurrentHIDElement->max);
 			element[x->x_device_number][element_count[x->x_device_number]] = new_element;
 			++element_count[x->x_device_number];
-			pCurrentHIDElement = HIDGetNextDeviceElement(pCurrentHIDElement, kHIDElementTypeInput);
+			pCurrentHIDElement = HIDGetNextDeviceElement(pCurrentHIDElement, kHIDElementTypeIO);
 		}
 	}
 }
@@ -652,7 +651,7 @@
 
 void hidio_get_events(t_hidio *x)
 {
-	unsigned int       i,j;
+	unsigned int       i;
 	pRecDevice         pCurrentHIDDevice;
 	t_hid_element      *current_element;
 	IOHIDEventStruct   event;
@@ -676,12 +675,13 @@
 //		debug_post(LOG_DEBUG,"output this: %s %s %d prev %d",current_element->type->s_name,
 //			 current_element->name->s_name, current_element->value, 
 //			 current_element->previous_value);
-		timestamp =  * (uint64_t *) &(event.timestamp);
-		difference = calculate_event_latency(timestamp,0);
+		timestamp =  * (uint64_t *) &(event.timestamp);	
+/*
+// temp hack for measuring latency
+        difference = calculate_event_latency(timestamp,0);
 		debug_post(LOG_DEBUG,"timestamp: %llu %llu", timestamp, difference);
 		now =  mach_absolute_time();
-/*
-// temp hack for measuring latency
+
 		difference = calculate_event_latency(now, timestamp);
 		if( latency_i < LATENCY_MAX)
 		{
@@ -717,7 +717,19 @@
 					   t_float instance, t_float value)
 {
 	debug_post(LOG_DEBUG,"hidio_write_event");
-	
+	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))
+		elem = HIDGetNextDeviceElement(elem, kHIDElementTypeOutput);	
+    
+    post("element usage page and usage: 0x%04x 0x%04x", elem->usagePage, elem->usage);
+	event.elementCookie = (IOHIDElementCookie)cookie;
+	event.value = (SInt32)value;
+    post("elem->cookie, cookie, event.value, value: %d %d %d %f",
+         elem->cookie, cookie, event.value, value);
+	HIDSetElementValue(pCurrentHIDDevice, elem, &event);	
 }
 
 


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