Skip to content
Closed
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
14 changes: 11 additions & 3 deletions linux/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,8 @@ static int get_hid_report_descriptor_from_hidraw(hid_device *dev, struct hidraw_
*/
static int parse_uevent_info(const char *uevent, unsigned *bus_type,
unsigned short *vendor_id, unsigned short *product_id,
char **serial_number_utf8, char **product_name_utf8)
char **serial_number_utf8, char **product_name_utf8,
unsigned short *version)
{
char tmp[1024];

Expand Down Expand Up @@ -622,6 +623,11 @@ static int parse_uevent_info(const char *uevent, unsigned *bus_type,
/* The caller has to free the serial number */
*serial_number_utf8 = strdup(value);
found_serial = 1;
} else if (strcmp(key, "HID_FIRMWARE_VERSION") == 0) {
/* Device version from kernel, introduced in Linux v7.1:
https://github.com/torvalds/linux/commit/6ca9029c823b7853e980585e757343e0e84227cd
*/
*version = (unsigned short)strtol(value, NULL, 16);
}

next_line:
Expand All @@ -648,6 +654,7 @@ static struct hid_device_info * create_device_info_for_device(struct udev_device
char *serial_number_utf8 = NULL;
char *product_name_utf8 = NULL;
unsigned bus_type;
unsigned short hid_version = 0;
int result;
struct hidraw_report_descriptor report_desc;

Expand All @@ -670,7 +677,8 @@ static struct hid_device_info * create_device_info_for_device(struct udev_device
&dev_vid,
&dev_pid,
&serial_number_utf8,
&product_name_utf8);
&product_name_utf8,
&hid_version);

if (!result) {
/* parse_uevent_info() failed for at least one field. */
Expand Down Expand Up @@ -709,7 +717,7 @@ static struct hid_device_info * create_device_info_for_device(struct udev_device
cur_dev->serial_number = utf8_to_wchar_t(serial_number_utf8);

/* Release Number */
cur_dev->release_number = 0x0;
cur_dev->release_number = hid_version;

/* Interface Number */
cur_dev->interface_number = -1;
Expand Down
Loading