OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [MW_0_8_9PRE7/] [mw/] [src/] [drivers/] [kbd_pac.c] - Blame information for rev 673

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 673 markom
/*
2
 * Copyright (c) 1999 Greg Haerr <greg@censoft.com>
3
 *
4
 * Copyright (c) 2000 Victor Rogachev <rogach@sut.ru>
5
 *
6
 * Keyboard Driver, using BIOS for PACIFIC C on MSDOS
7
 */
8
 
9
#include "device.h"
10
#include <dos.h>
11
#include <conio.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
 * Close the keyboard.
41
 */
42
static void
43
KBD_Close(void)
44
{
45
}
46
 
47
/*
48
 * Return the possible modifiers for the keyboard.
49
 */
50
static  void
51
KBD_GetModifierInfo(int *modifiers)
52
{
53
        *modifiers = 0;                  /* no modifiers available */
54
}
55
 
56
/*
57
 * This reads one keystroke from the keyboard, and the current state of
58
 * the mode keys (ALT, SHIFT, CTRL).  Returns -1 on error, 0 if no data
59
 * is ready, and 1 if data was read.  This is a non-blocking call.
60
 */
61
static int
62
KBD_Read(MWUCHAR *buf, int *modifiers)
63
{
64
        union REGS      reg;
65
 
66
        /* wait until a char is ready*/
67
        if (!kbhit())
68
                return 0;
69
 
70
        /* read keyboard shift status*/
71
        reg.x.ax = 0x0200;
72
        int86(0x16, &reg, &reg);
73
        *modifiers = reg.x.ax;
74
 
75
        /* read keyboard character*/
76
        reg.x.ax = 0x1000;
77
        int86(0x16, &reg, &reg);
78
        *buf = (reg.x.ax & 0x00ff);
79
 
80
        if(*buf == 0x1b)        /* special case ESC*/
81
                return -2;
82
        return 1;
83
}
84
 
85
/*
86
**      Poll keyboard for char ready
87
*/
88
static int
89
KBD_Poll(void)
90
{
91
        if (kbhit())
92
                return 1;
93
        else
94
                return 0;
95
}
96
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.