xref: /titanic_52/usr/src/uts/common/io/kbtrans/kbtrans_lower.h (revision 2b24ab6b3865caeede9eeb9db6b83e1d89dcd1ea)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1999 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef _KBTRANS_LOWER_H
28 #define	_KBTRANS_LOWER_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * This structure describes the state of the keyboard.
38  * and also specifies the keytables.
39  */
40 struct kbtrans_lower {
41 	/* Generating pre-4.1 events? */
42 	int	kbtrans_compat;
43 
44 	/* key to repeat in TR_ASCII mode */
45 	kbtrans_key_t kbtrans_repeatkey;
46 
47 	/* Current state of the LED's */
48 	uchar_t	kbtrans_led_state;
49 
50 	/* Pointer to keyboard maps */
51 	struct  keyboard *kbtrans_keyboard;
52 
53 	/* Current shift state */
54 	uint_t   kbtrans_shiftmask;
55 
56 	uchar_t  kbtrans_state;		/* compose state */
57 	uint_t   kbtrans_buckybits;	/* current buckybits */
58 	uint_t   kbtrans_togglemask;   	/* Toggle shifts state */
59 	ushort_t kbtrans_compose_key;	/* first compose key */
60 	ushort_t kbtrans_fltaccent_entry; /* floating accent keymap entry */
61 
62 	/*
63 	 * Various mapping tables.
64 	 */
65 	signed char			*kbtrans_compose_map;
66 	struct compose_sequence_t	*kbtrans_compose_table;
67 	struct fltaccent_sequence_t	*kbtrans_fltaccent_table;
68 
69 	/* Strings sent by various keys */
70 	char				(*kbtrans_keystringtab)[KTAB_STRLEN];
71 
72 	/* Num lock table */
73 	unsigned char			*kbtrans_numlock_table;
74 
75 	/*
76 	 * The kbtrans structure specifies the state of the
77 	 * stream.
78 	 */
79 	struct kbtrans			*kbtrans_upper;
80 };
81 
82 
83 /*
84  * Different functions must be called based upon the type of translation
85  * mode.  Each translation mode such as TR_ASCII, TR_EVENT, TR_NONE, etc.
86  * has an instance of this structure.
87  */
88 struct keyboard_callback {
89 
90 	/*
91 	 * Raw (untranslated) keypress
92 	 */
93 	void (*kc_keypressed_raw)(struct kbtrans *, kbtrans_key_t);
94 
95 	/*
96 	 * Raw (untranslated) keyrelease
97 	 */
98 	void (*kc_keyreleased_raw)(struct kbtrans *, kbtrans_key_t);
99 
100 	/*
101 	 * Keypress
102 	 */
103 	void (*kc_keypressed)(struct kbtrans *, uint_t, kbtrans_key_t, uint_t);
104 
105 	/*
106 	 * Keyrelease
107 	 */
108 	void (*kc_keyreleased)(struct kbtrans *, kbtrans_key_t);
109 
110 	/*
111 	 * Initialize a repeat character
112 	 */
113 	void (*kc_setup_repeat)(struct kbtrans *, uint_t, kbtrans_key_t);
114 
115 	/*
116 	 * Cancel a repeat character
117 	 */
118 	void (*kc_cancel_repeat)(struct kbtrans *);
119 
120 	/*
121 	 * Process the led state change
122 	 */
123 	void (*kc_setled)(struct kbtrans *);
124 };
125 
126 /*
127  * Process a scancode.  This routine will call the functions in
128  * keyboard_callback to handle the translated key.
129  */
130 void
131 kbtrans_processkey(
132 	struct kbtrans_lower *lower,
133 	struct keyboard_callback *cb,
134 	kbtrans_key_t key,
135 	enum keystate state
136 );
137 
138 /*
139  * This routine finds the entry for the specified keycode based on the
140  * specified shift mask.
141  */
142 unsigned short *
143 kbtrans_find_entry(
144 	struct kbtrans_lower	*lower,
145 	uint_t mask,
146 	kbtrans_key_t
147 );
148 
149 /*
150  * Debug printing
151  */
152 #ifndef DPRINTF
153 #ifdef DEBUG
154 #define	DPRINTF(l, m, args) \
155 	(((l) >= kbtrans_errlevel) && ((m) & kbtrans_errmask) ? \
156 		kbtrans_dprintf args :                          \
157 		(void) 0)
158 #else
159 #define	DPRINTF(l, m, args)
160 #endif
161 #endif
162 
163 /*
164  * Severity levels for printing
165  */
166 #define	PRINT_L0	0	/* print every message */
167 #define	PRINT_L1	1	/* debug */
168 #define	PRINT_L2	2	/* minor errors */
169 #define	PRINT_L3	3	/* major errors */
170 #define	PRINT_L4	4	/* catastophic errors */
171 
172 /*
173  * Masks
174  */
175 
176 #define	PRINT_MASK_ALL		0xFFFFFFFF
177 #define	PRINT_MASK_OPEN		0x00000002
178 #define	PRINT_MASK_PACKET	0x00000008
179 #define	PRINT_MASK_CLOSE	0x00000004
180 
181 #ifdef DEBUG
182 extern int	kbtrans_errmask;
183 extern int	kbtrans_errlevel;
184 extern void	kbtrans_dprintf(void *, const char *fmt, ...);
185 #endif
186 
187 #ifdef __cplusplus
188 }
189 #endif
190 
191 #endif	/* _KBTRANS_LOWER_H */
192