Update of /cvsroot/pure-data/externals/hcs/hid In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6176
Modified Files: hid.c hid_linux.c Log Message: fixed pointer bug that was preventing proper creation of the element array. Now it outputs data properly on Linux
Index: hid_linux.c =================================================================== RCS file: /cvsroot/pure-data/externals/hcs/hid/hid_linux.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** hid_linux.c 25 Aug 2006 01:41:49 -0000 1.21 --- hid_linux.c 22 Sep 2006 05:05:51 -0000 1.22 *************** *** 16,21 **** #include "hid.h"
! //#define DEBUG(x) ! #define DEBUG(x) x
#define LINUX_BLOCK_DEVICE "/dev/input/event" --- 16,21 ---- #include "hid.h"
! #define DEBUG(x) ! //#define DEBUG(x) x
#define LINUX_BLOCK_DEVICE "/dev/input/event" *************** *** 26,35 **** */
#define BITS_PER_LONG (sizeof(long) * 8) ! #define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1) ! #define OFF(x) ((x)%BITS_PER_LONG) ! #define BIT(x) (1UL<<OFF(x)) #define LONG(x) ((x)/BITS_PER_LONG) ! #define test_bit(bit, array) ((array[LONG(bit)] >> OFF(bit)) & 1)
--- 26,34 ---- */
+ /* from asm/types.h and linux/input.h __kernel__ sections */ #define BITS_PER_LONG (sizeof(long) * 8) ! #define NBITS(x) (((x)/BITS_PER_LONG)+1) #define LONG(x) ((x)/BITS_PER_LONG) ! #define test_bit(bit, array) ((array[LONG(bit)] >> (bit%BITS_PER_LONG)) & 1)
*************** *** 295,299 **** static void hid_build_element_list(t_hid *x) { ! post("hid_build_element_list"); unsigned long element_bitmask[EV_MAX][NBITS(KEY_MAX)]; uint8_t abs_bitmask[ABS_MAX/8 + 1]; --- 294,298 ---- static void hid_build_element_list(t_hid *x) { ! debug_print(LOG_DEBUG,"hid_build_element_list"); unsigned long element_bitmask[EV_MAX][NBITS(KEY_MAX)]; uint8_t abs_bitmask[ABS_MAX/8 + 1]; *************** *** 305,309 **** if( x->x_fd ) { - new_element = getbytes(sizeof(t_hid_element)); /* get bitmask representing supported elements (axes, keys, etc.) */ memset(element_bitmask, 0, sizeof(element_bitmask)); --- 304,307 ---- *************** *** 317,322 **** if(test_bit(i, element_bitmask[0])) { - new_element->linux_type = i; - new_element->type = gensym(ev[i] ? ev[i] : "?"); /* get bitmask representing supported button types */ ioctl(x->x_fd, EVIOCGBIT(i, KEY_MAX), element_bitmask[i]); --- 315,318 ---- *************** *** 327,330 **** --- 323,327 ---- for(j = 0; j < KEY_MAX; j++) { + new_element = getbytes(sizeof(t_hid_element)); if( (i == EV_ABS) && (test_bit(j, abs_bitmask)) ) { *************** *** 342,345 **** --- 339,344 ---- if(test_bit(j, element_bitmask[i])) { + new_element->linux_type = i; /* the int from linux/input.h */ + new_element->type = gensym(ev[i] ? ev[i] : "?"); /* the symbol */ new_element->linux_code = j; if((i == EV_KEY) && (j >= BTN_MISC) && (j < KEY_OK) ) *************** *** 379,383 **** void 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 */ --- 378,382 ---- void hid_get_events(t_hid *x) { ! debug_print(9,"hid_get_events");
/* for debugging, counts how many events are processed each time hid_read() is called */ *************** *** 399,408 **** for( i=0; i < element_count[x->x_device_number]; ++i ) { ! output_element = element[x->x_device_number][i]; if( (hid_input_event.type == output_element->linux_type) && \ (hid_input_event.code == output_element->linux_code) ) { output_element->value = hid_input_event.value; ! post("output %d",output_element->value); break; } --- 398,409 ---- for( i=0; i < element_count[x->x_device_number]; ++i ) { ! output_element = element[x->x_device_number][i]; if( (hid_input_event.type == output_element->linux_type) && \ (hid_input_event.code == output_element->linux_code) ) { output_element->value = hid_input_event.value; ! debug_print(9,"i: %d linux_type: %d linux_code: %d", i, ! output_element->linux_type, output_element->linux_code); ! debug_print(9,"value to output: %d",output_element->value); break; } *************** *** 415,419 **** DEBUG( if(event_counter > 0) ! post("output %d events",event_counter); ); --- 416,420 ---- DEBUG( if(event_counter > 0) ! debug_print(8,"output %d events",event_counter); );
Index: hid.c =================================================================== RCS file: /cvsroot/pure-data/externals/hcs/hid/hid.c,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** hid.c 25 Aug 2006 01:41:49 -0000 1.30 --- hid.c 22 Sep 2006 05:05:51 -0000 1.31 *************** *** 36,41 **** */
! //#define DEBUG(x) ! #define DEBUG(x) x
unsigned short global_debug_level = 0; --- 36,41 ---- */
! #define DEBUG(x) ! //#define DEBUG(x) x
unsigned short global_debug_level = 0; *************** *** 225,229 **** outlet_anything(x->x_data_outlet,output_data->type,3,event_data); #endif ! } }
--- 225,229 ---- outlet_anything(x->x_data_outlet,output_data->type,3,event_data); #endif ! } }