2 * readkey.c - read keystrokes and decode standard escape sequences
4 * Partly based on busybox vi
6 * Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
8 * See file CREDITS for list of people who contributed to this
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2
13 * as published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <linux/ctype.h>
34 static const struct esc_cmds esccmds
[] = {
35 {"OA", KEY_UP
}, // cursor key Up
36 {"OB", KEY_DOWN
}, // cursor key Down
37 {"OC", KEY_RIGHT
}, // Cursor Key Right
38 {"OD", KEY_LEFT
}, // cursor key Left
39 {"OH", KEY_HOME
}, // Cursor Key Home
40 {"OF", KEY_END
}, // Cursor Key End
41 {"[A", KEY_UP
}, // cursor key Up
42 {"[B", KEY_DOWN
}, // cursor key Down
43 {"[C", KEY_RIGHT
}, // Cursor Key Right
44 {"[D", KEY_LEFT
}, // cursor key Left
45 {"[H", KEY_HOME
}, // Cursor Key Home
46 {"[F", KEY_END
}, // Cursor Key End
47 {"[1~", KEY_HOME
}, // Cursor Key Home
48 {"[2~", KEY_INSERT
}, // Cursor Key Insert
49 {"[3~", KEY_DEL
}, // Cursor Key Delete
50 {"[4~", KEY_END
}, // Cursor Key End
51 {"[5~", KEY_PAGEUP
}, // Cursor Key Page Up
52 {"[6~", KEY_PAGEDOWN
},// Cursor Key Page Down
65 if (isdigit(esc
[1])) {
73 for (i
= 0; i
< ARRAY_SIZE(esccmds
); i
++){
74 if (!strcmp(esc
, esccmds
[i
].seq
))
75 return esccmds
[i
].val
;
81 EXPORT_SYMBOL(read_key
);