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