From bdcc194e413f1176bef9be22e1219c08f57833d8 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 23 Oct 2015 09:45:32 -0400 Subject: [PATCH] hidpp10: implement get_extended_pairing_info for the serial number This request has more information, for now we just fetch the serial number Signed-off-by: Peter Hutterer Signed-off-by: Benjamin Tissoires --- src/hidpp10.c | 20 ++++++++++++++++++++ src/hidpp10.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/src/hidpp10.c b/src/hidpp10.c index 874c93c2..0f14c25f 100644 --- a/src/hidpp10.c +++ b/src/hidpp10.c @@ -1145,6 +1145,26 @@ hidpp10_get_pairing_information_device_name(struct hidpp10_device *dev, return 0; } +int +hidpp10_get_extended_pairing_information(struct hidpp10_device *dev, + uint32_t *serial) +{ + unsigned int idx = dev->index; + union hidpp10_message info = CMD_PAIRING_INFORMATION(idx, DEVICE_EXTENDED_PAIRING_INFORMATION); + int res; + + hidpp_log_raw(&dev->base, "Fetching extended pairing information\n"); + + res = hidpp10_request_command(dev, &info); + if (res) + return -1; + + *serial = hidpp10_get_unaligned_u16(&info.msg.string[2]) << 16; + *serial |= hidpp10_get_unaligned_u16(&info.msg.string[4]); + + return 0; +} + /* -------------------------------------------------------------------------- */ /* 0xF1: Device Firmware Information */ /* -------------------------------------------------------------------------- */ diff --git a/src/hidpp10.h b/src/hidpp10.h index d100ff21..5b1cf1fe 100644 --- a/src/hidpp10.h +++ b/src/hidpp10.h @@ -492,6 +492,9 @@ int hidpp10_get_pairing_information_device_name(struct hidpp10_device *dev, char *name, size_t *name_sz); +int +hidpp10_get_extended_pairing_information(struct hidpp10_device *dev, + uint32_t *serial); /* -------------------------------------------------------------------------- */ /* 0xF1: Device Firmware Information */