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