1 /* $NetBSD: wsemul_vt100_keys.c,v 1.5.16.4 2005/11/10 14:08:43 skrll Exp $ */
5 * Matthias Drochner. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include <sys/cdefs.h>
30 __KERNEL_RCSID(0, "$NetBSD: wsemul_vt100_keys.c,v 1.5.16.4 2005/11/10 14:08:43 skrll Exp $");
32 #include <sys/param.h>
33 #include <sys/systm.h>
35 #include <dev/wscons/wsconsio.h>
36 #include <dev/wscons/wsdisplayvar.h>
37 #include <dev/wscons/wsksymvar.h>
38 #include <dev/wscons/wsksymdef.h>
39 #include <dev/wscons/wsemul_vt100var.h>
41 static const char *vt100_fkeys
[] = {
44 "\033[13~", /* F1-F5 normally don't send codes */
52 "\033[23~", /* VT100: ESC */
53 "\033[24~", /* VT100: BS */
54 "\033[25~", /* VT100: LF */
56 "\033[28~", /* help */
64 static const char *vt100_pfkeys
[] = {
71 static const char *vt100_numpad
[] = {
85 wsemul_vt100_translate(void *cookie
, keysym_t in
, const char **out
)
87 struct wsemul_vt100_emuldata
*edp
= cookie
;
90 if (in
>= KS_f1
&& in
<= KS_f20
) {
91 *out
= vt100_fkeys
[in
- KS_f1
];
94 if (in
>= KS_F1
&& in
<= KS_F20
) {
95 *out
= vt100_fkeys
[in
- KS_F1
];
98 if (in
>= KS_KP_F1
&& in
<= KS_KP_F4
) {
99 *out
= vt100_pfkeys
[in
- KS_KP_F1
];
102 if (edp
->flags
& VTFL_APPLKEYPAD
) {
103 if (in
>= KS_KP_0
&& in
<= KS_KP_9
) {
104 *out
= vt100_numpad
[in
- KS_KP_0
];
120 case KS_KP_Separator
:
135 c
= in
& 0xff; /* turn into ASCII */
142 *out
= vt100_fkeys
[15 - 1];
144 case KS_Execute
: /* "Do" */
145 *out
= vt100_fkeys
[16 - 1];
178 if (edp
->flags
& VTFL_APPLCURSOR
)
185 if (edp
->flags
& VTFL_APPLCURSOR
)
192 if (edp
->flags
& VTFL_APPLCURSOR
)
199 if (edp
->flags
& VTFL_APPLCURSOR
)