[PD-cvs] externals/hcs/hid joystick-help.pd,NONE,1.1 joystick.pd,NONE,1.1 TODO,1.1,1.2 hid-help.pd,1.6,1.7 hid.c,1.9,1.10 hid.h,1.6,1.7 hid_darwin.c,1.5,1.6 mouse-help.pd,1.1,1.2 mouse.pd,1.1,1.2

Hans-Christoph Steiner eighthave at users.sourceforge.net
Sat Nov 6 22:15:06 CET 2004


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

Modified Files:
	TODO hid-help.pd hid.c hid.h hid_darwin.c mouse-help.pd 
	mouse.pd 
Added Files:
	joystick-help.pd joystick.pd 
Log Message:
things are working MacOS X, but there are lots of bugs

Index: TODO
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/TODO,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TODO	4 Nov 2004 17:24:17 -0000	1.1
--- TODO	6 Nov 2004 21:15:04 -0000	1.2
***************
*** 55,60 ****
  (in SC_HID.c its locID and cookie)
  
! it should probably just store the Pd arguments
  
  
  
--- 55,62 ----
  (in SC_HID.c its locID and cookie)
  
! - it should probably just store the Pd arguments
  
+ - this will have to be dealt with when the "mouse0", "joystick2" arguments are
+   implemented 
  
  
***************
*** 70,80 ****
    devices map to the same value
  
- - but then, I could just create an [autocal] object in Pd, and have [hid]
-   output only raw values.  This would probably be best in keeping with the
-   idea of having [hid] giving as low level access as possible, then using
-   [mouse], [joystick], [tablet], etc. objects providing a nice, consistent
-   interface to the respective devices.
- 
- 
  
  ==============================================================================
--- 72,75 ----
***************
*** 91,136 ****
  
  ==============================================================================
! =  make generic functions for the basic actions
! 
!     releaseDevices()
!     buildDeviceList()
!     buildElementList()
!     getEvent()
  
!  - make Darwin HID Manager -> Linux input event convertor functions
  
  
  
  ==============================================================================
! = [close( message might be totally frivolous.
  
! - what does Max's [hi] do with that?
  
! - when would you need to close a device, yet still have the object there?
!   [open( closes the previous device anyway.
  
  
  
  ==============================================================================
! = function return values
  
! - most functions probably do not need return values
  
- - return (1) seems to be the default on many functions
  
  
  ==============================================================================
! = control input messages
  
! - the [delay( message should be replaced by the [poll( msg
  
- - should [poll( also start things, or should it just set polling time?
  
! - are [start( and [stop( needed?  is 0/1 enough?
  
  
  
  
  
  
  
--- 86,153 ----
  
  ==============================================================================
! = function return values
  
! - most functions probably do not need return values
  
+ - return (1) seems to be the default on many functions
  
  
  ==============================================================================
! = control input messages
  
! - the [delay( message should be replaced by the [poll( msg
  
! - should [poll( also start things, or should it just set polling time?
  
+ - are [start( and [stop( needed?  is 0/1 enough?
  
  
  ==============================================================================
! = ditch x_devname in hid_linux.c
  
! - use sprintf(arg,"/dev/input/event%d",x_ddevice_number); instead
  
  
  
  ==============================================================================
! =  consistent console output 
  
! void hid_post(const char *format, const char *);
  
  
! ==============================================================================
! = if device is closed and obj is started, open device and start
! 
! 
! ______________________________________________________________________________
! ------------------------------------------------------------------------------
! BUGS
! ______________________________________________________________________________
! ------------------------------------------------------------------------------
! 
! ______________________________________________________________________________
! - BUG x->x_delay reset to default when device is opened
  
+ ______________________________________________________________________________
+ - BUG: [mouse] and [joystick] arguments don't work to open device
  
+ ______________________________________________________________________________
+ - BUG: [open('ing a device causes all other active [hid] objs to have their
+ devices closed
  
+ - this means only one [hid] object can have an open device at one time
  
+ - I thought this was due to the hid_close_device() call in hid_open(), which releases
+   the device list, but this doesn't seem to be the case.
  
+ ______________________________________________________________________________
+ - BUG: getting events from the queue doesn't output a 0 value event when the
+   motion stops, so when the mouse stops, the sound keeps playing.
+ 
+ This is probably only a problem on relative axes.
  
+   This will probably have to be implemented on a platform-specific level:  
+ 
+   - On Darwin/MacOSX, I think that the HIDGetEvent() loop will have to be
+     followed by one call to HIDGetElementValue()
  

Index: mouse.pd
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/mouse.pd,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** mouse.pd	4 Nov 2004 00:17:49 -0000	1.1
--- mouse.pd	6 Nov 2004 21:15:04 -0000	1.2
***************
*** 1,3 ****
! #N canvas 305 189 689 434 10;
  #X obj 125 38 inlet;
  #X obj 5 346 outlet;
--- 1,3 ----
! #N canvas 305 189 693 438 10;
  #X obj 125 38 inlet;
  #X obj 5 346 outlet;
***************
*** 20,24 ****
  #X obj 187 61 f \$1;
  #X obj 187 37 loadbang;
- #X obj 125 115 hid;
  #X obj 5 283 autoscale -1 1;
  #X obj 110 283 autoscale -1 1;
--- 20,23 ----
***************
*** 26,47 ****
  #X obj 67 233 route rel_x rel_y rel_wheel;
  #X obj 271 258 print MOUSE_UNIMPLEMENTED_EVENT;
! #X connect 0 0 20 0;
  #X connect 7 0 6 0;
  #X connect 8 0 7 0;
  #X connect 9 0 8 0;
! #X connect 15 0 24 0;
  #X connect 15 1 16 0;
- #X connect 15 2 25 0;
  #X connect 16 0 4 0;
  #X connect 16 1 5 0;
- #X connect 17 0 20 0;
  #X connect 18 0 17 0;
  #X connect 19 0 18 0;
! #X connect 20 0 15 0;
! #X connect 21 0 1 0;
! #X connect 22 0 2 0;
! #X connect 23 0 3 0;
! #X connect 24 0 21 0;
! #X connect 24 1 22 0;
! #X connect 24 2 23 0;
! #X connect 24 3 25 0;
--- 25,45 ----
  #X obj 67 233 route rel_x rel_y rel_wheel;
  #X obj 271 258 print MOUSE_UNIMPLEMENTED_EVENT;
! #X text 343 139 this is for once this feature is implemented;
! #X obj 125 115 hid \$1;
! #X connect 0 0 26 0;
  #X connect 7 0 6 0;
  #X connect 8 0 7 0;
  #X connect 9 0 8 0;
! #X connect 15 0 23 0;
  #X connect 15 1 16 0;
  #X connect 16 0 4 0;
  #X connect 16 1 5 0;
  #X connect 18 0 17 0;
  #X connect 19 0 18 0;
! #X connect 20 0 1 0;
! #X connect 21 0 2 0;
! #X connect 22 0 3 0;
! #X connect 23 0 20 0;
! #X connect 23 1 21 0;
! #X connect 23 2 22 0;
! #X connect 26 0 15 0;

Index: hid_darwin.c
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/hid_darwin.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** hid_darwin.c	6 Nov 2004 01:03:01 -0000	1.5
--- hid_darwin.c	6 Nov 2004 21:15:04 -0000	1.6
***************
*** 66,81 ****
   *======================================================================== */
  
- /* count of total number of devices found */
- int gNumberOfHIDDevices = 0;
- 
- /* 
-  *	an array of discovered devices, which is used for selecting the
-  * current device, by #, type, or name
-  */
- pRecDevice discoveredDevices[256];
- 
- /* timer for element data updates */
- EventLoopTimerRef gTimer = NULL; 
- 
  /*==============================================================================
   * FUNCTION PROTOTYPES
--- 66,69 ----
***************
*** 87,99 ****
  
  /* IOKit HID Utilities functions from SC_HID.cpp */
- void releaseHIDDevices(void);
  int prHIDBuildElementList(t_hid *x);
  int prHIDBuildDeviceList(void);
  int prHIDGetValue(void);
- void PushQueueEvents_RawValue(void);
- void PushQueueEvents_CalibratedValue(void);
- int prHIDReleaseDeviceList(void);
- //int prHIDRunEventLoop(void);
- //int prHIDStopEventLoop(void);
  
  /*==============================================================================
--- 75,81 ----
***************
*** 220,223 ****
--- 202,231 ----
  }
  
+ pRecDevice hid_get_device_by_number(t_int device_number)
+ {
+ 	pRecDevice currentDevice;
+ 	t_int i, numdevs;
+ 
+ /*
+  *	If the specified device is greater than the total number of devices, return
+  *	an error.
+  */
+ 	numdevs = (t_int) HIDCountDevices();
+ 	if (device_number >= numdevs) {
+ 		error("[hid]: no such device, \"%d\", only %d devices found\n",device_number,numdevs);
+ 		return (NULL);
+ 	}
+ /*
+  *	The most recently discovered HID is the first element of the list here.  I
+  *	want the oldest to be number 0 rather than the newest, so I use (numdevs -
+  *	device_number - 1).
+  */
+ 	currentDevice = HIDGetFirstDevice();
+ 	for(i=0; i < numdevs - device_number - 1; ++i)
+ 		currentDevice = HIDGetNextDevice(currentDevice);
+ 
+ 	return currentDevice;
+ }
+ 
  /* ============================================================================== */
  /* Pd [hid] FUNCTIONS */
***************
*** 258,262 ****
  		while (pCurrentHIDElement && (pCurrentHIDElement->cookie != cookie))
  			pCurrentHIDElement = HIDGetNextDeviceElement (pCurrentHIDElement, kHIDElementTypeIO);
! 		
  //		convertDarwinToLinuxType((IOHIDElementType) pCurrentHIDElement->type, event_output_string);
  		HIDGetUsageName(pCurrentHIDElement->usagePage, pCurrentHIDElement->usage, event_output_string);
--- 266,271 ----
  		while (pCurrentHIDElement && (pCurrentHIDElement->cookie != cookie))
  			pCurrentHIDElement = HIDGetNextDeviceElement (pCurrentHIDElement, kHIDElementTypeIO);
! 
! 		DEBUG(
  //		convertDarwinToLinuxType((IOHIDElementType) pCurrentHIDElement->type, event_output_string);
  		HIDGetUsageName(pCurrentHIDElement->usagePage, pCurrentHIDElement->usage, event_output_string);
***************
*** 265,268 ****
--- 274,278 ----
  			pCurrentHIDDevice->vendorID, pCurrentHIDDevice->productID,
  			(long) pCurrentHIDElement->cookie, event_output_string);
+ 		); //end DEBUG
  		
  		convertDarwinElementToLinuxTypeCode(pCurrentHIDElement,type,code);
***************
*** 326,330 ****
  	DEBUG(post("hid_open_device"););
  
! 	t_int i,err,result;
  	pRecDevice currentDevice = NULL;
  
--- 336,340 ----
  	DEBUG(post("hid_open_device"););
  
! 	t_int err,result;
  	pRecDevice currentDevice = NULL;
  
***************
*** 333,356 ****
  	if(result) error("[hid]: no HID devices found\n");
  
! /*
!  *	If the specified device is greater than the total number of devices, return
!  *	an error.
!  */
! 	int numdevs = HIDCountDevices();
! 	gNumberOfHIDDevices = numdevs;
! 	if (device_number >= numdevs) {
! 		error("[hid]: no such device, \"%d\", only %d devices found\n",device_number,numdevs);
! 		return (1);
! 	}
! 	
! 	currentDevice = HIDGetFirstDevice();
! 
! /*
!  *	The most recently discovered HID is the first element of the list here.  I
!  *	want the oldest to be number 0 rather than the newest, so I use (numdevs -
!  *	device_number - 1).
!  */
! 	for(i=0; i < numdevs - device_number - 1; ++i)
! 		currentDevice = HIDGetNextDevice(currentDevice);
  
  	x->x_locID = currentDevice->locID;
--- 343,347 ----
  	if(result) error("[hid]: no HID devices found\n");
  
! 	currentDevice = hid_get_device_by_number(device_number);
  
  	x->x_locID = currentDevice->locID;
***************
*** 372,381 ****
  	DEBUG(post("hid_close_device"););
  
! 	post("[hid] close_device %d",x->x_device_number);
! 	HIDReleaseAllDeviceQueues();
! 	HIDReleaseDeviceList();
! 	gNumberOfHIDDevices = 0;
! 
! 	return (0);
  }
  
--- 363,368 ----
  	DEBUG(post("hid_close_device"););
  
! 	post("[hid] closing device %d",x->x_device_number);
! 	return( HIDDequeueDevice( hid_get_device_by_number(x->x_device_number) ) );
  }
  
***************
*** 391,395 ****
  }
  
! 
  
  /*==============================================================================
--- 378,386 ----
  }
  
! void hid_platform_specific_free(t_hid *x)
! {
! 	HIDReleaseAllDeviceQueues();
! 	HIDReleaseDeviceList();
! }
  
  /*==============================================================================
***************
*** 398,415 ****
   */
  
- void releaseHIDDevices (void)
- {
- 	DEBUG(post("releaseHIDDevices"););
- 
- 	if (gTimer)
-     {    
- 		RemoveEventLoopTimer(gTimer);
- 		gTimer = NULL;
- 	}
- 	HIDReleaseAllDeviceQueues();
- 	HIDReleaseDeviceList();
- 	gNumberOfHIDDevices = 0;
- }
- 
  int prHIDBuildElementList(t_hid *x)
  {
--- 389,392 ----
***************
*** 475,479 ****
  	
  	int numdevs = HIDCountDevices();
- 	gNumberOfHIDDevices = numdevs;
  	// exit if no devices found
  	if(!numdevs) return (0);
--- 452,455 ----
***************
*** 483,487 ****
  	
  	pCurrentHIDDevice = HIDGetFirstDevice();
! 	for(i=gNumberOfHIDDevices - 1; i >= 0; --i)
  	{
  		post("Device %d: '%s' '%s' version %d",i,
--- 459,463 ----
  	
  	pCurrentHIDDevice = HIDGetFirstDevice();
! 	for(i=numdevs - 1; i >= 0; --i)
  	{
  		post("Device %d: '%s' '%s' version %d",i,
***************
*** 547,694 ****
  }
  
- 
- void PushQueueEvents_RawValue(void)
- {
- 	DEBUG(post("PushQueueEvents_RawValue"););
- 
- 	int i;
- 	
- 	IOHIDEventStruct event;
- 	pRecDevice  pCurrentHIDDevice = HIDGetFirstDevice ();
- 	int numdevs = gNumberOfHIDDevices;
- 	unsigned char result;
- 	for(i=0; i< numdevs; i++)
- 	{
- 		result = HIDGetEvent(pCurrentHIDDevice, (void*) &event);
- 		if(result) 
- 		{
- 			SInt32 value = event.value;
- 			int vendorID = pCurrentHIDDevice->vendorID;
- 			int productID = pCurrentHIDDevice->productID;			
- 			int locID = pCurrentHIDDevice->locID;
- 			IOHIDElementCookie cookie = (IOHIDElementCookie) event.elementCookie;
- 			//set arguments: 
- //			++g->sp;SetInt(g->sp, vendorID); 
- //			++g->sp;SetInt(g->sp, productID); 			
- //			++g->sp;SetInt(g->sp, locID); 
- //			++g->sp;SetInt(g->sp, (int) cookie); 
- //			++g->sp;SetInt(g->sp, value); 
- 		}
- 		pCurrentHIDDevice = HIDGetNextDevice(pCurrentHIDDevice);
- 	}
- }
- 
- 
- void PushQueueEvents_CalibratedValue(void)
- {
- 	DEBUG(post("PushQueueEvents_CalibratedValue"););
- 
- 	int i;
- 	
- 	IOHIDEventStruct event;
- 	pRecDevice  pCurrentHIDDevice = HIDGetFirstDevice ();
- 	
- 	int numdevs = gNumberOfHIDDevices;
- 	unsigned char result;
- 	for(i=0; i< numdevs; i++)
- 	{
- 
- 		result = HIDGetEvent(pCurrentHIDDevice, (void*) &event);
- 		if(result) 
- 		{
- 			SInt32 value = event.value;
- 			int vendorID = pCurrentHIDDevice->vendorID;
- 			int productID = pCurrentHIDDevice->productID;			
- 			int locID = pCurrentHIDDevice->locID;
- 			IOHIDElementCookie cookie = (IOHIDElementCookie) event.elementCookie;
- 			pRecElement pCurrentHIDElement =  HIDGetFirstDeviceElement (pCurrentHIDDevice, kHIDElementTypeIO);
- 	// use gElementCookie to find current element
- 			while (pCurrentHIDElement && ( (pCurrentHIDElement->cookie) != cookie))
- 				pCurrentHIDElement = HIDGetNextDeviceElement (pCurrentHIDElement, kHIDElementTypeIO);
- 		
- 			if (pCurrentHIDElement)
- 			{
- 			value = HIDCalibrateValue(value, pCurrentHIDElement);
- 			//find element to calibrate
- 			//set arguments: 
- //			++g->sp;SetInt(g->sp, vendorID); 
- //			++g->sp;SetInt(g->sp, productID); 			
- //			++g->sp;SetInt(g->sp, locID); 
- //			++g->sp;SetInt(g->sp, (int) cookie); 
- //			++g->sp;SetInt(g->sp, value); 
- 			}
- 		}
- 		pCurrentHIDDevice = HIDGetNextDevice(pCurrentHIDDevice);
- 	}
- }
- 
- 
- /* static pascal void IdleTimer(EventLoopTimerRef inTimer, void* userData) */
- /* { */
- /* 	DEBUG(post("IdleTimer");); */
- 
- /* 	#pragma unused (inTimer, userData) */
- /* 	PushQueueEvents_CalibratedValue (); */
- /* } */
- 
- 
- int prHIDReleaseDeviceList(void)
- {
- 	DEBUG(post("prHIDReleaseDeviceList"););
- 
- 	releaseHIDDevices();
- 	return (0);	
- }
- 
- 
- /* static EventLoopTimerUPP GetTimerUPP(void) */
- /* { */
- /* 	DEBUG(post("GetTimerUPP");); */
- 	
- /* 	static EventLoopTimerUPP sTimerUPP = NULL; */
- /* 	if (sTimerUPP == NULL) */
- /* 		sTimerUPP = NewEventLoopTimerUPP(IdleTimer); */
- 	
- /* 	return sTimerUPP; */
- /* } */
- 
- 
- /*
- typedef void (*IOHIDCallbackFunction)
-               (void * target, IOReturn result, void * refcon, void * sender);
- 
- */
- /*
- void callback  (void * target, IOReturn result, void * refcon, void * sender);
- void callback  (void * target, IOReturn result, void * refcon, void * sender)
- {
- }
- */
- 
- /* int prHIDRunEventLoop(void) */
- /* { */
- /* 	DEBUG(post("prHIDRunEventLoop");); */
- 
- /* 	//PyrSlot *a = g->sp - 1; //class */
- 
- /* 	InstallEventLoopTimer(GetCurrentEventLoop(), 0, 0.001, GetTimerUPP (), 0, &gTimer); */
- 
- /* 	//HIDSetQueueCallback(pCurrentHIDDevice, callback); */
- /* 	return (0);	 */
- /* } */
- 
- /* int prHIDStopEventLoop(void) */
- /* { */
- /* 	DEBUG(post("prHIDStopEventLoop");); */
- 
- /* 	if (gTimer) */
- /*         RemoveEventLoopTimer(gTimer); */
- /* 	gTimer = NULL; */
- /* 	return (0);	 */
- /* } */
- 
- /* this is just a rough sketch */
- 
- 
  //void HIDGetUsageName (const long valueUsagePage, const long valueUsage, char * cstrName)
  char *convertEventsFromDarwinToLinux(pRecElement element)
--- 523,526 ----

--- NEW FILE: joystick.pd ---
#N canvas 353 77 803 591 10;
#X msg 96 64 start;
#X msg 105 83 stop;
#X obj 77 30 inlet;
#X obj 207 160 print UNKNOWN_JOYSTICK_EVENT_TYPE;
#X text 260 134 types (1=buttons 3=abs axes);
#X obj 218 286 print UNKNOWN_JOYSTICK_EVENT_CODE;
#X obj 38 508 outlet;
#X obj 143 327 outlet;
#X obj 164 307 outlet;
#X text 52 244 codes (0=X 1=Y 6=throttle 7=rudder \, 16=hat0X \, 17=hat0Y)
;
#X obj 411 417 outlet;
#X text 401 433 button_num;
#X text 492 434 button_value;
#X obj 511 418 outlet;
#X obj 77 107 hid \$1;
#X obj 38 264 route abs_x abs_y 7 16 17 6;
#X obj 38 489 autoscale -1 1;
#X obj 68 468 outlet;
#X obj 68 449 autoscale -1 1;
#X obj 99 428 outlet;
#X obj 99 409 autoscale -1 1;
#X obj 130 388 outlet;
#X obj 130 369 autoscale -1 1;
#X obj 79 139 route ev_abs ev_key;
#X obj 221 91 print RAW;
#X obj 411 351 unpack s f f;
#X connect 0 0 14 0;
#X connect 1 0 14 0;
#X connect 2 0 14 0;
#X connect 14 0 23 0;
#X connect 15 0 16 0;
#X connect 15 1 18 0;
#X connect 15 2 20 0;
#X connect 15 3 22 0;
#X connect 15 4 7 0;
#X connect 15 5 8 0;
#X connect 16 0 6 0;
#X connect 18 0 17 0;
#X connect 20 0 19 0;
#X connect 22 0 21 0;
#X connect 23 0 15 0;
#X connect 23 1 25 0;
#X connect 23 2 3 0;
#X connect 25 0 10 0;
#X connect 25 1 13 0;

Index: hid.h
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/hid.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** hid.h	6 Nov 2004 01:03:00 -0000	1.6
--- hid.h	6 Nov 2004 21:15:04 -0000	1.7
***************
*** 25,33 ****
  		t_symbol            *x_devname;
  		t_int               x_device_number;
  		t_clock             *x_clock;
- 		t_int               x_read_ok;
- 		t_int               x_started;
  		t_int               x_delay;
! 		long                x_locID;
  } t_hid;
  
--- 25,33 ----
  		t_symbol            *x_devname;
  		t_int               x_device_number;
+ 		long                x_locID;
  		t_clock             *x_clock;
  		t_int               x_delay;
! 		t_int               x_started;
! 		t_int               x_device_open;
  } t_hid;
  
***************
*** 51,54 ****
--- 51,55 ----
  t_int hid_devicelist_refresh(t_hid* x);
  t_int hid_output_events(t_hid *x) ;
+ void hid_platform_specific_free(t_hid *x);
  
  #endif  /* #ifndef _HID_H */

Index: mouse-help.pd
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/mouse-help.pd,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** mouse-help.pd	4 Nov 2004 00:17:49 -0000	1.1
--- mouse-help.pd	6 Nov 2004 21:15:04 -0000	1.2
***************
*** 1,11 ****
! #N canvas 127 178 668 433 10;
! #X symbolatom 211 183 0 0 0 0 - - -;
! #X obj 178 21 tgl 25 0 empty empty empty 0 -6 0 8 -225271 -1 -1 1 1
  ;
! #X floatatom 287 185 5 0 0 0 - - -;
! #X floatatom 168 184 5 0 0 3 wheel - -;
! #X floatatom 113 184 7 0 0 3 Y - -;
! #X floatatom 59 184 7 0 0 3 X - -;
! #X obj 178 76 mouse 4;
  #X obj 28 294 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1
  ;
--- 1,10 ----
! #N canvas 138 201 676 441 10;
! #X symbolatom 233 198 0 0 0 0 - - -;
! #X obj 200 36 tgl 25 0 empty empty empty 0 -6 0 8 -225271 -1 -1 0 1
  ;
! #X floatatom 309 200 5 0 0 0 - - -;
! #X floatatom 190 199 5 0 0 3 wheel - -;
! #X floatatom 135 199 7 0 0 3 Y - -;
! #X floatatom 81 199 7 0 0 3 X - -;
  #X obj 28 294 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1
  ;
***************
*** 28,44 ****
  #X obj 268 295 route btn_side btn_extra btn_forward btn_back btn_task
  ;
! #X connect 1 0 6 0;
! #X connect 6 0 5 0;
! #X connect 6 1 4 0;
! #X connect 6 2 3 0;
! #X connect 6 3 0 0;
! #X connect 6 4 2 0;
! #X connect 10 0 7 0;
! #X connect 10 1 8 0;
! #X connect 10 2 9 0;
! #X connect 10 3 17 0;
! #X connect 17 0 12 0;
! #X connect 17 1 13 0;
! #X connect 17 2 14 0;
! #X connect 17 3 15 0;
! #X connect 17 4 16 0;
--- 27,50 ----
  #X obj 268 295 route btn_side btn_extra btn_forward btn_back btn_task
  ;
! #X msg 245 23 open 0;
! #X msg 250 42 open 1;
! #X msg 255 61 open 2;
! #X obj 200 91 mouse 1;
! #X connect 1 0 20 0;
! #X connect 9 0 6 0;
! #X connect 9 1 7 0;
! #X connect 9 2 8 0;
! #X connect 9 3 16 0;
! #X connect 16 0 11 0;
! #X connect 16 1 12 0;
! #X connect 16 2 13 0;
! #X connect 16 3 14 0;
! #X connect 16 4 15 0;
! #X connect 17 0 20 0;
! #X connect 18 0 20 0;
! #X connect 19 0 20 0;
! #X connect 20 0 5 0;
! #X connect 20 1 4 0;
! #X connect 20 2 3 0;
! #X connect 20 3 0 0;
! #X connect 20 4 2 0;

Index: hid.c
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/hid.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** hid.c	6 Nov 2004 01:03:00 -0000	1.9
--- hid.c	6 Nov 2004 21:15:04 -0000	1.10
***************
*** 39,48 ****
   */
  
! void hid_start(t_hid *x);
  void hid_stop(t_hid *x);
  t_int hid_open(t_hid *x, t_float f);
  t_int hid_close(t_hid *x);
  t_int hid_read(t_hid *x,int fd);
- void hid_delay(t_hid *x, t_float f);
  static void hid_float(t_hid* x, t_floatarg f);
  
--- 39,47 ----
   */
  
! void hid_start(t_hid *x, t_float f);
  void hid_stop(t_hid *x);
  t_int hid_open(t_hid *x, t_float f);
  t_int hid_close(t_hid *x);
  t_int hid_read(t_hid *x,int fd);
  static void hid_float(t_hid* x, t_floatarg f);
  
***************
*** 72,78 ****
  	hid_stop(x);
  
! 	post("[hid] closed device number %d",x->x_device_number);
  
! 	return (hid_close_device(x));
  }
  
--- 71,81 ----
  	hid_stop(x);
  
! 	if(! hid_close_device(x)) 
! 	{
! 		post("[hid] closed device number %d",x->x_device_number);
! 		return (0);
! 	}
  
! 	return (1);
  }
  
***************
*** 98,102 ****
    {
  	  error("[hid] can not open device %d",x->x_device_number);
! 	  post("\\================================ [hid] ================================/\n");
  	  return (1);
    }
--- 101,105 ----
    {
  	  error("[hid] can not open device %d",x->x_device_number);
! 	  post("\\=========================== [hid] ===========================/\n");
  	  return (1);
    }
***************
*** 107,111 ****
    hid_float(x,started);
  
!   post("\\================================ [hid] ================================/\n");
    return (0);
  }
--- 110,114 ----
    hid_float(x,started);
  
!   post("\\=========================== [hid] ===========================/\n");
    return (0);
  }
***************
*** 121,151 ****
  	}
  	
! 	return 1;  /* why is this 1? */
! }
! 
! /* Actions */
! void hid_delay(t_hid* x, t_float f)  
! {
! 	DEBUG(post("hid_DELAY %f",f);)
! 		
! /*	if the user sets the delay less than zero, reset to default */
! 	if ( f > 0 ) 
! 	{	
! 		x->x_delay = (t_int)f;
! 	} 
! 	else 
! 	{
! 		x->x_delay = DEFAULT_DELAY;
! 	}
  }
  
! void hid_start(t_hid* x) 
  {
  	DEBUG(post("hid_start"););
    
     if (!x->x_started) 
  	{
! 		clock_delay(x->x_clock, DEFAULT_DELAY);
! 		post("hid: polling started");
  		x->x_started = 1;
  	} 
--- 124,143 ----
  	}
  	
! 	// TODO: why is this 1? 
! 	return 1; 
  }
  
! void hid_start(t_hid* x, t_float f) 
  {
  	DEBUG(post("hid_start"););
    
+ /*	if the user sets the delay less than one, ignore */
+ 	if ( f >= 1 ) 	
+ 		x->x_delay = (t_int)f;
+ 	
     if (!x->x_started) 
  	{
! 		clock_delay(x->x_clock, x->x_delay);
! 		post("[hid]: polling started");
  		x->x_started = 1;
  	} 
***************
*** 155,163 ****
  {
  	DEBUG(post("hid_float"););
!    
! 	if(f == 1) 
! 		hid_start(x);
! 	else if(f == 0) 
  		hid_stop(x);
  }
  
--- 147,167 ----
  {
  	DEBUG(post("hid_float"););
! 
! /* values greater than 1 set the polling delay time */
! /* 1 and 0 for start/stop so you can use a [tgl] */
! 	if(f > 1)
! 	{
! 		x->x_delay = (t_int)f;
! 		hid_start(x,f);
! 	}
! 	else if(f == 1) 
! 	{
! 		if (! x->x_started)
! 		hid_start(x,f);
! 	}
! 	else if(f == 0) 		
! 	{
  		hid_stop(x);
+ 	}
  }
  
***************
*** 168,172 ****
  		
  	hid_close(x);
! 
  	clock_free(x->x_clock);
  }
--- 172,178 ----
  		
  	hid_close(x);
! 	
! 	hid_platform_specific_free(x);
! 	
  	clock_free(x->x_clock);
  }
***************
*** 179,183 ****
    DEBUG(post("hid_new"););
  
!   post("/================================ [hid] ================================\\");
    post("[hid] %s, written by Hans-Christoph Steiner <hans at eds.org>",version);  
  #if !defined(__linux__) && !defined(__APPLE__)
--- 185,189 ----
    DEBUG(post("hid_new"););
  
!   post("/=========================== [hid] ===========================\\");
    post("[hid] %s, written by Hans-Christoph Steiner <hans at eds.org>",version);  
  #if !defined(__linux__) && !defined(__APPLE__)
***************
*** 188,192 ****
  
    /* init vars */
-   x->x_read_ok = 1;
    x->x_started = 0;
    x->x_delay = DEFAULT_DELAY;
--- 194,197 ----
***************
*** 203,208 ****
     * anyway, so that the inlets and outlets are created, thus not breaking the
     * patch.   */
! /*   if (hid_open(x,f)) */
! /* 	  error("[hid] device %d did not open",(t_int)f); */
    
    return (x);
--- 208,213 ----
     * anyway, so that the inlets and outlets are created, thus not breaking the
     * patch.   */
!   if (hid_open(x,f))
! 	  error("[hid] device %d did not open",(t_int)f);
    
    return (x);
***************
*** 224,233 ****
  	
  	/* add inlet message methods */
- 	class_addmethod(hid_class,(t_method) hid_delay,gensym("delay"),A_DEFFLOAT,0);
- 	class_addmethod(hid_class,(t_method) hid_open,gensym("open"),A_DEFFLOAT,0);
  	class_addmethod(hid_class,(t_method) hid_devicelist_refresh,gensym("refresh"),0);
  	class_addmethod(hid_class,(t_method) hid_close,gensym("close"),0);
! 	class_addmethod(hid_class,(t_method) hid_start,gensym("start"),0);
! 	class_addmethod(hid_class,(t_method) hid_start,gensym("poll"),0);
  	class_addmethod(hid_class,(t_method) hid_stop,gensym("stop"),0);
  	class_addmethod(hid_class,(t_method) hid_stop,gensym("nopoll"),0);
--- 229,237 ----
  	
  	/* add inlet message methods */
  	class_addmethod(hid_class,(t_method) hid_devicelist_refresh,gensym("refresh"),0);
+ 	class_addmethod(hid_class,(t_method) hid_open,gensym("open"),A_DEFFLOAT,0);
  	class_addmethod(hid_class,(t_method) hid_close,gensym("close"),0);
! 	class_addmethod(hid_class,(t_method) hid_start,gensym("start"),A_DEFFLOAT,0);
! 	class_addmethod(hid_class,(t_method) hid_start,gensym("poll"),A_DEFFLOAT,0);
  	class_addmethod(hid_class,(t_method) hid_stop,gensym("stop"),0);
  	class_addmethod(hid_class,(t_method) hid_stop,gensym("nopoll"),0);

--- NEW FILE: joystick-help.pd ---
#N canvas 182 322 672 437 10;
#X symbolatom 339 141 0 0 0 0 - - -;
#X obj 178 21 tgl 25 0 empty empty empty 0 -6 0 8 -225271 -1 -1 1 1
;
#X floatatom 420 144 5 0 0 0 - - -;
#X floatatom 93 184 7 0 0 3 Y - -;
#X floatatom 39 184 7 0 0 3 X - -;
#X obj 158 294 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
#X obj 203 294 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
#X obj 248 294 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
#X obj 294 294 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
#X obj 178 74 joystick 3;
#X floatatom 153 184 5 0 0 0 - - -;
#X floatatom 196 184 5 0 0 0 - - -;
#X obj 158 271 route btn_1 btn_2 btn_3 btn_4 btn_5 btn_6 btn_7 btn_8
btn_9;
#X obj 339 294 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
#X obj 384 294 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
#X obj 430 294 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
#X obj 475 294 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
#X obj 338 115 unpack s f;
#X connect 1 0 9 0;
#X connect 9 0 4 0;
#X connect 9 1 3 0;
#X connect 9 2 10 0;
#X connect 9 3 11 0;
#X connect 12 0 5 0;
#X connect 12 1 6 0;
#X connect 12 2 7 0;
#X connect 12 3 8 0;
#X connect 12 4 13 0;
#X connect 12 5 14 0;
#X connect 12 6 15 0;
#X connect 12 7 16 0;
#X connect 17 0 0 0;
#X connect 17 1 2 0;

Index: hid-help.pd
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/hid-help.pd,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** hid-help.pd	6 Nov 2004 01:03:00 -0000	1.6
--- hid-help.pd	6 Nov 2004 21:15:04 -0000	1.7
***************
*** 1,4 ****
! #N canvas 143 45 911 634 10;
! #X msg 390 265 ev_abs abs_x 117 1.13626e+09;
  #X obj 390 244 prepend set;
  #X obj 149 473 route rel_x rel_y;
--- 1,4 ----
! #N canvas 143 45 927 650 10;
! #X msg 390 265 ev_rel rel_x 0 4.08559e+09;
  #X obj 390 244 prepend set;
  #X obj 149 473 route rel_x rel_y;
***************
*** 16,20 ****
  #X floatatom 206 454 7 0 0 0 - - -;
  #X floatatom 264 454 7 0 0 0 - - -;
! #X obj 86 81 tgl 35 0 empty empty empty 0 -6 0 8 -24198 -1 -1 1 1;
  #X floatatom 500 392 12 0 0 1 value - -;
  #X symbolatom 468 409 10 0 0 1 eventcode - -;
--- 16,21 ----
  #X floatatom 206 454 7 0 0 0 - - -;
  #X floatatom 264 454 7 0 0 0 - - -;
! #X obj 86 81 tgl 35 0 empty empty empty 0 -6 0 8 -24198 -1 -1 25 25
! ;
  #X floatatom 500 392 12 0 0 1 value - -;
  #X symbolatom 468 409 10 0 0 1 eventcode - -;
***************
*** 24,33 ****
  #X obj 93 514 route key_f key_leftctrl btn_left;
  #X floatatom 243 537 5 0 0 0 - - -;
! #X obj 71 241 bng 35 250 50 0 empty empty event_received 38 18 1 9
  -225280 -1 -1;
  #X obj 2 2 cnv 15 900 20 empty empty [hid] 2 11 1 18 -233017 -66577
  0;
  #X text 362 287 outlet message format:;
- #X text 386 301 eventtype eventcode value timestamp;
  #X obj 742 104 ev-list;
  #X obj 742 155 ev_syn-list;
--- 25,33 ----
  #X obj 93 514 route key_f key_leftctrl btn_left;
  #X floatatom 243 537 5 0 0 0 - - -;
! #X obj 177 296 bng 35 250 50 0 empty empty event_received 38 18 1 9
  -225280 -1 -1;
  #X obj 2 2 cnv 15 900 20 empty empty [hid] 2 11 1 18 -233017 -66577
  0;
  #X text 362 287 outlet message format:;
  #X obj 742 104 ev-list;
  #X obj 742 155 ev_syn-list;
***************
*** 43,49 ****
  #X text 710 85 Event Types:;
  #X text 710 136 Event Codes:;
! #X obj 208 302 print INPUT_EVENT;
! #X obj 208 281 spigot;
! #X obj 245 263 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
  1;
  #X obj 93 345 route ev_key ev_rel ev_abs ev_syn;
--- 43,49 ----
  #X text 710 85 Event Types:;
  #X text 710 136 Event Codes:;
! #X obj 223 287 print INPUT_EVENT;
! #X obj 223 266 spigot;
! #X obj 269 266 tgl 17 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
  1;
  #X obj 93 345 route ev_key ev_rel ev_abs ev_syn;
***************
*** 51,67 ****
  #X obj 262 397 +;
  #X msg 262 377 1;
! #X msg 336 152 close;
! #X msg 398 180 delay 20;
! #X msg 336 180 delay 2;
! #X msg 465 180 delay 200;
! #X text 383 40 new possibilities:;
! #X msg 391 62 poll;
! #X msg 431 62 poll 20;
! #X msg 499 61 nopoll;
! #X text 380 152 probably not needed;
! #X msg 336 129 refresh;
! #X text 397 127 refresh device list;
  #X obj 248 225 hid 2;
- #X obj 590 143 loadbang;
  #X obj 337 514 unpack s f f;
  #X obj 376 532 tgl 25 0 empty empty any_button 27 13 1 9 -195568 -1
--- 51,59 ----
  #X obj 262 397 +;
  #X msg 262 377 1;
! #X msg 336 136 close;
! #X text 380 136 probably not needed;
! #X msg 336 113 refresh;
! #X text 397 111 refresh device list;
  #X obj 248 225 hid 2;
  #X obj 337 514 unpack s f f;
  #X obj 376 532 tgl 25 0 empty empty any_button 27 13 1 9 -195568 -1
***************
*** 76,120 ****
  #X obj 206 433 route abs_x abs_y abs_z;
  #X floatatom 322 454 7 0 0 0 - - -;
  #X connect 1 0 0 0;
  #X connect 2 0 3 0;
  #X connect 2 1 4 0;
! #X connect 5 0 59 0;
! #X connect 6 0 59 0;
  #X connect 8 0 19 0;
  #X connect 8 1 18 0;
  #X connect 8 2 17 0;
  #X connect 8 3 7 0;
! #X connect 9 0 59 0;
! #X connect 10 0 59 0;
! #X connect 11 0 59 0;
! #X connect 12 0 59 0;
! #X connect 13 0 59 0;
! #X connect 16 0 59 0;
  #X connect 22 0 20 0;
  #X connect 22 1 21 0;
  #X connect 22 2 23 0;
! #X connect 22 3 61 0;
! #X connect 42 0 41 0;
! #X connect 43 0 42 1;
! #X connect 44 0 22 0;
! #X connect 44 1 2 0;
! #X connect 44 2 69 0;
! #X connect 44 3 47 0;
! #X connect 45 0 46 1;
  #X connect 46 0 45 0;
! #X connect 47 0 46 0;
! #X connect 48 0 59 0;
! #X connect 49 0 59 0;
! #X connect 50 0 59 0;
! #X connect 51 0 59 0;
! #X connect 57 0 59 0;
! #X connect 59 0 42 0;
! #X connect 59 0 24 0;
! #X connect 59 0 44 0;
! #X connect 59 0 1 0;
! #X connect 59 0 8 0;
! #X connect 60 0 51 0;
! #X connect 61 1 62 0;
! #X connect 69 0 14 0;
! #X connect 69 1 15 0;
! #X connect 69 2 70 0;
--- 68,118 ----
  #X obj 206 433 route abs_x abs_y abs_z;
  #X floatatom 322 454 7 0 0 0 - - -;
+ #X msg 398 180 poll 20;
+ #X msg 336 180 poll 2;
+ #X text 332 159 start polling and set the poll delay in ms;
+ #X text 386 301 event_type event_code value timestamp;
+ #X msg 465 180 poll 2000;
+ #X text 371 56 !!! This software is very much alpha \, so any aspect
+ of it could change without notice !!!;
  #X connect 1 0 0 0;
  #X connect 2 0 3 0;
  #X connect 2 1 4 0;
! #X connect 5 0 51 0;
! #X connect 6 0 51 0;
  #X connect 8 0 19 0;
  #X connect 8 1 18 0;
  #X connect 8 2 17 0;
  #X connect 8 3 7 0;
! #X connect 9 0 51 0;
! #X connect 10 0 51 0;
! #X connect 11 0 51 0;
! #X connect 12 0 51 0;
! #X connect 13 0 51 0;
! #X connect 16 0 51 0;
  #X connect 22 0 20 0;
  #X connect 22 1 21 0;
  #X connect 22 2 23 0;
! #X connect 22 3 52 0;
! #X connect 41 0 40 0;
! #X connect 41 0 24 0;
! #X connect 42 0 41 1;
! #X connect 43 0 22 0;
! #X connect 43 1 2 0;
! #X connect 43 2 60 0;
! #X connect 43 3 46 0;
! #X connect 44 0 45 1;
! #X connect 45 0 44 0;
  #X connect 46 0 45 0;
! #X connect 47 0 51 0;
! #X connect 49 0 51 0;
! #X connect 51 0 41 0;
! #X connect 51 0 43 0;
! #X connect 51 0 1 0;
! #X connect 51 0 8 0;
! #X connect 52 1 53 0;
! #X connect 60 0 14 0;
! #X connect 60 1 15 0;
! #X connect 60 2 61 0;
! #X connect 62 0 51 0;
! #X connect 63 0 51 0;
! #X connect 66 0 51 0;





More information about the Pd-cvs mailing list