summaryrefslogtreecommitdiffstats
path: root/input/device.c
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2007-02-27 19:39:03 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2007-02-27 19:39:03 +0000
commitd242929462d90d619156709b9188f455d6f1fea3 (patch)
tree8d55a788226840bb117f5134e8ab1ea3a8112976 /input/device.c
parentbebbd2498d580e91d8184970732383449d856a3c (diff)
Fake input: changed is_connected function to support fake inputs
Diffstat (limited to 'input/device.c')
-rw-r--r--input/device.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/input/device.c b/input/device.c
index 0ae644a5..3c6c2f12 100644
--- a/input/device.c
+++ b/input/device.c
@@ -564,6 +564,7 @@ static gboolean rfcomm_io_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
return TRUE;
failed:
+ /* FIXME: Missing clean/free fake io channel */
g_io_channel_close(chan);
g_io_channel_unref(chan);
ioctl(fake->uinput, UI_DEV_DESTROY);
@@ -638,7 +639,6 @@ static gboolean rfcomm_connect_cb(GIOChannel *chan,
return FALSE;
failed:
- /* FIXME: close the rfcomm and uinput socket */
err_connection_failed(pc->conn, pc->msg, strerror(err));
pending_connect_free(pc);
g_io_channel_unref(chan);
@@ -973,17 +973,27 @@ fail:
return -errno;
}
-static int is_connected(bdaddr_t *dst)
+static int is_connected(struct input_device *idev)
{
+ struct fake_input *fake = idev->fake;
struct hidp_conninfo ci;
int ctl;
+ /* Fake input */
+ if (fake) {
+ if (fake->io)
+ return 1;
+ else
+ return 0;
+ }
+
+ /* Standard HID */
ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HIDP);
if (ctl < 0)
return 0;
memset(&ci, 0, sizeof(struct hidp_conninfo));
- bacpy(&ci.bdaddr, dst);
+ bacpy(&ci.bdaddr, &idev->dst);
if (ioctl(ctl, HIDPGETCONNINFO, &ci) < 0) {
close(ctl);
return 0;
@@ -1008,8 +1018,7 @@ static DBusHandlerResult device_connect(DBusConnection *conn,
struct input_manager *mgr;
struct pending_connect *pc;
- /* FIXME: check if the fake input is connected */
- if (is_connected(&idev->dst))
+ if (is_connected(idev))
return err_connection_failed(conn, msg, "Already connected");
/* FIXME: Check if there is a pending connection */
@@ -1060,7 +1069,7 @@ static DBusHandlerResult device_is_connected(DBusConnection *conn,
DBusMessage *reply;
dbus_bool_t connected;
- connected = is_connected(&idev->dst);
+ connected = is_connected(idev);
reply = dbus_message_new_method_return(msg);
if (!reply)
return DBUS_HANDLER_RESULT_NEED_MEMORY;