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