[PD-cvs] externals/hcs/hid Makefile, 1.14, 1.15 TODO, 1.20, 1.21 hid.c, 1.21, 1.22 hid.h, 1.19, 1.20 hid_darwin.c, 1.18, 1.19 hid_linux.c, 1.14, 1.15 hid_windows.c, 1.1, 1.2 mouse.pd, 1.6, 1.7

Hans-Christoph Steiner eighthave at users.sourceforge.net
Sat May 27 02:57:17 CEST 2006


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

Modified Files:
	Makefile TODO hid.c hid.h hid_darwin.c hid_linux.c 
	hid_windows.c mouse.pd 
Log Message:
seemed to fix the mac crasher bug caused by HIDReleaseBuildList wierdness; cleaned up things a bit and made it possible to open devices by type

Index: hid.c
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/hid.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** hid.c	25 Jan 2006 08:40:35 -0000	1.21
--- hid.c	27 May 2006 00:57:15 -0000	1.22
***************
*** 24,27 ****
--- 24,33 ----
  /* --------------------------------------------------------------------------*/
  
+ #include <unistd.h>
+ #include <stdarg.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <ctype.h>
+ 
  #include "hid.h"
  
***************
*** 33,36 ****
--- 39,44 ----
  //#define DEBUG(x) x 
  
+ unsigned short global_debug_level = 0;
+ 
  static t_class *hid_class;
  
***************
*** 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);
  
--- 47,54 ----
   */
  
! static void hid_poll(t_hid *x, t_float f);
! static t_int hid_open(t_hid *x, t_symbol *s, t_int argc, t_atom *argv);
! static t_int hid_close(t_hid *x);
! static t_int hid_read(t_hid *x,int fd);
  static void hid_float(t_hid* x, t_floatarg f);
  
***************
*** 51,54 ****
--- 58,101 ----
   */
  
+ void debug_print(t_int message_debug_level, const char *fmt, ...)
+ {
+ 	if(message_debug_level <= global_debug_level)
+ 	{
+ 		char buf[MAXPDSTRING];
+ 		va_list ap;
+ 		//t_int arg[8];
+ 		va_start(ap, fmt);
+ 		vsnprintf(buf, MAXPDSTRING-1, fmt, ap);
+ 		post(buf);
+ 		va_end(ap);
+ 	}
+ }
+ 
+ void debug_error(t_hid *x, t_int message_debug_level, const char *fmt, ...)
+ {
+ 	if(message_debug_level <= global_debug_level)
+ 	{
+ 		char buf[MAXPDSTRING];
+ 		va_list ap;
+ 		//t_int arg[8];
+ 		va_start(ap, fmt);
+ 		vsnprintf(buf, MAXPDSTRING-1, fmt, ap);
+ 		pd_error(x, buf);
+ 		va_end(ap);
+ 	}
+ }
+ 
+ static unsigned int name_to_usage(char *usage_name)
+ { // output usagepage << 16 + usage
+ 	if(strcmp(usage_name,"pointer") == 0)   return(0x00010001);
+ 	if(strcmp(usage_name,"mouse") == 0)     return(0x00010002);
+ 	if(strcmp(usage_name,"joystick") == 0)  return(0x00010004);
+ 	if(strcmp(usage_name,"gamepad") == 0)   return(0x00010005);
+ 	if(strcmp(usage_name,"keyboard") == 0)  return(0x00010006);
+ 	if(strcmp(usage_name,"keypad") == 0)    return(0x00010007);
+ 	if(strcmp(usage_name,"multiaxiscontroller") == 0) return(0x00010008);
+ 	return(0);
+ }
+ 
  void hid_output_event(t_hid *x, char *type, char *code, t_float value)
  {
***************
*** 62,65 ****
--- 109,125 ----
  }
  
+ /* stop polling the device */
+ void stop_poll(t_hid* x) 
+ {
+   debug_print(LOG_DEBUG,"stop_poll");
+   
+   if (x->x_started) 
+   { 
+ 	  clock_unset(x->x_clock);
+ 	  debug_print(LOG_INFO,"[hid] polling stopped");
+ 	  x->x_started = 0;
+   }
+ }
+ 
  void hid_set_from_float(t_hid *x, t_floatarg f)
  {
***************
*** 69,113 ****
  	{
  		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);
  	}
  }
  
  /*------------------------------------------------------------------------------
!  * IMPLEMENTATION                    
   */
  
- /* stop polling the device */
- void hid_stop(t_hid* x) 
- {
-   DEBUG(post("hid_stop"););
-   
-   if (x->x_started) 
-   { 
- 	  clock_unset(x->x_clock);
- 	  DEBUG(post("[hid] polling stopped"););
- 	  x->x_started = 0;
-   }
- }
  
  /* close the device */
  t_int hid_close(t_hid *x) 
  {
! 	DEBUG(post("hid_close"););
  
  /* just to be safe, stop it first */
! 	hid_stop(x);
  
  	if(! hid_close_device(x)) 
  	{
! 		post("[hid] closed device %d",x->x_device_number);
  		x->x_device_open = 0;
  		return (0);
--- 129,161 ----
  	{
  		x->x_delay = (t_int)f;
! 		hid_poll(x,f);
  	}
  	else if (f == 1) 
  	{
  		if (! x->x_started)
! 		hid_poll(x,f);
  	}
  	else if (f == 0) 		
  	{
! 		stop_poll(x);
  	}
  }
  
  /*------------------------------------------------------------------------------
!  * METHODS FOR [hid]'s MESSAGES                    
   */
  
  
  /* close the device */
  t_int hid_close(t_hid *x) 
  {
! 	debug_print(LOG_DEBUG,"hid_close");
  
  /* just to be safe, stop it first */
! 	stop_poll(x);
  
  	if(! hid_close_device(x)) 
  	{
! 		debug_print(LOG_INFO,"[hid] closed device %d",x->x_device_number);
  		x->x_device_open = 0;
  		return (0);
***************
*** 127,143 ****
   */
  
! t_int hid_open(t_hid *x, t_float f) 
  {
! 	DEBUG(post("hid_open"););
  
  /* store running state to be restored after the device has been opened */
  	t_int started = x->x_started;
  
  /* only close the device if its different than the current and open */	
! 	if ( (f != x->x_device_number) && (x->x_device_open) ) 
  		hid_close(x);
  
! 	if (f > 0)
! 		x->x_device_number = f;
  	else
  		x->x_device_number = 0;
--- 175,225 ----
   */
  
! t_int hid_open(t_hid *x, t_symbol *s, t_int argc, t_atom *argv) 
  {
! 	debug_print(LOG_DEBUG,"hid_open");
! 	unsigned short i;
! 	unsigned short device_number = 0;
! 	unsigned short usage_number;
! 	unsigned int usage;
! 	char usage_string[MAXPDSTRING] = "";
  
+ 	if(argc == 1)
+ 	{
+ 		if(atom_getsymbolarg(0,argc,argv) == &s_) 
+ 		{ // single float arg means device
+ 			debug_print(LOG_DEBUG,"[hid] setting device# to %d",device_number);
+ 			device_number = (unsigned short) atom_getfloatarg(0,argc,argv);
+ 		}
+ 		else
+ 		{ // single symbol arg means usagepage/usage
+ 			debug_print(LOG_DEBUG,"[hid] setting device via usagepage/usage");
+ 			atom_string(argv, usage_string, MAXPDSTRING-1);
+ 			i = strlen(usage_string);
+ 			do {
+ 				--i;
+ 			} while(isdigit(usage_string[i]));
+ 			usage_number = strtol(usage_string + i + 1,NULL,10);
+ 			usage_string[i+1] = '\0';
+ 			debug_print(LOG_DEBUG,"[hid] looking for %s #%d",usage_string,usage_number);
+ 			usage = name_to_usage(usage_string);
+ 			debug_print(LOG_DEBUG,"[hid] usage 0x%08x 0x%04x 0x%04x",usage, usage >> 16, usage & 0xffff);
+ 			device_number = get_device_number_from_usage_list(usage_number, 
+ 															  usage >> 16, usage & 0xffff);
+ 		}
+ 	}
+ 	else if( (argc == 2) && (atom_getsymbolarg(0,argc,argv) != NULL) 
+ 			 && (atom_getsymbolarg(1,argc,argv) != NULL) )
+ 	{ /* two symbols means idVendor and idProduct in hex */
+ 	}
+ 	
  /* store running state to be restored after the device has been opened */
  	t_int started = x->x_started;
  
  /* only close the device if its different than the current and open */	
! 	if( (device_number != x->x_device_number) && (x->x_device_open) ) 
  		hid_close(x);
  
! 	if(device_number > 0)
! 		x->x_device_number = device_number;
  	else
  		x->x_device_number = 0;
***************
*** 146,152 ****
   * therefore ignore the redundant open request.  To reopen the same device,
   * send a [close( msg, then an [open( msg. */
! 	if (! x->x_device_open) 
  	{
! 		if (hid_open_device(x,x->x_device_number))
  		{
  			error("[hid] can not open device %d",x->x_device_number);
--- 228,234 ----
   * therefore ignore the redundant open request.  To reopen the same device,
   * send a [close( msg, then an [open( msg. */
! 	if(! x->x_device_open) 
  	{
! 		if(hid_open_device(x,x->x_device_number))
  		{
  			error("[hid] can not open device %d",x->x_device_number);
***************
*** 165,168 ****
--- 247,252 ----
  		hid_set_from_float(x,x->x_delay);
  
+ 	debug_print(LOG_DEBUG,"[hid] done device# to %d",device_number);
+ 
  	return (0);
  }
***************
*** 171,175 ****
  t_int hid_read(t_hid *x,int fd) 
  {
! //	DEBUG(post("hid_read"););
  
  	hid_get_events(x);
--- 255,259 ----
  t_int hid_read(t_hid *x,int fd) 
  {
! //	debug_print(LOG_DEBUG,"hid_read");
  
  	hid_get_events(x);
***************
*** 184,217 ****
  }
  
! 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_device_open)
! 		hid_open(x,x->x_device_number);
  	
!    if(!x->x_started) 
  	{
  		clock_delay(x->x_clock, x->x_delay);
! 		DEBUG(post("[hid] polling started"););
  		x->x_started = 1;
  	} 
  }
  
  static void hid_float(t_hid* x, t_floatarg f) 
  {
! 	DEBUG(post("hid_float"););
  
  	hid_set_from_float(x,f);
  }
  
! /* setup functions */
  static void hid_free(t_hid* x) 
  {
! 	DEBUG(post("hid_free"););
  		
  	hid_close(x);
--- 268,327 ----
  }
  
! void hid_poll(t_hid* x, t_float f) 
  {
! 	debug_print(LOG_DEBUG,"hid_poll");
    
  /*	if the user sets the delay less than one, ignore */
! 	if( f > 0 ) 	
  		x->x_delay = (t_int)f;
  
  	if(!x->x_device_open)
! 		hid_open(x,gensym("open"),0,NULL);
  	
! 	if(!x->x_started) 
  	{
  		clock_delay(x->x_clock, x->x_delay);
! 		debug_print(LOG_DEBUG,"[hid] polling started");
  		x->x_started = 1;
  	} 
  }
  
+ static void hid_anything(t_hid *x, t_symbol *s, t_int argc, t_atom *argv)
+ {
+ 	int i;
+ 	t_symbol *my_symbol;
+ 	char device_name[MAXPDSTRING];
+ 		
+ 	startpost("ANYTHING! selector: %s data:");
+ 	for(i=0; i<argc; ++i)
+ 	{
+ 		my_symbol = atom_getsymbolarg(i,argc,argv);
+ 		if(my_symbol != NULL)
+ 			post(" %s",my_symbol->s_name);
+ 		else
+ 			post(" %f",atom_getfloatarg(i,argc,argv));
+ 	}
+ }
+ 
+ 
  static void hid_float(t_hid* x, t_floatarg f) 
  {
! 	debug_print(LOG_DEBUG,"hid_float");
  
  	hid_set_from_float(x,f);
  }
  
! static void hid_debug(t_hid *x, t_float f)
! {
! 	global_debug_level = f;
! }
! 
! 
! /*------------------------------------------------------------------------------
!  * system functions 
!  */
  static void hid_free(t_hid* x) 
  {
! 	debug_print(LOG_DEBUG,"hid_free");
  		
  	hid_close(x);
***************
*** 226,236 ****
  {
    t_hid *x = (t_hid *)pd_new(hid_class);
! 
!   DEBUG(post("hid_new"););
! 
  /* only display the version when the first instance is loaded */
    if(!hid_instance_count)
  	  post("[hid] %d.%d, written by Hans-Christoph Steiner <hans at eds.org>",
  			 HID_MAJOR_VERSION, HID_MINOR_VERSION);  
  
  #if !defined(__linux__) && !defined(__APPLE__)
--- 336,349 ----
  {
    t_hid *x = (t_hid *)pd_new(hid_class);
!   
!   debug_print(LOG_DEBUG,"hid_new");
!   
  /* only display the version when the first instance is loaded */
    if(!hid_instance_count)
+   {
  	  post("[hid] %d.%d, written by Hans-Christoph Steiner <hans at eds.org>",
  			 HID_MAJOR_VERSION, HID_MINOR_VERSION);  
+ 	  post("\tcompiled on "__DATE__" at "__TIME__ " ");
+   }
  
  #if !defined(__linux__) && !defined(__APPLE__)
***************
*** 241,244 ****
--- 354,358 ----
  
    /* init vars */
+   global_debug_level = 9; /* high numbers here means see more messages */
    x->x_has_ff = 0;
    x->x_device_open = 0;
***************
*** 251,264 ****
    x->x_data_outlet = outlet_new(&x->x_obj, 0);
    x->x_device_name_outlet = outlet_new(&x->x_obj, 0);
-   
-   /* find and report the list of devices */
-   hid_build_device_list(x);
-   
-   /* 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.   */
-   if (hid_open(x,f))
- 	  error("[hid] device %d did not open",(t_int)f);
  
    hid_instance_count++;
  
--- 365,376 ----
    x->x_data_outlet = outlet_new(&x->x_obj, 0);
    x->x_device_name_outlet = outlet_new(&x->x_obj, 0);
  
+   x->x_device_number = 0;
+ 
+   if(f > 0)
+ 	  x->x_device_number = f;
+   else
+ 	  x->x_device_number = 0;
+   
    hid_instance_count++;
  
***************
*** 268,272 ****
  void hid_setup(void) 
  {
! 	DEBUG(post("hid_setup"););
  	hid_class = class_new(gensym("hid"), 
  								 (t_newmethod)hid_new, 
--- 380,384 ----
  void hid_setup(void) 
  {
! 	debug_print(LOG_DEBUG,"hid_setup");
  	hid_class = class_new(gensym("hid"), 
  								 (t_newmethod)hid_new, 
***************
*** 279,292 ****
  	class_addfloat(hid_class,(t_method) hid_float);
  	class_addbang(hid_class,(t_method) hid_read);
  	
  	/* add inlet message methods */
  	class_addmethod(hid_class,(t_method) hid_build_device_list,gensym("refresh"),0);
  	class_addmethod(hid_class,(t_method) hid_print,gensym("print"),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);
     /* force feedback messages */
  	class_addmethod(hid_class,(t_method) hid_ff_autocenter,
--- 391,403 ----
  	class_addfloat(hid_class,(t_method) hid_float);
  	class_addbang(hid_class,(t_method) hid_read);
+ 	class_addanything(hid_class,(t_method) hid_anything);
  	
  	/* add inlet message methods */
+ 	class_addmethod(hid_class,(t_method) hid_debug,gensym("debug"),A_DEFFLOAT,0);
  	class_addmethod(hid_class,(t_method) hid_build_device_list,gensym("refresh"),0);
  	class_addmethod(hid_class,(t_method) hid_print,gensym("print"),0);
! 	class_addmethod(hid_class,(t_method) hid_open,gensym("open"),A_GIMME,0);
  	class_addmethod(hid_class,(t_method) hid_close,gensym("close"),0);
! 	class_addmethod(hid_class,(t_method) hid_poll,gensym("poll"),A_DEFFLOAT,0);
     /* force feedback messages */
  	class_addmethod(hid_class,(t_method) hid_ff_autocenter,

Index: hid_windows.c
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/hid_windows.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** hid_windows.c	19 Dec 2005 20:40:31 -0000	1.1
--- hid_windows.c	27 May 2006 00:57:15 -0000	1.2
***************
*** 73,77 ****
  t_int hid_print_element_list(t_hid *x)
  {
! 	DEBUG(post("hid_print_element_list"););
  
  
--- 73,77 ----
  t_int hid_print_element_list(t_hid *x)
  {
! 	debug_print(LOG_DEBUG,"hid_print_element_list");
  
  
***************
*** 249,253 ****
  t_int hid_get_events(t_hid *x)
  {
! 	//DEBUG(post("hid_get_events"););
  
  	return (0);	
--- 249,253 ----
  t_int hid_get_events(t_hid *x)
  {
! 	//debug_print(LOG_DEBUG,"hid_get_events");
  
  	return (0);	
***************
*** 257,261 ****
  t_int hid_open_device(t_hid *x, t_int device_number)
  {
! 	DEBUG(post("hid_open_device"););
  	t_int result = 0;
  	
--- 257,261 ----
  t_int hid_open_device(t_hid *x, t_int device_number)
  {
! 	debug_print(LOG_DEBUG,"hid_open_device");
  	t_int result = 0;
  	
***************
*** 267,271 ****
  t_int hid_close_device(t_hid *x)
  {
! 	DEBUG(post("hid_close_device"););
  
  	t_int result = 0;
--- 267,271 ----
  t_int hid_close_device(t_hid *x)
  {
! 	debug_print(LOG_DEBUG,"hid_close_device");
  
  	t_int result = 0;
***************
*** 277,281 ****
  t_int hid_build_device_list(t_hid *x)
  {
! 	DEBUG(post("hid_build_device_list"););
  	
  /*
--- 277,281 ----
  t_int hid_build_device_list(t_hid *x)
  {
! 	debug_print(LOG_DEBUG,"hid_build_device_list");
  	
  /*
***************
*** 322,326 ****
  void hid_platform_specific_free(t_hid *x)
  {
! 	DEBUG(post("hid_platform_specific_free"););
  /* only call this if the last instance is being freed */
  	if (hid_instance_count < 1) 
--- 322,326 ----
  void hid_platform_specific_free(t_hid *x)
  {
! 	debug_print(LOG_DEBUG,"hid_platform_specific_free");
  /* only call this if the last instance is being freed */
  	if (hid_instance_count < 1) 

Index: Makefile
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/Makefile,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** Makefile	26 May 2006 14:31:28 -0000	1.14
--- Makefile	27 May 2006 00:57:15 -0000	1.15
***************
*** 1,4 ****
! TARGET := `pwd|sed 's|.*/\(.*\)$|\1|'`
! EXTERNALS_ROOT := `pwd | sed 's|^\(/.*externals\).*|\1|'`
  
  default: 
--- 1,4 ----
! TARGET := $(shell pwd | sed 's|.*/\(.*\)$$|\1|')
! EXTERNALS_ROOT := $(shell pwd | sed 's|^\(/.*externals\).*|\1|')
  
  default: 
***************
*** 11,157 ****
  	make -C $(EXTERNALS_ROOT) $(TARGET)_clean
  
- #==============================================================================
- #==============================================================================
- #==============================================================================
- #==============================================================================
- #==============================================================================
- # this stuff below probably works, but its not maintained anymore since I use
- # externals/Makefile
- 
- CWD := $(shell pwd)
- 
- # these are setup to be overridden by the packages/Makefile
- cvs_root_dir = $(CWD)/../../..
- DESTDIR = $(CWD)/build/
- BUILDLAYOUT_DIR = $(cvs_root_dir)/packages
- 
- -include $(BUILDLAYOUT_DIR)/Makefile.buildlayout
- 
- 
- 
- CFLAGS = $(OPT_FLAGS) -Wall -I./ -I../../../pd/src
- LDFLAGS = 
- LIBS = -lm
- 
- ifeq (x$(OS_NAME),x)
- default:
- 	@echo no OS_NAME specified
- endif
- 
- 
- #SRC = $(wildcard $(externals_src)/hcs/hid/hid*.c)
- SRC = $(wildcard *.c)
- SRC = input_arrays.c hid_$(OS_NAME).c
- OBJ := $(SRC:.c=.o)
- 
- # ----------------------- GNU/LINUX i386 -----------------------
- ifeq ($(OS_NAME),linux)
-   EXTENSION = pd_linux
-   LDFLAGS += -export_dynamic -shared
-   LIBS += -lc
-   STRIP = strip --strip-unneeded
-   hid.$(EXTENSION): input_arrays $(OBJ)
- endif
- 
- # ----------------------- Windows MinGW -----------------------
- ifeq ($(OS_NAME),windows)
-   EXTENSION = dll
-   CFLAGS += -mms-bitfields
-   LDFLAGS += -shared 
-   LIBS += -lhid -lsetupapi -L../../../pd/bin -lpd
-   STRIP = strip --strip-unneeded
-   hid.$(EXTENSION): input_arrays $(OBJ)
- endif
- 
- # ----------------------- DARWIN -----------------------
- ifeq ($(OS_NAME),darwin)
-   EXTENSION = pd_darwin
-   CFLAGS +=  -I./HID\ Utilities\ Source
-   PDEXECUTABLE = ../../../pd/bin/pd
-   FRAMEWORKS = Carbon IOKit ForceFeedback
-   LDFLAGS += -bundle  -bundle_loader $(PDEXECUTABLE)
-   LIBS += -lc -L/sw/lib -L./HID\ Utilities\ Source/build \
-        -lHIDUtilities $(patsubst %,-framework %,$(FRAMEWORKS))
-   STRIP = strip -x
-   hid.$(EXTENSION): input_arrays hid_utilites $(OBJ)
- .SUFFIXES: .pd_darwin
- endif
- 
- all: hid.$(EXTENSION)
- 
- .SUFFIXES: .$(EXTENSION)
- 
- # ----------------------- GENERAL ---------------------------------------------
- # generic optimization
- OPT_FLAGS = -O3 -ffast-math
- # G4 optimization on Mac OS X
- #OPT_FLAGS = -O3 -mcpu=7400 -maltivec -ffast-math -fPIC
- # faster G4 7450 optimization  (gives errors) on GNU/Linux
- #OPT_FLAGS = -O3 -mcpu=7450 -maltivec -ffast-math -fPIC
- # G4 optimization on Mac OS X
- #OPT_FLAGS = -O3 -mcpu=7400 -faltivec -ffast-math -fPIC
- # faster G4 7450 optimization  (gives errors) on Mac OS X
- #OPT_FLAGS = -ffast -mcpu=7450 -faltivec -ffast-math -fPIC
- 
- %.o: %.c
- 	$(CC) $(CFLAGS) -o "$*.o" -c "$*.c"
- 
- %.$(EXTENSION): %.o
- 	$(CC) $(LDFLAGS) -o "$*.$(EXTENSION)" "$*.o" $(OBJ) $(LIBS) \
- 		`test -f $*.libs && cat $*.libs`	\
- 		`test -f $(dir $*)../$(OS_NAME)/$(notdir $*).libs && \
- 			cat $(dir $*)../$(OS_NAME)/$(notdir $*).libs`
- 	chmod a-x "$*.$(EXTENSION)"
- 	$(STRIP) $*.$(EXTENSION)
- 	rm -f -- $*.o
- 
- 
- input_arrays: input_arrays.c input_arrays.h
- 
- input_arrays.c: linux/input.h
- 	./make-arrays-from-input.h.pl
- 
- input_arrays.h: linux/input.h
- 	./make-arrays-from-input.h.pl
- 
- 
- hid_utilities:
- 	test -f ./HID\ Utilities\ Source/build/libHIDUtilities.a || \
- 		( cd  ./HID\ Utilities\ Source && pbxbuild )
- 
- 
- local_clean: 
- 	-rm -f -- *.$(EXTENSION) *~ 
- 	-find . -name '*.o' | xargs rm -f -- 
- 
- distclean: local_clean
- 	 -rm -f -- input_arrays.? doc/ev*-list.pd
- 
- .PHONY: all input_arrays hid_utilities clean distclean
- 
- 
  test_locations:
! 	@echo "EXTENSION: $(EXTENSION)"
! 	@echo "CFLAGS: $(CFLAGS)"
! 	@echo "LDFLAGS: $(LDFLAGS)"
! 	@echo "LIBS: $(LIBS)"
! 	@echo "STRIP: $(STRIP)"
! 	@echo " "
! 	@echo "SRC: $(SRC)"
! 	@echo "OBJ: $(OBJ)"
! 	@echo " "
! 	@echo "OS_NAME: $(OS_NAME)"
! 	@echo "PD_VERSION: $(PD_VERSION)"
! 	@echo "PACKAGE_VERSION: $(PACKAGE_VERSION)"
! 	@echo "CWD: $(CWD)"
! 	@echo "DESTDIR: $(DESTDIR)"
! 	@echo "PREFIX: $(prefix)"
! 	@echo "BINDIR:  $(bindir)"
! 	@echo "LIBDIR:  $(libdir)"
! 	@echo "OBJECTSDIR:  $(objectsdir)"
! 	@echo "PDDOCDIR:  $(pddocdir)"
! 	@echo "LIBPDDIR:  $(libpddir)"
! 	@echo "LIBPDBINDIR:  $(libpdbindir)"
! 	@echo "HELPDIR:  $(helpdir)"
! 	@echo "MANUALSDIR:  $(manualsdir)"
! 	@echo "EXAMPLESDIR:  $(examplesdir)"
--- 11,15 ----
  	make -C $(EXTERNALS_ROOT) $(TARGET)_clean
  
  test_locations:
! 	make -C $(EXTERNALS_ROOT) test_locations
! 

Index: hid.h
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/hid.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** hid.h	25 Jan 2006 08:40:35 -0000	1.19
--- hid.h	27 May 2006 00:57:15 -0000	1.20
***************
*** 3,6 ****
--- 3,7 ----
  
  #include <stdio.h>
+ #include <sys/syslog.h>
  
  #include <m_pd.h>
***************
*** 13,17 ****
  
  #define HID_MAJOR_VERSION 0
! #define HID_MINOR_VERSION 6
  
  /* static char *version = "$Revision$"; */
--- 14,18 ----
  
  #define HID_MAJOR_VERSION 0
! #define HID_MINOR_VERSION 7
  
  /* static char *version = "$Revision$"; */
***************
*** 22,36 ****
  typedef struct _hid 
  {
! 		t_object            x_obj;
! 		t_int               x_fd;
! 		t_int               x_device_number;
! 		t_int               x_has_ff;
! 		void                *x_ff_device;
! 		t_clock             *x_clock;
! 		t_int               x_delay;
! 		t_int               x_started;
! 		t_int               x_device_open;
! 		t_outlet            *x_data_outlet;
! 		t_outlet            *x_device_name_outlet;
  } t_hid;
  
--- 23,40 ----
  typedef struct _hid 
  {
! 	t_object            x_obj;
! 	t_int               x_fd;
! //	unsigned short      x_device_number;
! 	t_float      x_device_number;
! 	unsigned short      vendor_id;    // USB idVendor for current device
! 	unsigned short      product_id;   // USB idProduct for current device
! 	t_int               x_has_ff;
! 	void                *x_ff_device;
! 	t_clock             *x_clock;
! 	t_int               x_delay;
! 	t_int               x_started;
! 	t_int               x_device_open;
! 	t_outlet            *x_data_outlet;
! 	t_outlet            *x_device_name_outlet;
  } t_hid;
  
***************
*** 53,56 ****
--- 57,61 ----
  t_int hid_instance_count;
  
+ extern unsigned short global_debug_level;
  
  /*------------------------------------------------------------------------------
***************
*** 59,86 ****
  
  /* support functions */
! void hid_output_event( t_hid *x, char *type, char *code, t_float value );
  
  /* generic, cross-platform functions implemented in a separate file for each
   * platform 
   */
! t_int hid_open_device( t_hid *x, t_int device_number );
! t_int hid_close_device( t_hid *x );
! t_int hid_build_device_list( t_hid* x );
! t_int hid_get_events( t_hid *x ) ;
! void hid_print( t_hid* x );
! void hid_platform_specific_free( t_hid *x );
  
  /* cross-platform force feedback functions */
! t_int hid_ff_autocenter( t_hid *x, t_float value );
! t_int hid_ff_gain( t_hid *x, t_float value );
! t_int hid_ff_motors( t_hid *x, t_float value );
! t_int hid_ff_continue( t_hid *x );
! t_int hid_ff_pause( t_hid *x );
! t_int hid_ff_reset( t_hid *x );
! t_int hid_ff_stopall( t_hid *x );
  
  // these are just for testing...
! t_int hid_ff_fftest ( t_hid *x, t_float value);
! void hid_ff_print( t_hid *x );
  
  
--- 64,97 ----
  
  /* support functions */
! void debug_print(t_int debug_level, const char *fmt, ...);
! void debug_error(t_hid *x, t_int debug_level, const char *fmt, ...);
! void hid_output_event(t_hid *x, char *type, char *code, t_float value);
  
  /* generic, cross-platform functions implemented in a separate file for each
   * platform 
   */
! t_int hid_open_device(t_hid *x, t_int device_number);
! t_int hid_close_device(t_hid *x);
! void hid_build_device_list(void);
! t_int hid_get_events(t_hid *x);
! void hid_print(t_hid* x);
! void hid_platform_specific_free(t_hid *x);
! t_int get_device_number_by_ids(unsigned short vendor_id, unsigned short product_id);
! t_int get_device_number_from_usage_list(t_int device_number, 
! 										unsigned short usage_page, unsigned short usage);
! 
  
  /* cross-platform force feedback functions */
! t_int hid_ff_autocenter(t_hid *x, t_float value);
! t_int hid_ff_gain(t_hid *x, t_float value);
! t_int hid_ff_motors(t_hid *x, t_float value);
! t_int hid_ff_continue(t_hid *x);
! t_int hid_ff_pause(t_hid *x);
! t_int hid_ff_reset(t_hid *x);
! t_int hid_ff_stopall(t_hid *x);
  
  // these are just for testing...
! t_int hid_ff_fftest (t_hid *x, t_float value);
! void hid_ff_print(t_hid *x);
  
  

Index: mouse.pd
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/mouse.pd,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** mouse.pd	10 Jun 2005 20:16:45 -0000	1.6
--- mouse.pd	27 May 2006 00:57:15 -0000	1.7
***************
*** 1,3 ****
! #N canvas 212 125 775 600 10;
  #X obj 130 18 inlet;
  #X obj 25 521 outlet;
--- 1,3 ----
! #N canvas 212 125 783 608 10;
  #X obj 130 18 inlet;
  #X obj 25 521 outlet;
***************
*** 38,42 ****
  #X text 41 489 zero when no motion;
  #X obj 43 48 loadbang;
- #X msg 43 71 25;
  #X obj 213 401 delay;
  #X obj 207 444 metro;
--- 38,41 ----
***************
*** 51,54 ****
--- 50,54 ----
  #X obj 108 378 * 2;
  #X obj 258 378 * 2;
+ #X msg 43 71 5;
  #X connect 0 0 28 0;
  #X connect 6 0 5 0;
***************
*** 58,62 ****
  #X connect 14 0 13 0;
  #X connect 15 0 1 0;
! #X connect 15 0 43 0;
  #X connect 16 0 2 0;
  #X connect 16 0 33 0;
--- 58,62 ----
  #X connect 14 0 13 0;
  #X connect 15 0 1 0;
! #X connect 15 0 42 0;
  #X connect 16 0 2 0;
  #X connect 16 0 33 0;
***************
*** 71,94 ****
  #X connect 28 1 20 0;
  #X connect 29 0 20 0;
! #X connect 31 0 49 0;
  #X connect 32 0 29 0;
! #X connect 33 0 38 0;
! #X connect 33 0 41 0;
  #X connect 34 0 1 0;
! #X connect 36 0 37 0;
! #X connect 37 0 30 0;
! #X connect 38 0 40 0;
! #X connect 39 0 27 0;
! #X connect 40 0 39 0;
! #X connect 41 0 39 0;
! #X connect 42 0 48 0;
! #X connect 43 0 44 0;
! #X connect 43 0 47 0;
! #X connect 44 0 46 0;
! #X connect 45 0 34 0;
! #X connect 46 0 45 0;
! #X connect 47 0 45 0;
! #X connect 48 0 44 1;
! #X connect 48 0 45 1;
! #X connect 49 0 38 1;
! #X connect 49 0 39 1;
--- 71,94 ----
  #X connect 28 1 20 0;
  #X connect 29 0 20 0;
! #X connect 31 0 48 0;
  #X connect 32 0 29 0;
! #X connect 33 0 37 0;
! #X connect 33 0 40 0;
  #X connect 34 0 1 0;
! #X connect 36 0 49 0;
! #X connect 37 0 39 0;
! #X connect 38 0 27 0;
! #X connect 39 0 38 0;
! #X connect 40 0 38 0;
! #X connect 41 0 47 0;
! #X connect 42 0 43 0;
! #X connect 42 0 46 0;
! #X connect 43 0 45 0;
! #X connect 44 0 34 0;
! #X connect 45 0 44 0;
! #X connect 46 0 44 0;
! #X connect 47 0 43 1;
! #X connect 47 0 44 1;
! #X connect 48 0 37 1;
! #X connect 48 0 38 1;
! #X connect 49 0 30 0;

Index: hid_darwin.c
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/hid_darwin.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** hid_darwin.c	10 Jun 2005 20:17:42 -0000	1.18
--- hid_darwin.c	27 May 2006 00:57:15 -0000	1.19
***************
*** 64,68 ****
  
  /*==============================================================================
!  * FUNCTION PROTOTYPES
   *==============================================================================
   */
--- 64,68 ----
  
  /*==============================================================================
! h * FUNCTION PROTOTYPES
   *==============================================================================
   */
***************
*** 97,101 ****
  void convertDarwinElementToLinuxTypeCode(pRecElement element, char *linux_type, char *linux_code) 
  {
! 	t_int button_offset = 0;
  
  	switch(element->type)
--- 97,101 ----
  void convertDarwinElementToLinuxTypeCode(pRecElement element, char *linux_type, char *linux_code) 
  {
! //	t_int button_offset = 0;
  
  	switch(element->type)
***************
*** 203,206 ****
--- 203,261 ----
  }
  
+ t_int get_device_number_by_ids(unsigned short vendor_id, unsigned short product_id)
+ {
+ 	return(1);
+ }
+ 
+ t_int get_device_number_from_usage_list(t_int device_number, 
+ 										unsigned short usage_page, unsigned short usage)
+ {
+ 	debug_print(LOG_DEBUG,"get_device_number_from_usage_list");
+ 
+ 	pRecDevice    pCurrentHIDDevice;
+ 	t_int i;
+ 	t_int device_count;
+ 	t_int total_devices = 0;
+ 	char cstrDeviceName[MAXPDSTRING];
+ 
+ 	if( !HIDHaveDeviceList() ) hid_build_device_list();
+ 
+ 	pCurrentHIDDevice = HIDGetFirstDevice();
+ 	while(pCurrentHIDDevice != NULL)
+ 	{
+ 		if( (pCurrentHIDDevice->usagePage == usage_page) && 
+ 			(pCurrentHIDDevice->usage == usage) )
+ 		{
+ 			++total_devices;
+ 		}
+ 		pCurrentHIDDevice = HIDGetNextDevice(pCurrentHIDDevice);
+ 	}
+ 	i = total_devices;
+ 	device_count = HIDCountDevices();
+ 	debug_print(LOG_DEBUG,"[hid]  %d is less than %d",i,device_number);
+ 	pCurrentHIDDevice = HIDGetFirstDevice();
+ 	while( (pCurrentHIDDevice != NULL) && (i > device_number) ) 
+ 	{
+ 		debug_print(LOG_DEBUG,"[hid] %d:  %d == %d     %d == %d",i,
+ 					pCurrentHIDDevice->usagePage, 
+ 					usage_page,
+ 					pCurrentHIDDevice->usage,
+ 					usage);
+ 		device_count--;
+ 		if( (pCurrentHIDDevice->usagePage == usage_page) && 
+ 			(pCurrentHIDDevice->usage == usage) )
+ 		{
+ 			i--;
+ 			HIDGetUsageName(pCurrentHIDDevice->usagePage, 
+ 							pCurrentHIDDevice->usage, 
+ 							cstrDeviceName);
+ 			debug_print(LOG_DEBUG,"[hid]: found a %s at %d: %s %s",cstrDeviceName,i,
+ 						pCurrentHIDDevice->manufacturer,pCurrentHIDDevice->product);
+ 		}
+ 		pCurrentHIDDevice = HIDGetNextDevice(pCurrentHIDDevice);
+ 	} 
+ 	return(device_count);
+ }
+ 
  
  void hid_build_element_list(t_hid *x) 
***************
*** 211,215 ****
  t_int hid_print_element_list(t_hid *x)
  {
! 	DEBUG(post("hid_print_element_list"););
  
  	UInt32 i;
--- 266,270 ----
  t_int hid_print_element_list(t_hid *x)
  {
! 	debug_print(LOG_DEBUG,"hid_print_element_list");
  
  	UInt32 i;
***************
*** 265,269 ****
  void hid_ff_print( t_hid *x )
  {
! 	DEBUG(post("hid_ff_print"););
  	HRESULT result;
  	UInt32 value;
--- 320,324 ----
  void hid_ff_print( t_hid *x )
  {
! 	debug_print(LOG_DEBUG,"hid_ff_print");
  	HRESULT result;
  	UInt32 value;
***************
*** 292,296 ****
  	char cstrDeviceName [256];
  	t_int i,numdevs;
! 	UInt32 usagePage, usage;
  	pRecDevice pCurrentHIDDevice = NULL;
  
--- 347,351 ----
  	char cstrDeviceName [256];
  	t_int i,numdevs;
! //	UInt32 usagePage, usage;
  	pRecDevice pCurrentHIDDevice = NULL;
  
***************
*** 304,317 ****
  		{
  			pCurrentHIDDevice = hid_get_device_by_number(i);
! 			post("Device %d: '%s' '%s' version %d",i,pCurrentHIDDevice->manufacturer,
! 				  pCurrentHIDDevice->product,pCurrentHIDDevice->version);
  			//usage
! 			HIDGetUsageName (pCurrentHIDDevice->usagePage, 
  								  pCurrentHIDDevice->usage, 
  								  cstrDeviceName);
! 			DEBUG(post("       vendorID: %d   productID: %d   locID: %d",
  						  pCurrentHIDDevice->vendorID,
  						  pCurrentHIDDevice->productID,
! 						  pCurrentHIDDevice->locID););
  		}
  		post("");
--- 359,379 ----
  		{
  			pCurrentHIDDevice = hid_get_device_by_number(i);
! 			debug_print(LOG_INFO,"Device %d: '%s' '%s' version %d",
! 						i,
! 						pCurrentHIDDevice->manufacturer,
! 						pCurrentHIDDevice->product,
! 						pCurrentHIDDevice->version);
  			//usage
! 			HIDGetUsageName(pCurrentHIDDevice->usagePage, 
  								  pCurrentHIDDevice->usage, 
  								  cstrDeviceName);
! 			debug_print(LOG_INFO,"\t\tcstrDeviceName: %s",cstrDeviceName);
! 			debug_print(LOG_INFO,"\t\tusage page: 0x%04x\tusage: 0x%04x",
! 						pCurrentHIDDevice->usagePage,
! 						pCurrentHIDDevice->usage);
! 			debug_print(LOG_INFO,"\t\tvendorID: 0x%04x\tproductID: 0x%04x\tlocID: 0x%08x",
  						  pCurrentHIDDevice->vendorID,
  						  pCurrentHIDDevice->productID,
! 						  pCurrentHIDDevice->locID);
  		}
  		post("");
***************
*** 322,326 ****
  {
  	char      *device_name;
! 	t_symbol  *device_name_symbol;
  
  	device_name = malloc( strlen(manufacturer) + 1 + strlen(product) + 1 );
--- 384,388 ----
  {
  	char      *device_name;
! //	t_symbol  *device_name_symbol;
  
  	device_name = malloc( strlen(manufacturer) + 1 + strlen(product) + 1 );
***************
*** 345,349 ****
  t_int hid_ff_autocenter(t_hid *x, t_float value)
  {
! 	DEBUG(post("hid_ff_autocenter"););
  	HRESULT result;
  	UInt32 autocenter_value;
--- 407,411 ----
  t_int hid_ff_autocenter(t_hid *x, t_float value)
  {
! 	debug_print(LOG_DEBUG,"hid_ff_autocenter");
  	HRESULT result;
  	UInt32 autocenter_value;
***************
*** 369,373 ****
  t_int hid_ff_gain(t_hid *x, t_float value)
  {
! 	DEBUG(post("hid_ff_gain"););
  	HRESULT result;
  	UInt32 ffgain_value;
--- 431,435 ----
  t_int hid_ff_gain(t_hid *x, t_float value)
  {
! 	debug_print(LOG_DEBUG,"hid_ff_gain");
  	HRESULT result;
  	UInt32 ffgain_value;
***************
*** 409,413 ****
  t_int hid_ff_continue( t_hid *x )
  {
! 	DEBUG(post("hid_ff_continue"););
  	return(  hid_ff_send_ff_command( x, FFSFFC_CONTINUE ) );
  }
--- 471,475 ----
  t_int hid_ff_continue( t_hid *x )
  {
! 	debug_print(LOG_DEBUG,"hid_ff_continue");
  	return(  hid_ff_send_ff_command( x, FFSFFC_CONTINUE ) );
  }
***************
*** 415,419 ****
  t_int hid_ff_pause( t_hid *x )
  {
! 	DEBUG(post("hid_ff_pause"););
  	return(  hid_ff_send_ff_command( x, FFSFFC_PAUSE ) );
  }
--- 477,481 ----
  t_int hid_ff_pause( t_hid *x )
  {
! 	debug_print(LOG_DEBUG,"hid_ff_pause");
  	return(  hid_ff_send_ff_command( x, FFSFFC_PAUSE ) );
  }
***************
*** 421,425 ****
  t_int hid_ff_reset( t_hid *x )
  {
! 	DEBUG(post("hid_ff_reset"););
  	return(  hid_ff_send_ff_command( x, FFSFFC_RESET ) );
  }
--- 483,487 ----
  t_int hid_ff_reset( t_hid *x )
  {
! 	debug_print(LOG_DEBUG,"hid_ff_reset");
  	return(  hid_ff_send_ff_command( x, FFSFFC_RESET ) );
  }
***************
*** 427,431 ****
  t_int hid_ff_setactuatorsoff( t_hid *x )
  {
! 	DEBUG(post("hid_ff_setactuatorsoff"););
  	return(  hid_ff_send_ff_command( x, FFSFFC_SETACTUATORSOFF ) );
  }
--- 489,493 ----
  t_int hid_ff_setactuatorsoff( t_hid *x )
  {
! 	debug_print(LOG_DEBUG,"hid_ff_setactuatorsoff");
  	return(  hid_ff_send_ff_command( x, FFSFFC_SETACTUATORSOFF ) );
  }
***************
*** 433,437 ****
  t_int hid_ff_setactuatorson( t_hid *x )
  {
! 	DEBUG(post("hid_ff_setactuatorson"););
  	return(  hid_ff_send_ff_command( x, FFSFFC_SETACTUATORSON ) );
  }
--- 495,499 ----
  t_int hid_ff_setactuatorson( t_hid *x )
  {
! 	debug_print(LOG_DEBUG,"hid_ff_setactuatorson");
  	return(  hid_ff_send_ff_command( x, FFSFFC_SETACTUATORSON ) );
  }
***************
*** 439,443 ****
  t_int hid_ff_stopall( t_hid *x )
  {
! 	DEBUG(post("hid_ff_stopall"););
  	return(  hid_ff_send_ff_command( x, FFSFFC_STOPALL ) );
  }
--- 501,505 ----
  t_int hid_ff_stopall( t_hid *x )
  {
! 	debug_print(LOG_DEBUG,"hid_ff_stopall");
  	return(  hid_ff_send_ff_command( x, FFSFFC_STOPALL ) );
  }
***************
*** 462,466 ****
  t_int hid_ff_fftest ( t_hid *x, t_float value)
  {
! 	DEBUG(post("hid_get_events"););
  	
  	return( 0 );
--- 524,528 ----
  t_int hid_ff_fftest ( t_hid *x, t_float value)
  {
! 	debug_print(LOG_DEBUG,"hid_get_events");
  	
  	return( 0 );
***************
*** 473,477 ****
  t_int hid_get_events(t_hid *x)
  {
! 	//DEBUG(post("hid_get_events"););
  
  	SInt32 value;
--- 535,539 ----
  t_int hid_get_events(t_hid *x)
  {
! 	//debug_print(LOG_DEBUG,"hid_get_events");
  
  	SInt32 value;
***************
*** 482,489 ****
  	char code[256];
  	char event_output_string[256];
! 	t_atom event_data[4];
  
  	int event_counter = 0;
! 	Boolean result;
  
  	pCurrentHIDDevice = hid_get_device_by_number(x->x_device_number);
--- 544,551 ----
  	char code[256];
  	char event_output_string[256];
! //	t_atom event_data[4];
  
  	int event_counter = 0;
! //	Boolean result;
  
  	pCurrentHIDDevice = hid_get_device_by_number(x->x_device_number);
***************
*** 624,649 ****
  t_int hid_open_device(t_hid *x, t_int device_number)
  {
! 	DEBUG(post("hid_open_device"););
  
  	t_int result = 0;
  	pRecDevice pCurrentHIDDevice = NULL;
  
! 	io_service_t hidDevice = NULL;
  	FFDeviceObjectReference ffDeviceReference = NULL;
  
  /* rebuild device list to make sure the list is current */
! 	if ( ! HIDHaveDeviceList() )
! 	{
! 		result = (t_int) HIDBuildDeviceList (NULL, NULL); 
! 		// returns false if no device found
! 		if(result) 
! 		{
! 			error("[hid]: no HID devices found\n");
! 			return(result);
! 		}
! 	}
  	
  	pCurrentHIDDevice = hid_get_device_by_number(device_number);
! 	if ( ! HIDIsValidDevice(pCurrentHIDDevice) )
  	{
  		error("[hid]: device %d is not a valid device\n",device_number);
--- 686,702 ----
  t_int hid_open_device(t_hid *x, t_int device_number)
  {
! 	debug_print(LOG_DEBUG,"hid_open_device");
  
  	t_int result = 0;
  	pRecDevice pCurrentHIDDevice = NULL;
  
! 	io_service_t hidDevice = 0;
  	FFDeviceObjectReference ffDeviceReference = NULL;
  
  /* rebuild device list to make sure the list is current */
! 	if( !HIDHaveDeviceList() ) hid_build_device_list();
  	
  	pCurrentHIDDevice = hid_get_device_by_number(device_number);
! 	if( ! HIDIsValidDevice(pCurrentHIDDevice) )
  	{
  		error("[hid]: device %d is not a valid device\n",device_number);
***************
*** 659,666 ****
  
  	hidDevice = AllocateHIDObjectFromRecDevice( pCurrentHIDDevice );
! 	if ( FFIsForceFeedback(hidDevice) == FF_OK ) 
  	{
  		post("\tdevice has Force Feedback support");
! 		if ( FFCreateDevice(hidDevice,&ffDeviceReference) == FF_OK ) 
  		{
  			x->x_has_ff = 1;
--- 712,719 ----
  
  	hidDevice = AllocateHIDObjectFromRecDevice( pCurrentHIDDevice );
! 	if( FFIsForceFeedback(hidDevice) == FF_OK ) 
  	{
  		post("\tdevice has Force Feedback support");
! 		if( FFCreateDevice(hidDevice,&ffDeviceReference) == FF_OK ) 
  		{
  			x->x_has_ff = 1;
***************
*** 685,689 ****
  t_int hid_close_device(t_hid *x)
  {
! 	DEBUG(post("hid_close_device"););
  
  	t_int result = 0;
--- 738,742 ----
  t_int hid_close_device(t_hid *x)
  {
! 	debug_print(LOG_DEBUG,"hid_close_device");
  
  	t_int result = 0;
***************
*** 691,695 ****
  
  	HIDDequeueDevice(pCurrentHIDDevice);
! // this doesn't seem to be needed at all
  //   result = HIDCloseReleaseInterface(pCurrentHIDDevice);
  	
--- 744,748 ----
  
  	HIDDequeueDevice(pCurrentHIDDevice);
! // this doesn't seem to be needed at all, but why not use it?
  //   result = HIDCloseReleaseInterface(pCurrentHIDDevice);
  	
***************
*** 698,724 ****
  
  
! t_int hid_build_device_list(t_hid *x)
  {
! 	DEBUG(post("hid_build_device_list"););
! 
! 	pRecDevice    pCurrentHIDDevice;
! 	t_atom        device_name_atoms[2];
! 	
! // returns false if no device found
! 	if(HIDBuildDeviceList (NULL, NULL)) 
! 		error("[hid]: no HID devices found\n");
! 
! 	/* send the [options( msg to set the [hid_menu] to blank */
! 	outlet_anything( x->x_device_name_outlet, gensym( "options" ),0,NULL );
  
! 	pCurrentHIDDevice = HIDGetFirstDevice();
! 	while ( pCurrentHIDDevice != NULL )
! 	{
! 		hid_output_device_name( x, pCurrentHIDDevice->manufacturer, 
! 										pCurrentHIDDevice->product );
! 		pCurrentHIDDevice = HIDGetNextDevice(pCurrentHIDDevice);
! 	} 
! 	
! 	return (0);
  }
  
--- 751,762 ----
  
  
! void hid_build_device_list(void)
  {
! 	debug_print(LOG_DEBUG,"hid_build_device_list");
  
! 	debug_print(LOG_WARNING,"[hid] Building device list...");
! 	if(HIDBuildDeviceList (0, 0)) 
! 		post("[hid]: no HID devices found\n");
! 	debug_print(LOG_WARNING,"[hid] completed device list.");
  }
  
***************
*** 738,742 ****
  void hid_platform_specific_free(t_hid *x)
  {
! 	DEBUG(post("hid_platform_specific_free"););
  /* only call this if the last instance is being freed */
  	if (hid_instance_count < 1) 
--- 776,780 ----
  void hid_platform_specific_free(t_hid *x)
  {
! 	debug_print(LOG_DEBUG,"hid_platform_specific_free");
  /* only call this if the last instance is being freed */
  	if (hid_instance_count < 1) 

Index: hid_linux.c
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/hid_linux.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** hid_linux.c	6 Apr 2006 16:50:42 -0000	1.14
--- hid_linux.c	27 May 2006 00:57:15 -0000	1.15
***************
*** 133,137 ****
  void hid_print_element_list(t_hid *x)
  {
!     DEBUG(post("hid_print_element_list"););
      unsigned long bitmask[EV_MAX][NBITS(KEY_MAX)];
  //    char event_type_string[256];
--- 133,137 ----
  void hid_print_element_list(t_hid *x)
  {
!     debug_print(LOG_DEBUG,"hid_print_element_list");
      unsigned long bitmask[EV_MAX][NBITS(KEY_MAX)];
  //    char event_type_string[256];
***************
*** 253,257 ****
  void hid_print_device_list(void)
  {
!     DEBUG(post("hid_print_device_list"););
      int i,fd;
      char device_output_string[256] = "Unknown";
--- 253,257 ----
  void hid_print_device_list(void)
  {
!     debug_print(LOG_DEBUG,"hid_print_device_list");
      int i,fd;
      char device_output_string[256] = "Unknown";
***************
*** 351,355 ****
  t_int hid_get_events(t_hid *x)
  {
!     DEBUG(post("hid_get_events"););
  
  /* for debugging, counts how many events are processed each time hid_read() is called */
--- 351,355 ----
  t_int hid_get_events(t_hid *x)
  {
!     debug_print(LOG_DEBUG,"hid_get_events");
  
  /* for debugging, counts how many events are processed each time hid_read() is called */
***************
*** 412,416 ****
  t_int hid_open_device(t_hid *x, t_int device_number)
  {
!     DEBUG(post("hid_open_device"););
  
      char device_name[256] = "Unknown";
--- 412,416 ----
  t_int hid_open_device(t_hid *x, t_int device_number)
  {
!     debug_print(LOG_DEBUG,"hid_open_device");
  
      char device_name[256] = "Unknown";
***************
*** 454,458 ****
  t_int hid_close_device(t_hid *x)
  {
!     DEBUG(post("hid_close_device"););
      if (x->x_fd <0) 
          return 0;
--- 454,458 ----
  t_int hid_close_device(t_hid *x)
  {
!     debug_print(LOG_DEBUG,"hid_close_device");
      if (x->x_fd <0) 
          return 0;
***************
*** 463,467 ****
  t_int hid_build_device_list(t_hid *x)
  {
!     DEBUG(post("hid_build_device_list"););
      /* the device list should be refreshed here */
  /*
--- 463,467 ----
  t_int hid_build_device_list(t_hid *x)
  {
!     debug_print(LOG_DEBUG,"hid_build_device_list");
      /* the device list should be refreshed here */
  /*

Index: TODO
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/TODO,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** TODO	27 Jun 2005 00:27:53 -0000	1.20
--- TODO	27 May 2006 00:57:15 -0000	1.21
***************
*** 1,2 ****
--- 1,13 ----
+ 
+ 
+ 
+ TODO: make open functions:
+ 
+ device number
+ vendor_id product_id
+ Product String
+ 
+ 
+ 
  ==============================================================================
  = test verbose names
***************
*** 24,38 ****
  
  ==============================================================================
! = make fake names in input_arrays.c
  
! Instead of having "NULL" names, make up names using the event type, and the
! code number, i.e. abs_41, rel_15
  
  
  
  ==============================================================================
! = check out GDAM HID implementation 
  
- - GDAM has a HID Manager implementation and probably a Linux one too
  
  
--- 35,59 ----
  
  ==============================================================================
! = hid/serial
  
! - open/close status outlet
! 
! - [send ( to send data
  
+ - [tgl] 1/0 for open/close
  
  
  ==============================================================================
! = linux input synch events (EV_SYN)
! 
! - these seem to be generated by the Linux kernel, so they probably don't fit
!   in with the [hid] scheme.  Probably the best thing is to ditch them, or
!   figure out whether they should be used in controlling the flow of event
!   data, as they are intended.
! 
! 
! ==============================================================================
! = open/close status outlet
  
  
  
***************
*** 40,45 ****
  = profile [hid] object and usage
  
! - find out how much more CPU the names (btn_?, abs, rel, etc) use over using
!   just floats.
  
  
--- 61,66 ----
  = profile [hid] object and usage
  
! - find out if [autoscale] takes a lot of CPU power, or where in [hid] is using
!   CPU where it doesn't have to be
  
  
***************
*** 57,60 ****
--- 78,87 ----
  
  
+ ==============================================================================
+ = device 0 gets events for all available devices
+ 
+ - it might be useful to have device #0 open all available devices and output
+   the events.
+ 
  
  ==============================================================================
***************
*** 87,97 ****
  - most functions probably do not need return values
  
- - return (1) seems to be the default on many functions
- 
  
  ==============================================================================
  = control input messages
  
! - are [poll(, [start(, and [stop( needed?  is 0/1/del# enough?
  
  
--- 114,122 ----
  - most functions probably do not need return values
  
  
  ==============================================================================
  = control input messages
  
! - are [poll(, [start(, and [stop( needed?  is 0/1/delay# enough?
  
  
***************
*** 105,109 ****
  = event name changes
  
! - make key/button Type btn rather than key (undecided on this one)
  
  
--- 130,134 ----
  = event name changes
  
! - make key/button Type "button" rather than "key" (undecided on this one)
  
  
***************
*** 120,130 ****
  
  ==============================================================================
- = device 0 gets events for all available devices
- 
- - it might be useful to have device #0 open all available devices and output
-   the events.
- 
- 
- ==============================================================================
  = figure out whole degree issue
  
--- 145,148 ----
***************
*** 161,164 ****
--- 179,187 ----
  http://www.2dcurves.com
  
+ ==============================================================================
+ = check out using USB timestamp 
+ 
+ - use the USB timestamp to correctly space the output data
+ 
  
   /++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\
***************
*** 169,172 ****
--- 192,202 ----
  
  ______________________________________________________________________________
+ - BUG: figure out how to prevent segfaults on mismapped devices/elements
+ 
+ - it should gracefully ignore things where it currently segfaults
+ 
+ - looks like its in build_device_list
+ 
+ ______________________________________________________________________________
  - BUG: multiple instances pointing to the same device don't have seperate close/free
  
***************
*** 185,188 ****
--- 215,220 ----
    access.  It must since its used with games.
  
+ - turn off/unlink mousepointer for that device?
+ 
  
  ______________________________________________________________________________





More information about the Pd-cvs mailing list