Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement hid_get_input_report for Linux hidraw backend #351

Merged
merged 1 commit into from
Dec 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions linux/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@
#endif


// HIDIOCGINPUT is not defined in Linux kernel headers < 5.11.
// This definition is from hidraw.h in Linux >= 5.11.
// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f43d3870cafa2a0f3854c1819c8385733db8f9ae
#ifndef HIDIOCGINPUT
#define HIDIOCGINPUT(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x0A, len)
#endif

/* USB HID device property names */
const char *device_string_names[] = {
"manufacturer",
Expand Down Expand Up @@ -1065,13 +1072,15 @@ int HID_API_EXPORT hid_get_feature_report(hid_device *dev, unsigned char *data,
return res;
}

// Not supported by Linux HidRaw yet
int HID_API_EXPORT HID_API_CALL hid_get_input_report(hid_device *dev, unsigned char *data, size_t length)
{
(void)dev;
(void)data;
(void)length;
return -1;
int res;

res = ioctl(dev->device_handle, HIDIOCGINPUT(length), data);
if (res < 0)
register_device_error_format(dev, "ioctl (GINPUT): %s", strerror(errno));

return res;
}

void HID_API_EXPORT hid_close(hid_device *dev)
Expand Down