Path: blob/main/usr.sbin/bluetooth/bthidd/bthidd.h
103755 views
/*1* bthidd.h2*/34/*-5* SPDX-License-Identifier: BSD-2-Clause6*7* Copyright (c) 2006 Maksim Yevmenkin <[email protected]>8* All rights reserved.9*10* Redistribution and use in source and binary forms, with or without11* modification, are permitted provided that the following conditions12* are met:13* 1. Redistributions of source code must retain the above copyright14* notice, this list of conditions and the following disclaimer.15* 2. Redistributions in binary form must reproduce the above copyright16* notice, this list of conditions and the following disclaimer in the17* documentation and/or other materials provided with the distribution.18*19* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND20* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE21* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE22* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE23* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL24* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS25* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)26* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT27* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY28* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF29* SUCH DAMAGE.30*31* $Id: bthidd.h,v 1.7 2006/09/07 21:06:53 max Exp $32*/3334#ifndef _BTHIDD_H_35#define _BTHIDD_H_ 13637#define BTHIDD_IDENT "bthidd"38#define BTHIDD_PIDFILE "/var/run/" BTHIDD_IDENT ".pid"3940struct bthid_session;4142struct bthid_server43{44bdaddr_t bdaddr; /* local bdaddr */45int32_t cons; /* /dev/consolectl */46int32_t ctrl; /* control channel (listen) */47int32_t intr; /* intr. channel (listen) */48int32_t maxfd; /* max fd in sets */49int32_t uinput; /* enable evdev support */50fd_set rfdset; /* read descriptor set */51fd_set wfdset; /* write descriptor set */52LIST_HEAD(, bthid_session) sessions;53};5455typedef struct bthid_server bthid_server_t;56typedef struct bthid_server * bthid_server_p;5758struct bthid_session59{60bthid_server_p srv; /* pointer back to server */61int32_t ctrl; /* control channel */62int32_t intr; /* interrupt channel */63int32_t vkbd; /* virual keyboard */64void *ctx; /* product specific dev state */65int32_t ukbd; /* evdev user input */66int32_t umouse;/* evdev user input */67int32_t obutt; /* previous mouse buttons */68int32_t consk; /* last consumer page key */69bdaddr_t bdaddr;/* remote bdaddr */70uint16_t state; /* session state */71#define CLOSED 072#define W4CTRL 173#define W4INTR 274#define OPEN 375bitstr_t *keys1; /* keys map (new) */76bitstr_t *keys2; /* keys map (old) */77LIST_ENTRY(bthid_session) next; /* link to next */78};7980typedef struct bthid_session bthid_session_t;81typedef struct bthid_session * bthid_session_p;8283int32_t server_init (bthid_server_p srv);84void server_shutdown (bthid_server_p srv);85int32_t server_do (bthid_server_p srv);8687int32_t client_rescan (bthid_server_p srv);88int32_t client_connect (bthid_server_p srv, int fd);8990bthid_session_p session_open (bthid_server_p srv, hid_device_p const d);91bthid_session_p session_by_bdaddr(bthid_server_p srv, bdaddr_p bdaddr);92bthid_session_p session_by_fd (bthid_server_p srv, int32_t fd);93int32_t session_run (bthid_session_p s);94void session_close (bthid_session_p s);9596void hid_initialise (bthid_session_p s);97int32_t hid_control (bthid_session_p s, uint8_t *data, int32_t len);98int32_t hid_interrupt (bthid_session_p s, uint8_t *data, int32_t len);99100#endif /* ndef _BTHIDD_H_ */101102103104