Skip to content

Commit

Permalink
implement hid_get_input_report for Linux hidraw backend
Browse files Browse the repository at this point in the history
Fixes #259
  • Loading branch information
Be-ing committed Nov 14, 2021
1 parent b66d7c2 commit 8ca0e0f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion linux/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,13 +1065,25 @@ 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)
{
// HIDIOCGINPUT was added in Linux 5.11:
// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f43d3870cafa2a0f3854c1819c8385733db8f9ae
// With older kernels, just return an error.
#ifdef HIDIOCGINPUT
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;
#else
(void)dev;
(void)data;
(void)length;
return -1;
#endif
}

void HID_API_EXPORT hid_close(hid_device *dev)
Expand Down

0 comments on commit 8ca0e0f

Please sign in to comment.