summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/io/kbtrans/kbtrans_lower.h
blob: 14157a7816a706ec202aa7ef5f61d4084eea0f63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 1999 by Sun Microsystems, Inc.
 * All rights reserved.
 */

#ifndef _KBTRANS_LOWER_H
#define	_KBTRANS_LOWER_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#ifdef __cplusplus
extern "C" {
#endif

/*
 * This structure describes the state of the keyboard.
 * and also specifies the keytables.
 */
struct kbtrans_lower {
	/* Generating pre-4.1 events? */
	int	kbtrans_compat;

	/* key to repeat in TR_ASCII mode */
	kbtrans_key_t kbtrans_repeatkey;

	/* Current state of the LED's */
	uchar_t	kbtrans_led_state;

	/* Pointer to keyboard maps */
	struct  keyboard *kbtrans_keyboard;

	/* Current shift state */
	uint_t   kbtrans_shiftmask;

	uchar_t  kbtrans_state;		/* compose state */
	uint_t   kbtrans_buckybits;	/* current buckybits */
	uint_t   kbtrans_togglemask;   	/* Toggle shifts state */
	ushort_t kbtrans_compose_key;	/* first compose key */
	ushort_t kbtrans_fltaccent_entry; /* floating accent keymap entry */

	/*
	 * Various mapping tables.
	 */
	signed char			*kbtrans_compose_map;
	struct compose_sequence_t	*kbtrans_compose_table;
	struct fltaccent_sequence_t	*kbtrans_fltaccent_table;

	/* Strings sent by various keys */
	char				(*kbtrans_keystringtab)[KTAB_STRLEN];

	/* Num lock table */
	unsigned char			*kbtrans_numlock_table;

	/*
	 * The kbtrans structure specifies the state of the
	 * stream.
	 */
	struct kbtrans			*kbtrans_upper;
};


/*
 * Different functions must be called based upon the type of translation
 * mode.  Each translation mode such as TR_ASCII, TR_EVENT, TR_NONE, etc.
 * has an instance of this structure.
 */
struct keyboard_callback {

	/*
	 * Raw (untranslated) keypress
	 */
	void (*kc_keypressed_raw)(struct kbtrans *, kbtrans_key_t);

	/*
	 * Raw (untranslated) keyrelease
	 */
	void (*kc_keyreleased_raw)(struct kbtrans *, kbtrans_key_t);

	/*
	 * Keypress
	 */
	void (*kc_keypressed)(struct kbtrans *, uint_t, kbtrans_key_t, uint_t);

	/*
	 * Keyrelease
	 */
	void (*kc_keyreleased)(struct kbtrans *, kbtrans_key_t);

	/*
	 * Initialize a repeat character
	 */
	void (*kc_setup_repeat)(struct kbtrans *, uint_t, kbtrans_key_t);

	/*
	 * Cancel a repeat character
	 */
	void (*kc_cancel_repeat)(struct kbtrans *);

	/*
	 * Process the led state change
	 */
	void (*kc_setled)(struct kbtrans *);
};

/*
 * Process a scancode.  This routine will call the functions in
 * keyboard_callback to handle the translated key.
 */
void
kbtrans_processkey(
	struct kbtrans_lower *lower,
	struct keyboard_callback *cb,
	kbtrans_key_t key,
	enum keystate state
);

/*
 * This routine finds the entry for the specified keycode based on the
 * specified shift mask.
 */
unsigned short *
kbtrans_find_entry(
	struct kbtrans_lower	*lower,
	uint_t mask,
	kbtrans_key_t
);

/*
 * Debug printing
 */
#ifndef DPRINTF
#ifdef DEBUG
#define	DPRINTF(l, m, args) \
	(((l) >= kbtrans_errlevel) && ((m) & kbtrans_errmask) ? \
		kbtrans_dprintf args :                          \
		(void) 0)
#else
#define	DPRINTF(l, m, args)
#endif
#endif

/*
 * Severity levels for printing
 */
#define	PRINT_L0	0	/* print every message */
#define	PRINT_L1	1	/* debug */
#define	PRINT_L2	2	/* minor errors */
#define	PRINT_L3	3	/* major errors */
#define	PRINT_L4	4	/* catastophic errors */

/*
 * Masks
 */

#define	PRINT_MASK_ALL		0xFFFFFFFF
#define	PRINT_MASK_OPEN		0x00000002
#define	PRINT_MASK_PACKET	0x00000008
#define	PRINT_MASK_CLOSE	0x00000004

#ifdef DEBUG
extern int	kbtrans_errmask;
extern int	kbtrans_errlevel;
extern void	kbtrans_dprintf(void *, const char *fmt, ...);
#endif

#ifdef __cplusplus
}
#endif

#endif	/* _KBTRANS_LOWER_H */