aboutsummaryrefslogtreecommitdiffstats
path: root/kbd.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2016-03-30 15:56:45 +0200
committerGerd Hoffmann <kraxel@redhat.com>2016-03-30 15:56:45 +0200
commit23c102eb5272d3c2199cb5d952c3ad4b15a03cf6 (patch)
treec6a73d39c0ca4ac3c11dc531c543f64dc5f7185f /kbd.c
parent25441348c4a28fd0821fe7a173e3c6cc166deb16 (diff)
downloadfbida-23c102eb5272d3c2199cb5d952c3ad4b15a03cf6.tar.gz
fbpdf
Diffstat (limited to 'kbd.c')
-rw-r--r--kbd.c71
1 files changed, 45 insertions, 26 deletions
diff --git a/kbd.c b/kbd.c
index d5f0191..b788607 100644
--- a/kbd.c
+++ b/kbd.c
@@ -74,31 +74,6 @@ static struct termctrl termctrl[] = {
{ .seq = "Y", .code = KEY_Y, .mod = KEY_MOD_SHIFT },
{ .seq = "Z", .code = KEY_Z, .mod = KEY_MOD_SHIFT },
- { .seq = "0", .code = KEY_0, },
- { .seq = "1", .code = KEY_1, },
- { .seq = "2", .code = KEY_2, },
- { .seq = "3", .code = KEY_3, },
- { .seq = "4", .code = KEY_4, },
- { .seq = "5", .code = KEY_5, },
- { .seq = "6", .code = KEY_6, },
- { .seq = "7", .code = KEY_7, },
- { .seq = "8", .code = KEY_8, },
- { .seq = "9", .code = KEY_9, },
-
- { .seq = "\x1b[A", .code = KEY_UP },
- { .seq = "\x1b[B", .code = KEY_DOWN },
- { .seq = "\x1b[C", .code = KEY_RIGHT },
- { .seq = "\x1b[D", .code = KEY_LEFT },
- { .seq = "\x1b[F", .code = KEY_END },
- { .seq = "\x1b[H", .code = KEY_HOME },
-
- { .seq = "\x1b[1~", .code = KEY_HOME },
- { .seq = "\x1b[2~", .code = KEY_INSERT },
- { .seq = "\x1b[3~", .code = KEY_DELETE },
- { .seq = "\x1b[4~", .code = KEY_END },
- { .seq = "\x1b[5~", .code = KEY_PAGEUP },
- { .seq = "\x1b[6~", .code = KEY_PAGEDOWN },
-
{ .seq = "\x01", .code = KEY_A, .mod = KEY_MOD_CTRL },
{ .seq = "\x02", .code = KEY_B, .mod = KEY_MOD_CTRL },
{ .seq = "\x03", .code = KEY_C, .mod = KEY_MOD_CTRL },
@@ -125,7 +100,36 @@ static struct termctrl termctrl[] = {
{ .seq = "\x18", .code = KEY_X, .mod = KEY_MOD_CTRL },
{ .seq = "\x19", .code = KEY_Y, .mod = KEY_MOD_CTRL },
{ .seq = "\x1a", .code = KEY_Z, .mod = KEY_MOD_CTRL },
- { .seq = "\x1b", .code = KEY_ESC },
+
+ { .seq = "0", .code = KEY_0 },
+ { .seq = "1", .code = KEY_1 },
+ { .seq = "2", .code = KEY_2 },
+ { .seq = "3", .code = KEY_3 },
+ { .seq = "4", .code = KEY_4 },
+ { .seq = "5", .code = KEY_5 },
+ { .seq = "6", .code = KEY_6 },
+ { .seq = "7", .code = KEY_7 },
+ { .seq = "8", .code = KEY_8 },
+ { .seq = "9", .code = KEY_9 },
+
+ { .seq = " ", .code = KEY_SPACE },
+ { .seq = "\x1b", .code = KEY_ESC },
+ { .seq = "+", .code = KEY_KPPLUS },
+ { .seq = "-", .code = KEY_KPMINUS },
+
+ { .seq = "\x1b[A", .code = KEY_UP },
+ { .seq = "\x1b[B", .code = KEY_DOWN },
+ { .seq = "\x1b[C", .code = KEY_RIGHT },
+ { .seq = "\x1b[D", .code = KEY_LEFT },
+ { .seq = "\x1b[F", .code = KEY_END },
+ { .seq = "\x1b[H", .code = KEY_HOME },
+
+ { .seq = "\x1b[1~", .code = KEY_HOME },
+ { .seq = "\x1b[2~", .code = KEY_INSERT },
+ { .seq = "\x1b[3~", .code = KEY_DELETE },
+ { .seq = "\x1b[4~", .code = KEY_END },
+ { .seq = "\x1b[5~", .code = KEY_PAGEUP },
+ { .seq = "\x1b[6~", .code = KEY_PAGEDOWN },
{ /* EOF */ }
};
@@ -144,6 +148,21 @@ uint32_t kbd_parse(const char *key, uint32_t *mod)
return KEY_RESERVED;
}
+int kbd_wait(int timeout)
+{
+ struct timeval limit;
+ fd_set set;
+ int rc;
+
+ FD_ZERO(&set);
+ FD_SET(STDIN_FILENO, &set);
+ limit.tv_sec = timeout;
+ limit.tv_usec = 0;
+ rc = select(STDIN_FILENO + 1, &set, NULL, NULL,
+ timeout ? &limit : NULL);
+ return rc;
+}
+
/* ---------------------------------------------------------------------- */
struct termios saved_attributes;