diff options
| author | Paul Stewart <stewart@inverse.wetlogic.net> | 2002-03-16 18:14:24 -0800 |
|---|---|---|
| committer | Vojtech Pavlik <vojtech@suse.cz> | 2002-03-16 18:14:24 -0800 |
| commit | 36a9bab93af2737a23991d0a754ace7926f4464e (patch) | |
| tree | 1a8e9bcde928d85aeba04dd679e33c79f676f481 /include/linux/hiddev.h | |
| parent | bb94ccec13efe1d69601eb81c32468a73360464a (diff) | |
USB Urefs for hid-core/hiddev
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.
Diffstat (limited to 'include/linux/hiddev.h')
| -rw-r--r-- | include/linux/hiddev.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/include/linux/hiddev.h b/include/linux/hiddev.h index cffc0323325d..4f57c1174598 100644 --- a/include/linux/hiddev.h +++ b/include/linux/hiddev.h @@ -119,6 +119,7 @@ struct hiddev_usage_ref { __s32 value; }; +#define HID_FIELD_INDEX_NONE 0xffffffff /* * Protocol version. @@ -143,6 +144,15 @@ struct hiddev_usage_ref { #define HIDIOCGUSAGE _IOWR('H', 0x0B, struct hiddev_usage_ref) #define HIDIOCSUSAGE _IOW('H', 0x0C, struct hiddev_usage_ref) #define HIDIOCGUCODE _IOWR('H', 0x0D, struct hiddev_usage_ref) +#define HIDIOCGFLAG _IOR('H', 0x0E, int) +#define HIDIOCSFLAG _IOW('H', 0x0F, int) + +/* + * Flags to be used in HIDIOCSFLAG + */ +#define HIDDEV_FLAG_UREF 0x1 +#define HIDDEV_FLAG_REPORT 0x2 +#define HIDDEV_FLAGS 0x3 /* To traverse the input report descriptor info for a HID device, perform the * following: @@ -179,7 +189,7 @@ struct hiddev_usage_ref { #ifdef CONFIG_USB_HIDDEV int hiddev_connect(struct hid_device *); void hiddev_disconnect(struct hid_device *); -void hiddev_hid_event(struct hid_device *, unsigned int usage, int value); +void hiddev_hid_event(struct hid_device *, struct hiddev_usage_ref *ref); int __init hiddev_init(void); void __exit hiddev_exit(void); #else |
