Update cable plugin

This commit is contained in:
Bastien Nocera 2010-06-14 10:45:59 +00:00
parent 43c645615e
commit f1feb4889a

View File

@ -1,4 +1,4 @@
From 09ef06047b1b180e68853786cd9efb9a1c5b2379 Mon Sep 17 00:00:00 2001
From 5e78f3524c73fe5041bf88dada41f5dd3105e9fc Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Tue, 1 Sep 2009 17:32:48 +0100
Subject: [PATCH] Add sixaxis cable-pairing plugin
@ -129,7 +129,7 @@ index f7bb047..25005c0 100644
+ AM_CONDITIONAL(CABLE, test "${cable_enable}" = "yes" && test "${cable_found}" = "yes")
])
diff --git a/configure.ac b/configure.ac
index ec090aa..0c6fd97 100644
index 154d0dc..0e7084f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,7 +40,10 @@ AC_PATH_GLIB
@ -145,7 +145,7 @@ index ec090aa..0c6fd97 100644
diff --git a/plugins/cable.c b/plugins/cable.c
new file mode 100644
index 0000000..698d5e6
index 0000000..d74c771
--- /dev/null
+++ b/plugins/cable.c
@@ -0,0 +1,385 @@
@ -253,14 +253,14 @@ index 0000000..698d5e6
+ 5000);
+
+ if (res < 0) {
+ debug("Getting the device Bluetooth address failed");
+ DBG("Getting the device Bluetooth address failed");
+ return NULL;
+ }
+
+ address = g_strdup_printf("%02X:%02X:%02X:%02X:%02X:%02X",
+ msg[4], msg[5], msg[6], msg[7], msg[8], msg[9]);
+
+ debug("Device Bluetooth address: %s\n", address);
+ DBG("Device Bluetooth address: %s\n", address);
+
+ return address;
+}
@ -292,7 +292,7 @@ index 0000000..698d5e6
+ 5000);
+
+ if (res < 0) {
+ debug("Setting the master Bluetooth address failed");
+ DBG("Setting the master Bluetooth address failed");
+ return FALSE;
+ }
+
@ -314,24 +314,24 @@ index 0000000..698d5e6
+ device_bdaddr = NULL;
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (conn == NULL) {
+ debug("Failed to get on the bus");
+ DBG("Failed to get on the bus");
+ return;
+ }
+
+ if (libusb_open(dev, &devh) < 0) {
+ debug("Can't open device");
+ DBG("Can't open device");
+ goto bail;
+ }
+ libusb_detach_kernel_driver(devh, itfnum);
+
+ if (libusb_claim_interface(devh, itfnum) < 0) {
+ debug("Can't claim interface %d", itfnum);
+ DBG("Can't claim interface %d", itfnum);
+ goto bail;
+ }
+
+ device_bdaddr = get_bdaddr(devh, itfnum);
+ if (device_bdaddr == NULL) {
+ debug("Failed to get the Bluetooth address from the device");
+ DBG("Failed to get the Bluetooth address from the device");
+ goto bail;
+ }
+
@ -344,10 +344,10 @@ index 0000000..698d5e6
+
+ adapter_get_address(adapter, &dst);
+ ba2str(&dst, adapter_bdaddr);
+ debug("Adapter bdaddr %s", adapter_bdaddr);
+ DBG("Adapter bdaddr %s", adapter_bdaddr);
+
+ if (set_master_bdaddr(devh, itfnum, adapter_bdaddr) == FALSE) {
+ debug("Failed to set the master Bluetooth address");
+ DBG("Failed to set the master Bluetooth address");
+ goto bail;
+ }
+
@ -380,12 +380,12 @@ index 0000000..698d5e6
+ if (udev_device_get_property_value(udevice, "ID_USB_DRIVER") != NULL)
+ return;
+
+ debug("Found Sixaxis device");
+ DBG("Found Sixaxis device");
+
+ /* Look for the default adapter */
+ adapter_id = manager_get_default_adapter();
+ if (adapter_id == -1) {
+ debug("No adapters, exiting");
+ DBG("No adapters, exiting");
+ return;
+ }
+ adapter = manager_find_adapter_by_id(adapter_id);
@ -397,7 +397,7 @@ index 0000000..698d5e6
+
+ num_devices = libusb_get_device_list(NULL, &list);
+ if (num_devices < 0) {
+ debug("libusb_get_device_list failed");
+ DBG("libusb_get_device_list failed");
+ return;
+ }
+
@ -418,12 +418,12 @@ index 0000000..698d5e6
+
+ libusb_free_device_list(list, TRUE);
+ if (usbdev == NULL) {
+ debug("Found a Sixaxis, but couldn't find it via libusb");
+ DBG("Found a Sixaxis, but couldn't find it via libusb");
+ goto out;
+ }
+
+ if (libusb_get_device_descriptor(usbdev, &desc) < 0) {
+ debug("libusb_get_device_descriptor() failed");
+ DBG("libusb_get_device_descriptor() failed");
+ goto out;
+ }
+
@ -433,7 +433,7 @@ index 0000000..698d5e6
+ guint8 k;
+
+ if (libusb_get_config_descriptor(usbdev, j, &config) < 0) {
+ debug("Failed to get config descriptor %d", j);
+ DBG("Failed to get config descriptor %d", j);
+ continue;
+ }
+
@ -493,7 +493,7 @@ index 0000000..698d5e6
+{
+ GIOChannel *channel;
+
+ debug("Setup cable plugin");
+ DBG("Setup cable plugin");
+
+ ctx = udev_new();
+ monitor = udev_monitor_new_from_netlink(ctx, "udev");
@ -516,7 +516,7 @@ index 0000000..698d5e6
+
+static void cable_exit(void)
+{
+ debug("Cleanup cable plugin");
+ DBG("Cleanup cable plugin");
+
+ if (watch_id != 0) {
+ g_source_remove(watch_id);