summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/sixaxis.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c
index 5ef2c1a21..9290dbe74 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);