int input_device_set_channel(const bdaddr_t *src, const bdaddr_t *dst, int psm, GIOChannel *io) { struct input_device *idev = find_device(src, dst); struct input_conn *iconn; if (!idev) return -ENOENT; iconn = find_connection(idev->connections, "hid"); if (!iconn) return -ENOENT; switch (psm) { case L2CAP_PSM_HIDP_CTRL: if (iconn->ctrl_io) return -EALREADY; iconn->ctrl_io = g_io_channel_ref(io); break; case L2CAP_PSM_HIDP_INTR: if (iconn->intr_io) return -EALREADY; iconn->intr_io = g_io_channel_ref(io); break; } if (iconn->intr_io && iconn->ctrl_io) input_device_connadd(idev, iconn); return 0; }
int input_device_set_channel(const bdaddr_t *src, const bdaddr_t *dst, int psm, GIOChannel *io) { struct input_device *idev = find_device(src, dst); DBG("idev %p psm %d", idev, psm); if (!idev) return -ENOENT; switch (psm) { case L2CAP_PSM_HIDP_CTRL: if (idev->ctrl_io) return -EALREADY; idev->ctrl_io = g_io_channel_ref(io); idev->ctrl_watch = g_io_add_watch(idev->ctrl_io, G_IO_HUP | G_IO_ERR | G_IO_NVAL, ctrl_watch_cb, idev); break; case L2CAP_PSM_HIDP_INTR: if (idev->intr_io) return -EALREADY; idev->intr_io = g_io_channel_ref(io); idev->intr_watch = g_io_add_watch(idev->intr_io, G_IO_HUP | G_IO_ERR | G_IO_NVAL, intr_watch_cb, idev); break; } if (idev->intr_io && idev->ctrl_io) input_device_connadd(idev); return 0; }
int input_device_set_channel(const bdaddr_t *src, const bdaddr_t *dst, int psm, GIOChannel *io) { struct input_device *idev = find_device(src, dst); struct input_conn *iconn; char sstr[18], dstr[18]; ba2str(src, sstr); ba2str(dst, dstr); DBG("src %s, dst %s", sstr, dstr); DBG("idev %p", idev); if (!idev) return -ENOENT; iconn = find_connection(idev->connections, HID_UUID); if (!iconn) return -ENOENT; switch (psm) { case L2CAP_PSM_HIDP_CTRL: if (iconn->ctrl_io) return -EALREADY; iconn->ctrl_io = g_io_channel_ref(io); break; case L2CAP_PSM_HIDP_INTR: if (iconn->intr_io) return -EALREADY; iconn->intr_io = g_io_channel_ref(io); break; } if (iconn->intr_io && iconn->ctrl_io) input_device_connadd(idev, iconn); return 0; }