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