forked from drath/libratbag
With permission from Benjamin Tissoires and Olivier Gay Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
66 lines
1.9 KiB
C
66 lines
1.9 KiB
C
/*
|
|
* Un-pairing tool.
|
|
*
|
|
* Copyright 2013 Benjamin Tissoires <benjamin.tissoires@gmail.com>
|
|
* Copyright 2013 Red Hat, Inc
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice (including the next
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
* Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
* DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
/*
|
|
* Based on the HID++ 1.0 documentation provided by Nestor Lopez Casado at:
|
|
* https://drive.google.com/folderview?id=0BxbRzx7vEV7eWmgwazJ3NUFfQ28&usp=sharing
|
|
*/
|
|
|
|
#include <linux/types.h>
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
|
|
#include <unifying.h>
|
|
#include <hidpp10.h>
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
int fd;
|
|
int idx;
|
|
|
|
/* Open the Unifying Receiver. */
|
|
if (argc == 1)
|
|
fd = unifying_find_receiver();
|
|
else {
|
|
fd = unifying_open_receiver(argv[1]);
|
|
perror("Unable to open device");
|
|
}
|
|
|
|
if (fd < 0)
|
|
return 1;
|
|
|
|
hidpp10_list_devices(fd);
|
|
|
|
fprintf(stderr, "Select the device index [0-5]: ");
|
|
scanf("%d", &idx);
|
|
|
|
if (idx >= 0 && idx < 6)
|
|
hidpp10_disconnect(fd, idx);
|
|
|
|
close(fd);
|
|
return 0;
|
|
}
|