Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/usr.sbin/bluetooth/bthidd/bthidd.h
103755 views
1
/*
2
* bthidd.h
3
*/
4
5
/*-
6
* SPDX-License-Identifier: BSD-2-Clause
7
*
8
* Copyright (c) 2006 Maksim Yevmenkin <[email protected]>
9
* All rights reserved.
10
*
11
* Redistribution and use in source and binary forms, with or without
12
* modification, are permitted provided that the following conditions
13
* are met:
14
* 1. Redistributions of source code must retain the above copyright
15
* notice, this list of conditions and the following disclaimer.
16
* 2. Redistributions in binary form must reproduce the above copyright
17
* notice, this list of conditions and the following disclaimer in the
18
* documentation and/or other materials provided with the distribution.
19
*
20
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30
* SUCH DAMAGE.
31
*
32
* $Id: bthidd.h,v 1.7 2006/09/07 21:06:53 max Exp $
33
*/
34
35
#ifndef _BTHIDD_H_
36
#define _BTHIDD_H_ 1
37
38
#define BTHIDD_IDENT "bthidd"
39
#define BTHIDD_PIDFILE "/var/run/" BTHIDD_IDENT ".pid"
40
41
struct bthid_session;
42
43
struct bthid_server
44
{
45
bdaddr_t bdaddr; /* local bdaddr */
46
int32_t cons; /* /dev/consolectl */
47
int32_t ctrl; /* control channel (listen) */
48
int32_t intr; /* intr. channel (listen) */
49
int32_t maxfd; /* max fd in sets */
50
int32_t uinput; /* enable evdev support */
51
fd_set rfdset; /* read descriptor set */
52
fd_set wfdset; /* write descriptor set */
53
LIST_HEAD(, bthid_session) sessions;
54
};
55
56
typedef struct bthid_server bthid_server_t;
57
typedef struct bthid_server * bthid_server_p;
58
59
struct bthid_session
60
{
61
bthid_server_p srv; /* pointer back to server */
62
int32_t ctrl; /* control channel */
63
int32_t intr; /* interrupt channel */
64
int32_t vkbd; /* virual keyboard */
65
void *ctx; /* product specific dev state */
66
int32_t ukbd; /* evdev user input */
67
int32_t umouse;/* evdev user input */
68
int32_t obutt; /* previous mouse buttons */
69
int32_t consk; /* last consumer page key */
70
bdaddr_t bdaddr;/* remote bdaddr */
71
uint16_t state; /* session state */
72
#define CLOSED 0
73
#define W4CTRL 1
74
#define W4INTR 2
75
#define OPEN 3
76
bitstr_t *keys1; /* keys map (new) */
77
bitstr_t *keys2; /* keys map (old) */
78
LIST_ENTRY(bthid_session) next; /* link to next */
79
};
80
81
typedef struct bthid_session bthid_session_t;
82
typedef struct bthid_session * bthid_session_p;
83
84
int32_t server_init (bthid_server_p srv);
85
void server_shutdown (bthid_server_p srv);
86
int32_t server_do (bthid_server_p srv);
87
88
int32_t client_rescan (bthid_server_p srv);
89
int32_t client_connect (bthid_server_p srv, int fd);
90
91
bthid_session_p session_open (bthid_server_p srv, hid_device_p const d);
92
bthid_session_p session_by_bdaddr(bthid_server_p srv, bdaddr_p bdaddr);
93
bthid_session_p session_by_fd (bthid_server_p srv, int32_t fd);
94
int32_t session_run (bthid_session_p s);
95
void session_close (bthid_session_p s);
96
97
void hid_initialise (bthid_session_p s);
98
int32_t hid_control (bthid_session_p s, uint8_t *data, int32_t len);
99
int32_t hid_interrupt (bthid_session_p s, uint8_t *data, int32_t len);
100
101
#endif /* ndef _BTHIDD_H_ */
102
103
104