dmi: check both the AC and ID flags at the same time
[syslinux.git] / com32 / samples / keytest.c
blob09c041a105f9e8c36bbd3febc4cd85d9114aa1e0
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2004-2008 H. Peter Anvin - All Rights Reserved
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 * Boston MA 02111-1307, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
14 * keytest.c
16 * Test the key parsing library
19 #include <string.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <time.h>
23 #include <sys/times.h>
25 #include <consoles.h> /* Provided by libutil */
26 #include <getkey.h>
28 static void cooked_keys(void)
30 int key;
32 printf("[cooked]");
34 for (;;) {
35 key = get_key(stdin, 0);
37 if (key == 0x03) {
38 printf("[done]\n");
39 exit(0);
40 } else if (key == '!')
41 return;
43 if (key >= 0x20 && key < 0x100) {
44 putchar(key);
45 } else {
46 printf("[%s,%04x]", key_code_to_name(key), key);
51 static void raw_keys(void)
53 int key;
55 printf("[raw]");
57 for (;;) {
58 key = getc(stdin);
60 if (key == 0x03) {
61 printf("[done]\n");
62 exit(0);
63 } else if (key == '!')
64 return;
66 if (key != EOF)
67 printf("<%02x>", key);
71 int main(void)
73 console_ansi_raw();
75 printf("CLK_TCK = %d\n", (int)CLK_TCK);
76 printf("Press keys, end with Ctrl-C, ! changes from cooked to raw\n");
78 for (;;) {
79 cooked_keys();
80 raw_keys();