1128080Semax/* 2128080Semax * bthidd.h 3162128Semax */ 4162128Semax 5162128Semax/*- 6162128Semax * Copyright (c) 2006 Maksim Yevmenkin <m_evmenkin@yahoo.com> 7128080Semax * All rights reserved. 8128080Semax * 9128080Semax * Redistribution and use in source and binary forms, with or without 10128080Semax * modification, are permitted provided that the following conditions 11128080Semax * are met: 12128080Semax * 1. Redistributions of source code must retain the above copyright 13128080Semax * notice, this list of conditions and the following disclaimer. 14128080Semax * 2. Redistributions in binary form must reproduce the above copyright 15128080Semax * notice, this list of conditions and the following disclaimer in the 16128080Semax * documentation and/or other materials provided with the distribution. 17128080Semax * 18128080Semax * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19128080Semax * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20128080Semax * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21128080Semax * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22128080Semax * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23128080Semax * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24128080Semax * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25128080Semax * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26128080Semax * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27128080Semax * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28128080Semax * SUCH DAMAGE. 29128080Semax * 30162128Semax * $Id: bthidd.h,v 1.7 2006/09/07 21:06:53 max Exp $ 31128080Semax * $FreeBSD$ 32128080Semax */ 33128080Semax 34128080Semax#ifndef _BTHIDD_H_ 35128080Semax#define _BTHIDD_H_ 1 36128080Semax 37128080Semax#define BTHIDD_IDENT "bthidd" 38128080Semax#define BTHIDD_PIDFILE "/var/run/" BTHIDD_IDENT ".pid" 39128080Semax 40128080Semaxstruct bthid_session; 41128080Semax 42128080Semaxstruct bthid_server 43128080Semax{ 44137868Semax bdaddr_t bdaddr; /* local bdaddr */ 45162128Semax int32_t cons; /* /dev/consolectl */ 46162128Semax int32_t ctrl; /* control channel (listen) */ 47162128Semax int32_t intr; /* intr. channel (listen) */ 48162128Semax int32_t maxfd; /* max fd in sets */ 49137868Semax fd_set rfdset; /* read descriptor set */ 50137868Semax fd_set wfdset; /* write descriptor set */ 51137868Semax LIST_HEAD(, bthid_session) sessions; 52128080Semax}; 53128080Semax 54128080Semaxtypedef struct bthid_server bthid_server_t; 55128080Semaxtypedef struct bthid_server * bthid_server_p; 56128080Semax 57128080Semaxstruct bthid_session 58128080Semax{ 59137868Semax bthid_server_p srv; /* pointer back to server */ 60162128Semax int32_t ctrl; /* control channel */ 61162128Semax int32_t intr; /* interrupt channel */ 62162128Semax int32_t vkbd; /* virual keyboard */ 63137868Semax bdaddr_t bdaddr;/* remote bdaddr */ 64162128Semax uint16_t state; /* session state */ 65128080Semax#define CLOSED 0 66128080Semax#define W4CTRL 1 67128080Semax#define W4INTR 2 68128080Semax#define OPEN 3 69162128Semax bitstr_t *keys1; /* keys map (new) */ 70162128Semax bitstr_t *keys2; /* keys map (old) */ 71137868Semax LIST_ENTRY(bthid_session) next; /* link to next */ 72128080Semax}; 73128080Semax 74128080Semaxtypedef struct bthid_session bthid_session_t; 75128080Semaxtypedef struct bthid_session * bthid_session_p; 76128080Semax 77162128Semaxint32_t server_init (bthid_server_p srv); 78128080Semaxvoid server_shutdown (bthid_server_p srv); 79162128Semaxint32_t server_do (bthid_server_p srv); 80128080Semax 81162128Semaxint32_t client_rescan (bthid_server_p srv); 82162128Semaxint32_t client_connect (bthid_server_p srv, int fd); 83128080Semax 84162128Semaxbthid_session_p session_open (bthid_server_p srv, hid_device_p const d); 85128080Semaxbthid_session_p session_by_bdaddr(bthid_server_p srv, bdaddr_p bdaddr); 86162128Semaxbthid_session_p session_by_fd (bthid_server_p srv, int32_t fd); 87128080Semaxvoid session_close (bthid_session_p s); 88128080Semax 89162128Semaxint32_t hid_control (bthid_session_p s, uint8_t *data, int32_t len); 90162128Semaxint32_t hid_interrupt (bthid_session_p s, uint8_t *data, int32_t len); 91128080Semax 92128080Semax#endif /* ndef _BTHIDD_H_ */ 93128080Semax 94