]> git.karo-electronics.de Git - karo-tx-redboot.git/blob - packages/services/gfx/mw/v2_0/src/drivers/kbd_bios.c
Cleanup CVS ipmorted branch
[karo-tx-redboot.git] / packages / services / gfx / mw / v2_0 / src / drivers / kbd_bios.c
1 /*
2  * Copyright (c) 1999 Greg Haerr <greg@censoft.com>
3  *
4  * Keyboard Driver, PC bios version
5  */
6 #include "device.h"
7
8 static int  KBD_Open(KBDDEVICE *pkd);
9 static void KBD_Close(void);
10 static void KBD_GetModifierInfo(int *modifiers);
11 static int  KBD_Read(MWUCHAR *buf, int *modifiers);
12 static int      KBD_Poll(void);
13
14 /* external routines in asmkbd.s*/
15 extern int kbpoll(void);
16 extern int kbread(void);
17 extern int kbflags(void);
18
19 KBDDEVICE kbddev = {
20         KBD_Open,
21         KBD_Close,
22         KBD_GetModifierInfo,
23         KBD_Read,
24         KBD_Poll
25 };
26
27 /*
28  * Open the keyboard.
29  */
30 static int
31 KBD_Open(KBDDEVICE *pkd)
32 {
33         return 1;
34
35 }
36
37 /*
38  * Close the keyboard.
39  */
40 static void
41 KBD_Close(void)
42 {
43 }
44
45 /*
46  * Return the possible modifiers for the keyboard.
47  */
48 static  void
49 KBD_GetModifierInfo(int *modifiers)
50 {
51         *modifiers = 0;                 /* no modifiers available */
52 }
53
54 /*
55  * This reads one keystroke from the keyboard, and the current state of
56  * the mode keys (ALT, SHIFT, CTRL).  Returns -1 on error, 0 if no data
57  * is ready, and 1 if data was read.  This is a non-blocking call.
58  */
59 static int
60 KBD_Read(MWUCHAR *buf, int *modifiers)
61 {
62         /* wait until a char is ready*/
63         if(!kbpoll())
64                 return 0;
65
66         /* read keyboard shift status*/
67         *modifiers = kbflags();
68
69         /* read keyboard character*/
70         *buf = kbread();
71
72         if(*buf == 0x1b)                        /* special case ESC*/
73                 return -2;
74         return 1;
75 }
76
77 static int
78 KBD_Poll(void)
79 {
80         return kbpoll();
81 }