Difference between revisions of "Logitech Unifying Receiver"

From ArchWiki
Jump to: navigation, search
m (Installing pairintool: Typo)
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
[[Category:Input devices]]
 
[[Category:Input devices]]
{{i18n|Logitech Unifying Receiver}}
+
[[zh-TW:Logitech Unifying Receiver]]
 
The [http://www.logitech.com/349/6072 Logitech Unifying Receiver] is a wireless receiver that can connect up to six compatible wireless mice and keyboards to your computer.
 
The [http://www.logitech.com/349/6072 Logitech Unifying Receiver] is a wireless receiver that can connect up to six compatible wireless mice and keyboards to your computer.
 
The input device that comes with the receiver is already paired with it and should work out of the box through plug and play.
 
The input device that comes with the receiver is already paired with it and should work out of the box through plug and play.
Line 6: Line 6:
 
However [http://goo.gl/eG4q9 Benjamin Tissoires] posted a program on the kernel mailing list that allows pairing of additional devices also under Linux.
 
However [http://goo.gl/eG4q9 Benjamin Tissoires] posted a program on the kernel mailing list that allows pairing of additional devices also under Linux.
  
==Compiling unifying_pair==
+
==Installing pairingtool==
  
The program can also be found in [https://aur.archlinux.org/packages.php?ID=58261 AUR]
+
===From AUR===
 +
 
 +
You can install [https://aur.archlinux.org/packages.php?ID=58261 pairingtool] directly from AUR.
 +
 
 +
===Compiling manually===
 +
 
 +
If you want, you can also compile the sourcecode manually.
  
 
At first make sure that a C compiler is installed on your system:
 
At first make sure that a C compiler is installed on your system:
 
  # pacman -S gcc  
 
  # pacman -S gcc  
  
Afterwards copy and paste the following code to a local file, for example ''unifying_pair.c'':
+
Afterwards copy and paste the following code to a local file, for example ''pairing_tool.c'':
  
 
  /*
 
  /*
Line 99: Line 105:
 
  }
 
  }
  
Afterwards the code has to be compiled into the executable file ''unifying_pair'':
+
Afterwards the code has to be compiled into the executable file ''pairing_tool'':
  $ gcc -o unifying_pair unifying_pair.c  
+
  $ gcc -o pairing_tool pairing_tool.c
  
 
==Pairing of Compatible Devices==
 
==Pairing of Compatible Devices==
Line 111: Line 117:
  
 
Now switch off the device that you want to pair (if it was on) and execute your compiled program with the appropriate device as argument:
 
Now switch off the device that you want to pair (if it was on) and execute your compiled program with the appropriate device as argument:
  # ./unifying_pair /dev/hidraw0
+
  # ./pairing_tool /dev/hidraw0
 
+
The receiver is ready to pair a new device.
If the program runs fine it will tell you to turn on the device and it should work properly then.
+
Switch your device on to pair it.
 +
Now switch on the device you want to pair. After a few seconds your new device should work properly.
  
 
==Known Problems==
 
==Known Problems==
 +
===Wrong device===
 +
On some systems there is more than one device that has the same name. In that case you will receive the following error message when the wrong device is choosen:
 +
# pairing_tool /dev/hidraw1
 +
Error: 32
 +
write: Broken pipe
 
===Keyboard Layout via xorg.conf===
 
===Keyboard Layout via xorg.conf===
 
With kernel 3.2 the Unifying Receiver got its own kernel module ''hid_logitech_dj'' which does not work flawlessly together with keyboard layout setting set via [[Xorg#Keyboard settings|xorg.conf]].
 
With kernel 3.2 the Unifying Receiver got its own kernel module ''hid_logitech_dj'' which does not work flawlessly together with keyboard layout setting set via [[Xorg#Keyboard settings|xorg.conf]].

Revision as of 10:36, 4 December 2012

The Logitech Unifying Receiver is a wireless receiver that can connect up to six compatible wireless mice and keyboards to your computer. The input device that comes with the receiver is already paired with it and should work out of the box through plug and play. Logitech officially supports pairing of additional devices just through their Windows software. However Benjamin Tissoires posted a program on the kernel mailing list that allows pairing of additional devices also under Linux.

Installing pairingtool

From AUR

You can install pairingtool directly from AUR.

Compiling manually

If you want, you can also compile the sourcecode manually.

At first make sure that a C compiler is installed on your system:

# pacman -S gcc 

Afterwards copy and paste the following code to a local file, for example pairing_tool.c:

/*
* Copyright 2011 Benjamin Tissoires 
*
* 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 .
*/

#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;
}

Afterwards the code has to be compiled into the executable file pairing_tool:

$ gcc -o pairing_tool pairing_tool.c

Pairing of Compatible Devices

Next you need to find the device that the receiver has, therefore take a look at the outputs of

$ cat /sys/class/hidraw/hidrawX/device/uevent |grep NAME

(where you have to replace X with the - on your system valid - integers) until you find your Logitech USB Receiver (here it was directly device 0):

$ cat /sys/class/hidraw/hidraw0/device/uevent |grep NAME
  HID_NAME=Logitech USB Receiver

Now switch off the device that you want to pair (if it was on) and execute your compiled program with the appropriate device as argument:

# ./pairing_tool /dev/hidraw0
The receiver is ready to pair a new device.
Switch your device on to pair it.

Now switch on the device you want to pair. After a few seconds your new device should work properly.

Known Problems

Wrong device

On some systems there is more than one device that has the same name. In that case you will receive the following error message when the wrong device is choosen:

# pairing_tool /dev/hidraw1
Error: 32
write: Broken pipe

Keyboard Layout via xorg.conf

With kernel 3.2 the Unifying Receiver got its own kernel module hid_logitech_dj which does not work flawlessly together with keyboard layout setting set via xorg.conf. A temporary workaround is to use xorg-setxkbmap and set the layout manually. For example for a German layout with no deadkeys one has to execute:

$ setxkbmap -layout de -variant nodeadkeys

To automate this process one could add this line to xinitrc.