• Paul Stewart's avatar
    USB Urefs for hid-core/hiddev · 36a9bab9
    Paul Stewart authored
      I've written a patch Vojtech and I discussed for enhancing the
    hiddev code to optionally provide more detailed output on read().
    The old functionality is still supported by default, and in
    situations where HID usage codes are unique across reports, the
    old method is still preferable due to its terseness.
        
      The new method provides the ability to determine exactly which
    value has changed, in cases where the HID usage codes are not  
    unique.  It also provides a means to optionally receive notification
    when input reports are received from the device, whether or not
    any of the values in the report have changed.
    
      The details of the changes are as follows:
      
      - All current code behaves identically
    
      - A new ioctl pair HIDIOCGFLAG/HIDIOCSFLAG gets and clears
        flags on the hiddev device.                             
    
      - If you set the flag HIDDEV_FLAG_UREF, the read() call switches
        from reading hiddev_event structures to hiddev_usage_ref
        structures.  The change takes effect immediately, even to
        already queued events that haven't been read() yet.  Here's
        an example of enabling FLAG_UREF:                          
    
        {
            int flag = HIDDEV_FLAG_UREF;
            if (ioctl(fd, HIDIOCSFLAG, &flag) != 0) {
                    perror("ioctl");
                    exit(1);
            }
        }
      
      - With the HIDDEV_FLAG_REPORT set (which is only allowed if
        HIDDEV_FLAG_UREF is also set), there is a special uref that
        will be read() in addition to the ones corresponding to
        changes in the device state: when uref.field_index is set to
        HID_FIELD_INDEX_NONE, this uref is a notification that the
        report referred to by report_type and report_id has been
        received from the device.  This can be useful in situations
        when the notification of the arrival of a report is useful
        even if there is no change in state.
    36a9bab9
hid-core.c 36.9 KB