Skip to contentSkip to conversation

HID: Add full support for Logitech Unifying receivers

PATCH Applied Nestor Lopez Casado 5 participants 11 messages Sep 14, 2011 – Apr 23, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 HID: Add full support for Logitech Unifying receivers

From: Nestor Lopez Casado <[email protected]>

With this driver, all the devices paired to a single Unifying receiver are exposed to user processes in separated /input/dev nodes.

Keyboards with different layouts can be treated differently, Multiplayer games on single PC (like home theater PC) can differentiate input coming from different kbds paired to the same receiver.

Up to now, when Logitech Unifying receivers are connected to a Linux based system, a single keyboard and a single mouse are presented to the HID Layer, even if the Unifying receiver can pair up to six compatible devices. The Unifying receiver by default multiplexes all incoming events (from multiple keyboards/mice) into these two.

---
Hi guys,

This is patch v5 of the dj bus driver. I addressed the comments from Jiri concerning the double (c) and the paragraph with author information on the file header.

Also changed the tmpstr[20] to tmpstr[3] with an additional check for the validity of the device_index returned by the receiver.

Cheers,
Nestor.

drivers/hid/Kconfig | 9 +

 drivers/hid/Makefile          |    1 +
 drivers/hid/hid-core.c        |    2 +
 drivers/hid/hid-ids.h         |    2 +
 drivers/hid/hid-logitech-dj.c |  925 +++++++++++++++++++++++++++++++++++++++++
 drivers/hid/hid-logitech-dj.h |  120 ++++++
 6 files changed, 1059 insertions(+), 0 deletions(-)
 create mode 100644 drivers/hid/hid-logitech-dj.c
 create mode 100644 drivers/hid/hid-logitech-dj.h
drivers/hid/Kconfig +9 -0
index 306b15f..e0f1360 100644
@@ -245,6 +245,15 @@ config HID_LOGITECH
 	---help---
 	Support for Logitech devices that are not fully compliant with HID standard.
 
+config HID_LOGITECH_DJ
+	tristate "Logitech Unifying receivers full support"
+	depends on HID_LOGITECH
+	default m
+	---help---
+	Say Y if you want support for Logitech Unifying receivers and devices.
+	Unifying receivers are capable of pairing up to 6 Logitech compliant
+	devices to the same receiver.
+
 config LOGITECH_FF
 	bool "Logitech force feedback support"
 	depends on HID_LOGITECH
drivers/hid/Makefile +1 -0
index 0a0a38e..ff36e489 100644
@@ -43,6 +43,7 @@ obj-$(CONFIG_HID_KEYTOUCH)	+= hid-keytouch.o
 obj-$(CONFIG_HID_KYE)		+= hid-kye.o
 obj-$(CONFIG_HID_LCPOWER)       += hid-lcpower.o
 obj-$(CONFIG_HID_LOGITECH)	+= hid-logitech.o
+obj-$(CONFIG_HID_LOGITECH_DJ)	+= hid-logitech-dj.o
 obj-$(CONFIG_HID_MAGICMOUSE)    += hid-magicmouse.o
 obj-$(CONFIG_HID_MICROSOFT)	+= hid-microsoft.o
 obj-$(CONFIG_HID_MONTEREY)	+= hid-monterey.o
drivers/hid/hid-core.c +2 -0
index 1a5cf0c..ab4ae12 100644
@@ -1419,6 +1419,8 @@ static const struct hid_device_id hid_have_special_driver[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFP_WHEEL) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G27_WHEEL) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER_2) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) },
drivers/hid/hid-ids.h +2 -0
index db63ccf..64bd2df 100644
@@ -443,6 +443,8 @@
 #define USB_DEVICE_ID_S510_RECEIVER_2	0xc517
 #define USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500	0xc512
 #define USB_DEVICE_ID_MX3000_RECEIVER	0xc513
+#define USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER	0xc52b
+#define USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER_2	0xc532
 #define USB_DEVICE_ID_SPACETRAVELLER	0xc623
 #define USB_DEVICE_ID_SPACENAVIGATOR	0xc626
 #define USB_DEVICE_ID_DINOVO_DESKTOP	0xc704
drivers/hid/hid-logitech-dj.c new file +925 -0

925 lines not on this page · raw message

drivers/hid/hid-logitech-dj.h new file +120 -0

120 lines not on this page · raw message

Signature · 1 line
1.7.5.3
Applied
#1 lore raw
Quoted 5 lines · Nestor Lopez Casado

From: Nestor Lopez Casado <[email protected]>

With this driver, all the devices paired to a single Unifying receiver are exposed to user processes in separated /input/dev nodes.

Applied. Thanks everybody.

Signature · 2 lines
Jiri Kosina
SUSE Labs
#2 lore raw
In reply to Nestor Lopez Casado

Am 14.09.2011 18:48, schrieb Nestor Lopez Casado:

Quoted 5 lines

From: Nestor Lopez Casado<[email protected]>

With this driver, all the devices paired to a single Unifying receiver are exposed to user processes in separated /input/dev nodes.

But there's still no way to pair devices with an Unifying receiver under Linux, right? It would be nice to have a simple userspace tool for that, too.

Signature · 2 lines
Regards,
Richard Schütz
#3 lore raw

Hi Richard,

here, you'll find a small C program that allows you to do a pairing of a new device to a receiver.

compile it with with gcc -o pairing_tool pairing_tool.c

--------------------------------- file pairing_tool.c
---------------------------------
/*
* Copyright 2011 Benjamin Tissoires <[email protected]> *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <linux/input.h>
#include <linux/hidraw.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>

#define USB_VENDOR_ID_LOGITECH (__u32)0x046d
#define USB_DEVICE_ID_UNIFYING_RECEIVER (__s16)0xc52b
#define USB_DEVICE_ID_UNIFYING_RECEIVER_2 (__s16)0xc532

int main(int argc, char **argv)

{
	int fd;
	int res;
	struct hidraw_devinfo info;
	char magic_sequence[] = {0x10, 0xFF, 0x80, 0xB2, 0x01, 0x00, 0x00};

	if (argc == 1) {
		errno = EINVAL;
		perror("No hidraw device given");
		return 1;
	}

	/* Open the Device with non-blocking reads. */
	fd = open(argv[1], O_RDWR|O_NONBLOCK);

	if (fd < 0) {
		perror("Unable to open device");
		return 1;
	}

	/* Get Raw Info */
	res = ioctl(fd, HIDIOCGRAWINFO, &info);
	if (res < 0) {
		perror("error while getting info from device");
	} else {
		if (info.bustype != BUS_USB ||
		    info.vendor != USB_VENDOR_ID_LOGITECH ||
		    (info.product != USB_DEVICE_ID_UNIFYING_RECEIVER &&
		     info.product != USB_DEVICE_ID_UNIFYING_RECEIVER_2)) {
			errno = EPERM;
			perror("The given device is not a Logitech "
				"Unifying Receiver");
			return 1;
		}
	}

	/* Send the magic sequence to the Device */
	res = write(fd, magic_sequence, sizeof(magic_sequence));
	if (res < 0) {
		printf("Error: %d\n", errno);
		perror("write");
	} else if (res == sizeof(magic_sequence)) {
		printf("The receiver is ready to pair a new device.\n"
		"Switch your device on to pair it.\n");
	} else {
		errno = ENOMEM;
		printf("write: %d were written instead of %ld.\n", res,
			sizeof(magic_sequence));
		perror("write");
	}
	close(fd);
	return 0;
}

----------------------------- end of file pairing_tool.c
----------------------------

I hope it will be useful to you.

Cheers,
Benjamin

Quoted 8 lines · Richard Schütz

Am 14.09.2011 18:48, schrieb Nestor Lopez Casado:

Quoted 6 lines

From: Nestor Lopez Casado<[email protected]>

With this driver, all the devices paired to a single Unifying receiver are exposed to user processes in separated /input/dev nodes.

Quoted 8 lines

But there's still no way to pair devices with an Unifying receiver under Linux, right? It would be nice to have a simple userspace tool for that, too.

--
Regards,
Richard Schütz

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

Am 22.09.2011 22:48, schrieb Benjamin Tissoires:

Quoted 4 lines

Hi Richard,

here, you'll find a small C program that allows you to do a pairing of a new device to a receiver.

Thanks.

Could you also add the possibility to remove a pairing? It would be nice if the program would print the product name of device detected during the pairing process, too.

I think the tool should be distributed somewhere officially. There are probably a lot of people, who would use the Unifying feature under Linux, but don't read the mailing lists.

Signature · 6 lines
Regards,
Richard Schütz
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw
Quoted 4 lines · Richard Schütz

Am 22.09.2011 22:48, schrieb Benjamin Tissoires:

Quoted 3 lines

Hi Richard,

Quoted 8 lines
Quoted 2 lines

here, you'll find a small C program that allows you to do a pairing of a new device to a receiver.

Thanks.

Could you also add the possibility to remove a pairing? It would be nice if the program would print the product name of device detected during the pairing process, too.

mmm... this would be more complicated:
- the first problem is a NDA and political one. As I worked in Logitech, I had access to some internal (confidential) documentation. I was able to release this piece of code as it can be easily retrieved by adding a spy on the usb stack when doing the pairing on windows. Discovering the command that removes devices is not so easy (to my mind), thus, I can not give it right now. Please note that I asked them if I could release this magic sequence, and it went quite high in the hierarchy (but this piece of code has nothing to do with Logitech, just to be clear).
- the second problem is more a technical one. The removal of the device would require you two know which device you want to remove. So it would require the ability to know all the different devices and their pairing number. This information shows up somewhere in the log but there is no way to ask the receiver for this information with the current status of the driver (without knowing internal commands). Getting it from the list of devices would be quite complicated depending on the number of receivers you have plugged, etc...
- Obtaining the name of the device can not be retrieved at the moment without knowing the different commands to send to the device. As it's confidential Logitech, I can not give them to you unless someone else does the retro-engineering.

So, to sum up, I agree this would be better, but today, this has to be done by someone else, either officially at Logitech, or by someone not related to Logitech that does the retro-engineering.

Quoted 4 lines

I think the tool should be distributed somewhere officially. There are probably a lot of people, who would use the Unifying feature under Linux, but don't read the mailing lists.

I really don't have the time to do it. If somebody else want to pack it and publish it, I'm fine with it. I just gave this piece of code on this channel in order to target skilled persons that are able to compile a C file, and to run it from a shell. Then, if someone wants to do a gui or anything else (the important part in the code is the magic sequence), it's ok for me.

Sorry for not being able to do more.
Benjamin

Quoted 5 lines

--
Regards,
Richard Schütz

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw

Am 23.09.2011 00:21, schrieb Benjamin Tissoires:

Quoted 37 lines · Richard Schütz
Quoted 4 lines

Am 22.09.2011 22:48, schrieb Benjamin Tissoires:

Quoted 3 lines

Hi Richard,

Quoted 8 lines
Quoted 2 lines

here, you'll find a small C program that allows you to do a pairing of a new device to a receiver.

Thanks.

Could you also add the possibility to remove a pairing? It would be nice if the program would print the product name of device detected during the pairing process, too.

mmm... this would be more complicated:
- the first problem is a NDA and political one. As I worked in Logitech, I had access to some internal (confidential) documentation. I was able to release this piece of code as it can be easily retrieved by adding a spy on the usb stack when doing the pairing on windows. Discovering the command that removes devices is not so easy (to my mind), thus, I can not give it right now. Please note that I asked them if I could release this magic sequence, and it went quite high in the hierarchy (but this piece of code has nothing to do with Logitech, just to be clear).
- the second problem is more a technical one. The removal of the device would require you two know which device you want to remove. So it would require the ability to know all the different devices and their pairing number. This information shows up somewhere in the log but there is no way to ask the receiver for this information with the current status of the driver (without knowing internal commands). Getting it from the list of devices would be quite complicated depending on the number of receivers you have plugged, etc...
- Obtaining the name of the device can not be retrieved at the moment without knowing the different commands to send to the device. As it's confidential Logitech, I can not give them to you unless someone else does the retro-engineering.

Quoted 3 lines

So, to sum up, I agree this would be better, but today, this has to be done by someone else, either officially at Logitech, or by someone not related to Logitech that does the retro-engineering.

So what do the Logitech guys think about this? Without userspace tools for creating/removing pairings a Unifying receiver is quite useless for Linux users.

Signature · 6 lines
Regards,
Richard Schütz
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#7 lore raw
In reply to Benjamin Tissoires
Quoted 6 lines · Benjamin Tissoires

Hi Richard,

here, you'll find a small C program that allows you to do a pairing of a new device to a receiver.

compile it with with gcc -o pairing_tool pairing_tool.c

Could this perhaps be provided into Documentation/ or samples/ somewhere? I don't think that Logitech themselves do ship pairing application for Linux, or do they?

If they don't, it'd be nice to have this at least documented somewhere, so that someone could write a pairing GUI.

Thanks.

Quoted 86 lines

--------------------------------- file pairing_tool.c
---------------------------------
/*
* Copyright 2011 Benjamin Tissoires <[email protected]> *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <linux/input.h>
#include <linux/hidraw.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>

#define USB_VENDOR_ID_LOGITECH (__u32)0x046d
#define USB_DEVICE_ID_UNIFYING_RECEIVER (__s16)0xc52b
#define USB_DEVICE_ID_UNIFYING_RECEIVER_2 (__s16)0xc532

int main(int argc, char **argv)

{
	int fd;
	int res;
	struct hidraw_devinfo info;
	char magic_sequence[] = {0x10, 0xFF, 0x80, 0xB2, 0x01, 0x00, 0x00};

	if (argc == 1) {
		errno = EINVAL;
		perror("No hidraw device given");
		return 1;
	}

	/* Open the Device with non-blocking reads. */
	fd = open(argv[1], O_RDWR|O_NONBLOCK);

	if (fd < 0) {
		perror("Unable to open device");
		return 1;
	}

	/* Get Raw Info */
	res = ioctl(fd, HIDIOCGRAWINFO, &info);
	if (res < 0) {
		perror("error while getting info from device");
	} else {
		if (info.bustype != BUS_USB ||
		    info.vendor != USB_VENDOR_ID_LOGITECH ||
		    (info.product != USB_DEVICE_ID_UNIFYING_RECEIVER &&
		     info.product != USB_DEVICE_ID_UNIFYING_RECEIVER_2)) {
			errno = EPERM;
			perror("The given device is not a Logitech "
				"Unifying Receiver");
			return 1;
		}
	}

	/* Send the magic sequence to the Device */
	res = write(fd, magic_sequence, sizeof(magic_sequence));
	if (res < 0) {
		printf("Error: %d\n", errno);
		perror("write");
	} else if (res == sizeof(magic_sequence)) {
		printf("The receiver is ready to pair a new device.\n"
		"Switch your device on to pair it.\n");
	} else {
		errno = ENOMEM;
		printf("write: %d were written instead of %ld.\n", res,
			sizeof(magic_sequence));
		perror("write");
	}
	close(fd);
	return 0;
}
Signature · 2 lines
Jiri Kosina
SUSE Labs
#8 lore raw
Quoted 9 lines · Benjamin Tissoires
Quoted 7 lines

Hi Richard,

here, you'll find a small C program that allows you to do a pairing of a new device to a receiver.

compile it with with gcc -o pairing_tool pairing_tool.c

Quoted 8 lines

Could this perhaps be provided into Documentation/ or samples/ somewhere? I don't think that Logitech themselves do ship pairing application for Linux, or do they?

If they don't, it'd be nice to have this at least documented somewhere, so that someone could write a pairing GUI.

Thanks.

Hi all,
Just as an FYI there is the Logitech Wireless WiiWheel which also uses the nRF24L01 in it's dongle.

This wheel is handled in Linux with 'hid-lg' and 'hid-lg4ff' drivers, but we all know engineers are lazy and a certain amount of the control protocol is likely to be similar.

Below are some notes I made (also
http://wiibrew.org/wiki/Logitech_USB_steering_wheel).

Maybe they are of some use from the Unifying dongles. Cheers,
Simon

--
Configuration

The Wheel/Dongle are configured by writing to the feature port of the USB dongle. This allows the control of the 'on-air' features, such as initiating the wireless link, controlling the RF channel/hooping sequence and RF addressing (sub-channel coding).

When first plugged in the wireless link between the dongle and the wheel is not active, the link can be 'brought up' with writing the '0xAF Command' followed by the '0xB2 Command'.

The commands take some time to action, this can be confirmed by reading back the feature port, when the command completes the MSB of the first byte will be cleared. For most commands the same data that was sent is returned, some commands return different data.

Configure RX/TX Address?
Byte 1 - 0xA9
Byte 2 - 2nd and 4th Address/Sub-Channel Bytes Byte 3 = 3rd and 5th Address/Sub-Channel Bytes Note 1st Sub-Channel byte is always 0xAE

RF Test Mode
Byte 1 = 0xAC
Byte 2 = Test Mode

0 - Normal Mode (LED flashes on/off as normal)
1 - Constant TX (LED on), RF channel in 'P3' (can kill WiFi ;-) 2 - Pulsed TX (LED flashes long-on/short-off)
3 - Receive Only? (LED off), RF channel in 'P3'. Continually polls
nRF24L01 status and clears

Byte 3 - RF Channel/Frequency

Initialise communications

    Byte 1 - 0xAF
    Byte 2 - Hopping Sequence (0x00..0x0F)

Change RX/TX Address
Byte 1 - 0xB2
Byte 2 - 2nd and 4th Address/Sub-Channel Bytes Byte 3 = 3rd and 5th Address/Sub-Channel Bytes Note 1st Sub-Channel byte is always 0xAE

The following commands do not cause SPI activity to the nRF24L01

Check Status?
Byte 1 - 0xA8
Returns RX/TX Address bytes in Byte 5 and Byte 6 Returns whether the 'button' pressed in Byte 7 bit 5 Returns something in Byte 7 bits 4..0 related to 'LED mode' (not a
direct map)
Returns something in Byte 8 which depends on Byte 2 sent

LED Mode
Byte 1 - 0xAA
Byte 2 - changes the way the LED flashes, unknown what is actually
happening

Unknown
Byte 1 - 0xAE
Doesn't clear Byte 1 bit 7, like the other commands. Perhaps it is
waiting for something...

    Returns 0x14 in Byte 5 and 0x00 in Byte 6

Active Address?

    Byte 1 - 0xB3
    Only clears Byte 1 bit 7 if Command '0xAF' is issued first
    Returns values in Byte 5 and Byte 6 which are the values from Command

'0xB2' Bytes 2 & 3
--

#9 lore raw
In reply to Jiri Kosina
Quoted 4 lines · Jiri Kosina
Quoted 2 lines · Benjamin Tissoires

Hi Richard,

Quoted 9 lines
Quoted 4 lines

here, you'll find a small C program that allows you to do a pairing of a new device to a receiver.

compile it with with gcc -o pairing_tool pairing_tool.c

Could this perhaps be provided into Documentation/ or samples/ somewhere? I don't think that Logitech themselves do ship pairing application for Linux, or do they?

Hi Jiri,

well, I don't have any information about an official pairing tool. However, I don't think the kernel is the good place for this stuff. Other people started projects based on this code:
https://bitbucket.org/clach04/logitech-unifying-receiver-tools/ for instance.

Thanks,
Benjamin

Quoted 97 lines

If they don't, it'd be nice to have this at least documented somewhere, so that someone could write a pairing GUI.

Thanks.

Quoted 78 lines

--------------------------------- file pairing_tool.c
---------------------------------
/*
* Copyright 2011 Benjamin Tissoires <[email protected]> *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <linux/input.h>
#include <linux/hidraw.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>

#define USB_VENDOR_ID_LOGITECH (__u32)0x046d
#define USB_DEVICE_ID_UNIFYING_RECEIVER (__s16)0xc52b
#define USB_DEVICE_ID_UNIFYING_RECEIVER_2 (__s16)0xc532

int main(int argc, char **argv)

{
	int fd;
	int res;
	struct hidraw_devinfo info;
	char magic_sequence[] = {0x10, 0xFF, 0x80, 0xB2, 0x01, 0x00, 0x00};

	if (argc == 1) {
		errno = EINVAL;
		perror("No hidraw device given");
		return 1;
	}

	/* Open the Device with non-blocking reads. */
	fd = open(argv[1], O_RDWR|O_NONBLOCK);

	if (fd < 0) {
		perror("Unable to open device");
		return 1;
	}

	/* Get Raw Info */
	res = ioctl(fd, HIDIOCGRAWINFO, &info);
	if (res < 0) {
		perror("error while getting info from device");
	} else {
		if (info.bustype != BUS_USB ||
		    info.vendor != USB_VENDOR_ID_LOGITECH ||
		    (info.product != USB_DEVICE_ID_UNIFYING_RECEIVER &&
		     info.product != USB_DEVICE_ID_UNIFYING_RECEIVER_2)) {
			errno = EPERM;
			perror("The given device is not a Logitech "
				"Unifying Receiver");
			return 1;
		}
	}

	/* Send the magic sequence to the Device */
	res = write(fd, magic_sequence, sizeof(magic_sequence));
	if (res < 0) {
		printf("Error: %d\n", errno);
		perror("write");
	} else if (res == sizeof(magic_sequence)) {
		printf("The receiver is ready to pair a new device.\n"
		"Switch your device on to pair it.\n");
	} else {
Quoted 8 lines
		errno = ENOMEM;
		printf("write: %d were written instead of %ld.\n", res,
			sizeof(magic_sequence));
		perror("write");
	}
	close(fd);
	return 0;
}

--
Jiri Kosina
SUSE Labs

#10 lore raw
Quoted 5 lines · Benjamin Tissoires
Quoted 5 lines
Quoted 4 lines

here, you'll find a small C program that allows you to do a pairing of a new device to a receiver.

compile it with with gcc -o pairing_tool pairing_tool.c

Quoted 8 lines
Quoted 4 lines

Could this perhaps be provided into Documentation/ or samples/ somewhere? I don't think that Logitech themselves do ship pairing application for Linux, or do they?

well, I don't have any information about an official pairing tool. However, I don't think the kernel is the good place for this stuff. Other people started projects based on this code:
https://bitbucket.org/clach04/logitech-unifying-receiver-tools/ for instance.

Thanks for the pointer. I don't think we need to fully include the pairing tool in the kernel, sure.
But at least description of the pairing magic packet, or link such as the above might be nice to have.

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs