hidkbdsc.h revision 1.1.4.2 1 1.1.4.2 perseant /* $OpenBSD: hidkbdsc.h,v 1.3 2022/11/09 10:05:18 robert Exp $ */
2 1.1.4.2 perseant /* $NetBSD: hidkbdsc.h,v 1.1.4.2 2025/08/02 05:56:38 perseant Exp $ */
3 1.1.4.2 perseant
4 1.1.4.2 perseant /*
5 1.1.4.2 perseant * Copyright (c) 1998 The NetBSD Foundation, Inc.
6 1.1.4.2 perseant * All rights reserved.
7 1.1.4.2 perseant *
8 1.1.4.2 perseant * This code is derived from software contributed to The NetBSD Foundation
9 1.1.4.2 perseant * by Lennart Augustsson (lennart (at) augustsson.net) at
10 1.1.4.2 perseant * Carlstedt Research & Technology.
11 1.1.4.2 perseant *
12 1.1.4.2 perseant * Redistribution and use in source and binary forms, with or without
13 1.1.4.2 perseant * modification, are permitted provided that the following conditions
14 1.1.4.2 perseant * are met:
15 1.1.4.2 perseant * 1. Redistributions of source code must retain the above copyright
16 1.1.4.2 perseant * notice, this list of conditions and the following disclaimer.
17 1.1.4.2 perseant * 2. Redistributions in binary form must reproduce the above copyright
18 1.1.4.2 perseant * notice, this list of conditions and the following disclaimer in the
19 1.1.4.2 perseant * documentation and/or other materials provided with the distribution.
20 1.1.4.2 perseant *
21 1.1.4.2 perseant * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22 1.1.4.2 perseant * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 1.1.4.2 perseant * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 1.1.4.2 perseant * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25 1.1.4.2 perseant * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 1.1.4.2 perseant * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 1.1.4.2 perseant * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 1.1.4.2 perseant * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 1.1.4.2 perseant * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 1.1.4.2 perseant * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 1.1.4.2 perseant * POSSIBILITY OF SUCH DAMAGE.
32 1.1.4.2 perseant */
33 1.1.4.2 perseant
34 1.1.4.2 perseant #include "opt_wsdisplay_compat.h"
35 1.1.4.2 perseant
36 1.1.4.2 perseant #define MAXKEYCODE 6
37 1.1.4.2 perseant #define MAXVARS 128
38 1.1.4.2 perseant
39 1.1.4.2 perseant #define MAXKEYS (MAXVARS+2*MAXKEYCODE)
40 1.1.4.2 perseant
41 1.1.4.2 perseant /* quirks */
42 1.1.4.2 perseant #define HIDKBD_SPUR_BUT_UP 0x001 /* spurious button up events */
43 1.1.4.2 perseant
44 1.1.4.2 perseant struct hidkbd_variable {
45 1.1.4.2 perseant struct hid_location loc;
46 1.1.4.2 perseant u_int8_t mask;
47 1.1.4.2 perseant u_int8_t key;
48 1.1.4.2 perseant };
49 1.1.4.2 perseant
50 1.1.4.2 perseant struct hidkbd_data {
51 1.1.4.2 perseant u_int8_t keycode[MAXKEYCODE];
52 1.1.4.2 perseant u_int8_t var[MAXVARS];
53 1.1.4.2 perseant };
54 1.1.4.2 perseant
55 1.1.4.2 perseant struct hidkbd {
56 1.1.4.2 perseant /* stored data */
57 1.1.4.2 perseant struct hidkbd_data sc_ndata;
58 1.1.4.2 perseant struct hidkbd_data sc_odata;
59 1.1.4.2 perseant
60 1.1.4.2 perseant /* input reports */
61 1.1.4.2 perseant u_int sc_nvar;
62 1.1.4.2 perseant struct hidkbd_variable *sc_var;
63 1.1.4.2 perseant
64 1.1.4.2 perseant struct hid_location sc_keycodeloc;
65 1.1.4.2 perseant u_int sc_nkeycode;
66 1.1.4.2 perseant
67 1.1.4.2 perseant /* output reports */
68 1.1.4.2 perseant struct hid_location sc_numloc;
69 1.1.4.2 perseant struct hid_location sc_capsloc;
70 1.1.4.2 perseant struct hid_location sc_scroloc;
71 1.1.4.2 perseant struct hid_location sc_compose;
72 1.1.4.2 perseant int sc_leds;
73 1.1.4.2 perseant
74 1.1.4.2 perseant /* optional extra input source used by sc_munge */
75 1.1.4.2 perseant struct hid_location sc_fn;
76 1.1.4.2 perseant
77 1.1.4.2 perseant /* state information */
78 1.1.4.2 perseant device_t sc_device;
79 1.1.4.2 perseant device_t sc_wskbddev;
80 1.1.4.2 perseant char sc_enabled;
81 1.1.4.2 perseant
82 1.1.4.2 perseant char sc_console_keyboard; /* we are the console keyboard */
83 1.1.4.2 perseant
84 1.1.4.2 perseant char sc_debounce; /* for quirk handling */
85 1.1.4.2 perseant callout_t sc_delay; /* for quirk handling */
86 1.1.4.2 perseant struct hidkbd_data sc_data; /* for quirk handling */
87 1.1.4.2 perseant
88 1.1.4.2 perseant /* key repeat logic */
89 1.1.4.2 perseant #if defined(WSDISPLAY_COMPAT_RAWKBD)
90 1.1.4.2 perseant int sc_rawkbd;
91 1.1.4.2 perseant #endif /* defined(WSDISPLAY_COMPAT_RAWKBD) */
92 1.1.4.2 perseant
93 1.1.4.2 perseant int sc_polling;
94 1.1.4.2 perseant int sc_npollchar;
95 1.1.4.2 perseant u_int16_t sc_pollchars[MAXKEYS];
96 1.1.4.2 perseant
97 1.1.4.2 perseant void (*sc_munge)(void *, uint8_t *, u_int);
98 1.1.4.2 perseant };
99 1.1.4.2 perseant
100 1.1.4.2 perseant struct hidkbd_translation {
101 1.1.4.2 perseant uint8_t original;
102 1.1.4.2 perseant uint8_t translation;
103 1.1.4.2 perseant };
104 1.1.4.2 perseant
105 1.1.4.2 perseant int hidkbd_attach(struct device *, struct hidkbd *, int, uint32_t,
106 1.1.4.2 perseant int, void *, int);
107 1.1.4.2 perseant void hidkbd_attach_wskbd(struct hidkbd *, kbd_t,
108 1.1.4.2 perseant const struct wskbd_accessops *);
109 1.1.4.2 perseant void hidkbd_bell(u_int, u_int, u_int, int);
110 1.1.4.2 perseant void hidkbd_cngetc(struct hidkbd *, u_int *, int *);
111 1.1.4.2 perseant int hidkbd_detach(struct hidkbd *, int);
112 1.1.4.2 perseant int hidkbd_enable(struct hidkbd *, int);
113 1.1.4.2 perseant void hidkbd_input(struct hidkbd *, uint8_t *, u_int);
114 1.1.4.2 perseant int hidkbd_ioctl(struct hidkbd *, u_long, void *, int, lwp_t *);
115 1.1.4.2 perseant int hidkbd_set_leds(struct hidkbd *, int, uint8_t *);
116 1.1.4.2 perseant uint8_t hidkbd_translate(const struct hidkbd_translation *, size_t, uint8_t);
117 1.1.4.2 perseant void hidkbd_apple_munge(void *, uint8_t *, u_int);
118 1.1.4.2 perseant void hidkbd_apple_tb_munge(void *, uint8_t *, u_int);
119 1.1.4.2 perseant void hidkbd_apple_iso_munge(void *, uint8_t *, u_int);
120 1.1.4.2 perseant void hidkbd_apple_mba_munge(void *, uint8_t *, u_int);
121 1.1.4.2 perseant void hidkbd_apple_iso_mba_munge(void *, uint8_t *, u_int);
122 1.1.4.2 perseant
123 1.1.4.2 perseant extern int hidkbd_is_console;
124