aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/bluetooth/bthidd/server.c
diff options
context:
space:
mode:
authorVladimir Kondratyev <wulf@FreeBSD.org>2018-04-30 12:16:54 +0000
committerVladimir Kondratyev <wulf@FreeBSD.org>2018-04-30 12:16:54 +0000
commit44af5666d96e9249c98eaee767dc8f5203c7e5dc (patch)
tree83160b3c83ac8cc14f2c77dece1f7fdfa7003006 /usr.sbin/bluetooth/bthidd/server.c
parente65080696611e52ddc84103f4314122d0a336fa5 (diff)
Notes
Diffstat (limited to 'usr.sbin/bluetooth/bthidd/server.c')
-rw-r--r--usr.sbin/bluetooth/bthidd/server.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/usr.sbin/bluetooth/bthidd/server.c b/usr.sbin/bluetooth/bthidd/server.c
index 1bde6e1794cc..33915307db0e 100644
--- a/usr.sbin/bluetooth/bthidd/server.c
+++ b/usr.sbin/bluetooth/bthidd/server.c
@@ -37,6 +37,7 @@
#include <assert.h>
#define L2CAP_SOCKET_CHECKED
#include <bluetooth.h>
+#include <dev/evdev/input.h>
#include <dev/vkbd/vkbd_var.h>
#include <errno.h>
#include <fcntl.h>
@@ -48,6 +49,7 @@
#include <usbhid.h>
#include "bthid_config.h"
#include "bthidd.h"
+#include "btuinput.h"
#include "kbd.h"
#undef max
@@ -282,19 +284,12 @@ server_accept(bthid_server_p srv, int32_t fd)
(fd == srv->ctrl)? "control" : "interrupt",
bt_ntoa(&l2addr.l2cap_bdaddr, NULL));
- /* Register session's vkbd descriptor (if needed) for read */
- if (s->state == OPEN && d->keyboard) {
- assert(s->vkbd != -1);
-
- FD_SET(s->vkbd, &srv->rfdset);
- if (s->vkbd > srv->maxfd)
- srv->maxfd = s->vkbd;
+ /* Create virtual kbd/mouse after both channels are established */
+ if (s->state == OPEN && session_run(s) < 0) {
+ session_close(s);
+ return (-1);
}
- /* Pass device for probing after both channels are established */
- if (s->state == OPEN)
- hid_initialise(s);
-
return (0);
}
@@ -309,9 +304,10 @@ server_process(bthid_server_p srv, int32_t fd)
int32_t len, to_read;
int32_t (*cb)(bthid_session_p, uint8_t *, int32_t);
union {
- uint8_t b[1024];
- vkbd_status_t s;
- } data;
+ uint8_t b[1024];
+ vkbd_status_t s;
+ struct input_event ie;
+ } data;
if (s == NULL)
return (0); /* can happen on device disconnect */
@@ -323,6 +319,9 @@ server_process(bthid_server_p srv, int32_t fd)
} else if (fd == s->intr) {
cb = hid_interrupt;
to_read = sizeof(data.b);
+ } else if (fd == s->ukbd) {
+ cb = uinput_kbd_status_changed;
+ to_read = sizeof(data.ie);
} else {
assert(fd == s->vkbd);