aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Minka2015-06-08 15:32:18 +0200
committerMartin Minka2015-06-08 15:32:18 +0200
commitcfb88f1573e22df8f0dd84ec69079c2bf3d84704 (patch)
tree2a701f7810f33c0a287229698a5fe2e4470aee77
downloadaur-cfb88f1573e22df8f0dd84ec69079c2bf3d84704.tar.gz
manual move to aur4
-rw-r--r--.SRCINFO16
-rw-r--r--PKGBUILD27
-rw-r--r--README14
-rw-r--r--pairing_tool.c75
4 files changed, 132 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..16369607ca86
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,16 @@
+pkgbase = pairing_tool
+ pkgdesc = Tool to pair Logitech devices to unifying receiver
+ pkgver = 20110922
+ pkgrel = 1
+ url = http://goo.gl/eG4q9
+ arch = i686
+ arch = x86_64
+ license = GPL
+ depends = glibc
+ source = pairing_tool.c
+ source = README
+ md5sums = ca0db9898ac03facd732ba12b3ec9751
+ md5sums = ab0f29754cce4d627babad9ddbc4b0e4
+
+pkgname = pairing_tool
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..d622397cdc8b
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,27 @@
+# Maintainer: Martin Minka <martin dot minka at gmail dot com>
+# Author: Benjamin Tissoires <benjamin.tissoi...@gmail.com>
+pkgname=pairing_tool
+pkgver=20110922
+pkgrel=1
+pkgdesc="Tool to pair Logitech devices to unifying receiver"
+arch=('i686' 'x86_64')
+url="http://goo.gl/eG4q9"
+license=('GPL')
+source=(pairing_tool.c README)
+depends=(glibc)
+md5sums=('ca0db9898ac03facd732ba12b3ec9751'
+ 'ab0f29754cce4d627babad9ddbc4b0e4')
+
+build() {
+ cd "${srcdir}"
+ gcc -o pairing_tool pairing_tool.c
+
+}
+
+package() {
+ cd "${srcdir}"
+ mkdir -p $pkgdir/usr/bin/
+ cp ./pairing_tool $pkgdir/usr/bin/
+ chmod 775 $pkgdir/usr/bin/pairing_tool
+}
+
diff --git a/README b/README
new file mode 100644
index 000000000000..716b4736a7cc
--- /dev/null
+++ b/README
@@ -0,0 +1,14 @@
+1. Find the hidraw device corresponding to the unifying receiver:
+
+# grep "Logitech USB Receiver" /sys/class/hidraw/hidraw*/device/uevent
+/sys/class/hidraw/hidraw0/device/uevent:HID_NAME=Logitech USB Receiver
+/sys/class/hidraw/hidraw1/device/uevent:HID_NAME=Logitech USB Receiver
+/sys/class/hidraw/hidraw2/device/uevent:HID_NAME=Logitech USB Receiver
+
+2. turn your device on
+
+3. Start unifying with the following command
+# sudo pairing_tool /dev/hidraw2
+
+4. quickly turn your device off and on
+
diff --git a/pairing_tool.c b/pairing_tool.c
new file mode 100644
index 000000000000..1d88c4c7e279
--- /dev/null
+++ b/pairing_tool.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2011 Benjamin Tissoires <benjamin.tissoi...@gmail.com>
+ *
+ * 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;
+}