[PD] HID seg fault on linux - debugging

Hans-Christoph Steiner hans at eds.org
Mon Jun 6 04:59:39 CEST 2005


On Jun 5, 2005, at 2:46 PM, august wrote:

>
>
> 'nother thing.  it seems to crash whenever it gets a null reference  
> from
> ev_abs...so here is the else statement I have in hid_linux.c for that  
> code
> chunk:
>
> else
> {
>  	if (event_names[hid_input_event.type][hid_input_event.code] == NULL)  
> {
>                 return 0;
>         }
>         if (hid_input_event.code < 41) {
>                  strcpy(hid_code,  
> event_names[hid_input_event.type][hid_input_event.code] );
>         }
> }

Instead I am actually going to make fake names, like abs_41, rel_16,  
etc. using the event type and code number.  Then those strange HID  
elements will still be usable with the [hid] object, though not the  
[joystick], [mouse], etc. objects (abstractions).


> another question: is there any benefit to using the HID descriptor  
> names
> such as abs_x, abs_y, etc.....or would it be possible to just use  
> numbers?
> it seems to me that the usb devices are pretty random in what controls
> they assign to what descriptor.  and, AFAIK, the "hi" object in MAX   
> just
> outputs lists with numbers for the initial control descriptors.

There are two key reasons why [hid] has the event scheme the way it is  
as compared to Max's [hi].  First, [hi] numbers the elements  
sequentially as it finds them.  That means your patch is tied to that  
exact make/model of joystick, rather than working with any joystick.

Second, I could have used standardized numbers, instead of names, ie  
code 1 always = x-axis.  But I thought I'd try using descriptive names  
so that you would not need to consult a lookup table in order to use  
the data from [hid].  It does use more CPU power, but I think its worth  
it.  If thru experience, it proves not to be worth it, I'll change the  
names to numbers.

If you are interested in know more about my thinking behind the design  
of this, check out my thesis paper:

http://at.or.at/hans/misc/itp/thesis/

.hc



________________________________________________________________________ 
____

            "The arc of history bends towards justice."
                                                               Dr.  
Martin Luther King, Jr.





More information about the Pd-list mailing list