1 /*
2 
3 Copyright (C) 2015-2018 Night Dive Studios, LLC.
4 
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, either version 3 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 /*
20  * $Source: r:/prj/lib/src/input/test/RCS/kbtest.c $
21  * $Revision: 1.5 $
22  * $Author: kaboom $
23  * $Date: 1994/08/15 18:11:40 $
24  */
25 
26 #include <stdio.h>
27 #include <stdlib.h>
28 
29 #include "lg.h"
30 #include "kb.h"
31 
show_keyarray(void)32 void show_keyarray(void)
33 {
34 /*
35    int i,j;
36 
37    for (i=0; i<8; i++) {
38       for (j=0; j<32; j++)
39          if (kb_state(i*32+j)==KBS_DOWN)
40             mput('*', j*2, i*2);
41          else
42             mput(' ', j*2, i*2);
43    }
44 */
45 	printf("   %d\n", kb_state(0x31));
46 }
47 
main()48 main()
49 {
50    int n=0;
51    kbs_event event;
52 
53    printf("Start typing...\n");
54    kb_startup(NULL);
55 //   kb_set_state(0x01,KBA_REPEAT);
56 //   kb_set_state(0x17,KBA_REPEAT);
57 //   kb_set_state(0x54,KBA_SIGNAL);
58    show_keyarray();
59    while (n < 10)
60    {
61       event = kb_next();
62       if (event.code!=0xff)
63       {
64          printf("key %x %s",event.code,(event.state==KBS_UP)?"up":"down");
65          show_keyarray();
66          n++;
67       }
68       else
69       {
70 //         event.state = 0;
71 //         event.code = 1;
72 //         kb_generate(event);
73       }
74    }
75 
76    kb_shutdown();
77 }
78