diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2006-09-29 16:15:41 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2006-09-29 16:15:41 +0000 |
commit | 6d2c7e465e4a8e3e6bb9595ccfd0f471070eda69 (patch) | |
tree | a7e13644ff92608e32c9e77661b68467dd12dd10 /hidd/fakehid.c | |
parent | 2f867d62c154c7746b97480fee121a5feb308a94 (diff) |
Add framework for Celluon keyboard
Diffstat (limited to 'hidd/fakehid.c')
-rw-r--r-- | hidd/fakehid.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/hidd/fakehid.c b/hidd/fakehid.c index 3a1c0d6e..22349cbf 100644 --- a/hidd/fakehid.c +++ b/hidd/fakehid.c @@ -452,3 +452,70 @@ int jthree_keyboard(const bdaddr_t *src, const bdaddr_t *dst, uint8_t channel) return 0; } + +int celluon_keyboard(const bdaddr_t *src, const bdaddr_t *dst, uint8_t channel) +{ + unsigned char buf[16]; + struct sigaction sa; + struct pollfd p; + sigset_t sigs; + char addr[18]; + int fd, sk, len; + + sk = rfcomm_connect(src, dst, channel); + if (sk < 0) + return -1; + + fd = uinput_create("Celluon Keyboard", 1, 0); + if (fd < 0) { + close(sk); + return -1; + } + + ba2str(dst, addr); + + printf("Connected to %s on channel %d\n", addr, channel); + printf("Press CTRL-C for hangup\n"); + + memset(&sa, 0, sizeof(sa)); + sa.sa_flags = SA_NOCLDSTOP; + sa.sa_handler = SIG_IGN; + sigaction(SIGCHLD, &sa, NULL); + sigaction(SIGPIPE, &sa, NULL); + + sa.sa_handler = sig_term; + sigaction(SIGTERM, &sa, NULL); + sigaction(SIGINT, &sa, NULL); + + sa.sa_handler = sig_hup; + sigaction(SIGHUP, &sa, NULL); + + sigfillset(&sigs); + sigdelset(&sigs, SIGCHLD); + sigdelset(&sigs, SIGPIPE); + sigdelset(&sigs, SIGTERM); + sigdelset(&sigs, SIGINT); + sigdelset(&sigs, SIGHUP); + + p.fd = sk; + p.events = POLLIN | POLLERR | POLLHUP; + + while (!__io_canceled) { + p.revents = 0; + if (ppoll(&p, 1, NULL, &sigs) < 1) + continue; + + len = read(sk, buf, sizeof(buf)); + if (len < 0) + break; + } + + printf("Disconnected\n"); + + ioctl(fd, UI_DEV_DESTROY); + + close(fd); + close(sk); + + return 0; +} |