diff --git a/profiles/input/device.h b/profiles/input/device.h
index ff52967..d8baa2c 100644
--- a/profiles/input/device.h
+++ b/profiles/input/device.h
int uinput; /* uinput socket */
int rfcomm; /* RFCOMM socket */
uint8_t ch; /* RFCOMM channel number */
+ guint timeout_id; /* Disconnect timeout ID */
gboolean (*connect) (struct input_conn *iconn, GError **err);
int (*disconnect) (struct input_conn *iconn);
void *priv;
diff --git a/profiles/input/fakehid.c b/profiles/input/fakehid.c
index 305a204..e258e60 100644
--- a/profiles/input/fakehid.c
+++ b/profiles/input/fakehid.c
#include "fakehid.h"
#include "uinput.h"
+/* Timeout to get the PS3 remote disconnected, in seconds */
+#define PS3_REMOTE_TIMEOUT 10 * 60
+
enum ps3remote_special_keys {
PS3R_BIT_PS = 0,
PS3R_BIT_ENTER = 3,
return -1;
}
+static gboolean ps3_remote_timeout_cb(gpointer user_data)
+{
+ struct fake_input *fake = user_data;
+
+ input_device_request_disconnect(fake);
+ DBG("Disconnected PS3 BD Remote after timeout");
+
+ fake->timeout_id = 0;
+
+ return FALSE;
+}
+
+static void ps3remote_set_timeout(struct fake_input *fake)
+{
+ fake->timeout_id = g_timeout_add_seconds(PS3_REMOTE_TIMEOUT,
+ ps3_remote_timeout_cb, fake);
+}
+
static gboolean ps3remote_event(GIOChannel *chan, GIOCondition cond,
gpointer data)
{
goto failed;
}
+ if (fake->timeout_id > 0)
+ g_source_remove(fake->timeout_id);
+ ps3remote_set_timeout(fake);
+
return TRUE;
failed:
+ if (fake->timeout_id > 0) {
+ g_source_remove(fake->timeout_id);
+ fake->timeout_id = 0;
+ }
ioctl(fake->uinput, UI_DEV_DESTROY);
close(fake->uinput);
fake->uinput = -1;
goto err;
}
+ ps3remote_set_timeout(fake);
+
return 0;
err:
for (l = fake_hid->devices; l != NULL; l = l->next) {
old = l->data;
if (old->idev == fake->idev) {
+ if (fake->timeout_id > 0)
+ g_source_remove(fake->timeout_id);
g_free(fake);
fake = old;
fake_hid->connect(fake, NULL);