From b552b55cf6688e84a02dc0af88bfae2ed8c10e79 Mon Sep 17 00:00:00 2001 From: Jeff Hansen Date: Sun, 4 Mar 2012 20:44:19 -0700 Subject: [PATCH] input: Set up uinput device again, if it was previously closed. If you connect a PS3 controller to bluetoothd as an input device, then take the batteries out of a PS3 controller, then put them back in and push a few buttons, it will eventually cause an error which causes the uinput socket to be closed. It will then re-connect to bluetoothd, but the uinput socket fd will be -1, so it needs to be set up again after the re-connect. --- input/fakehid.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/input/fakehid.c b/input/fakehid.c index eebca0565..b8098705b 100644 --- a/input/fakehid.c +++ b/input/fakehid.c @@ -393,15 +393,17 @@ struct fake_input *fake_hid_connadd(struct fake_input *fake, /* New device? Add it to the list of known devices, * and create the uinput necessary */ - if (old == NULL) { + if (old == NULL || old->uinput < 0) { if (fake_hid->setup_uinput(fake, fake_hid)) { error("Error setting up uinput"); g_free(fake); return NULL; } - fake_hid->devices = g_list_append(fake_hid->devices, fake); } + if (old == NULL) + fake_hid->devices = g_list_append(fake_hid->devices, fake); + fake->io = g_io_channel_ref(intr_io); g_io_channel_set_close_on_unref(fake->io, TRUE); g_io_add_watch(fake->io, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, -- 2.47.3