Diff between 1f17efbac0d5b0e475073a3b98bcda9c23c8e8c7 and 7bb73f092aaf14f882de9735f8c2b3064b1f6b4c

Changed Files

File Additions Deletions Status
plugins/sixaxis.c +7 -8 modified

Full Patch

diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c
index 5ef2c1a..9290dbe 100644
--- a/plugins/sixaxis.c
+++ b/plugins/sixaxis.c
@@ -344,16 +344,13 @@ static bool setup_device(int fd, const char *sysfs_path,
 	if (get_device_bdaddr(fd, &device_bdaddr, cp->type) < 0)
 		return false;
 
-	/* This can happen if controller was plugged while already connected
-	 * eg. to charge up battery. */
+	/* This can happen if controller was plugged while already setup and
+	 * connected eg. to charge up battery. */
 	device = btd_adapter_find_device(adapter, &device_bdaddr,
 							BDADDR_BREDR);
-	if (device && btd_device_is_connected(device))
-		return false;
-
-	device = btd_adapter_get_device(adapter, &device_bdaddr, BDADDR_BREDR);
-
-	if (g_slist_find_custom(btd_device_get_uuids(device), HID_UUID,
+	if (device != NULL &&
+		btd_device_is_connected(device) &&
+		g_slist_find_custom(btd_device_get_uuids(device), HID_UUID,
 						(GCompareFunc)strcasecmp)) {
 		char device_addr[18];
 		ba2str(&device_bdaddr, device_addr);
@@ -361,6 +358,8 @@ static bool setup_device(int fd, const char *sysfs_path,
 		return false;
 	}
 
+	device = btd_adapter_get_device(adapter, &device_bdaddr, BDADDR_BREDR);
+
 	info("sixaxis: setting up new device");
 
 	btd_device_device_set_name(device, cp->name);