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

Subversion Repositories or1k

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

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 Larionov, Victor Rogachev <rogach@sut.ru>
5
 *
6
 * Keyboard Driver, TURBO C version
7
 */
8
 
9
#include "device.h"
10
#include <bios.h>
11
 
12
static int  KBD_Open(KBDDEVICE *pkd);
13
static void KBD_Close(void);
14
static void KBD_GetModifierInfo(int *modifiers);
15
static int  KBD_Read(MWUCHAR *buf, int *modifiers);
16
static int  KBD_Poll(void);
17
 
18
KBDDEVICE kbddev = {
19
        KBD_Open,
20
        KBD_Close,
21
        KBD_GetModifierInfo,
22
        KBD_Read,
23
        KBD_Poll
24
};
25
 
26
/*
27
 * Open the keyboard.
28
 */
29
static int
30
KBD_Open(KBDDEVICE *pkd)
31
{
32
        return 1;
33
}
34
 
35
/*
36
 * Close the keyboard.
37
 */
38
static void
39
KBD_Close(void)
40
{
41
}
42
 
43
/*
44
 * Return the possible modifiers for the keyboard.
45
 */
46
static  void
47
KBD_GetModifierInfo(int *modifiers)
48
{
49
        *modifiers = bioskey(2);                /* no modifiers available */
50
}
51
 
52
/*
53
 * This reads one keystroke from the keyboard, and the current state of
54
 * the mode keys (ALT, SHIFT, CTRL).  Returns -1 on error, 0 if no data
55
 * is ready, and 1 if data was read.  This is a non-blocking call.
56
 */
57
static int
58
KBD_Read(MWUCHAR *buf, int *modifiers)
59
{
60
        /* wait until a char is ready*/
61
        if(!bioskey(1))
62
                return 0;
63
 
64
        /* read keyboard shift status*/
65
        *modifiers = bioskey(2);
66
 
67
        /* read keyboard character*/
68
        *buf = bioskey(0);
69
 
70
        if(*buf == 0x1b)                        /* special case ESC*/
71
                return -2;
72
        return 1;
73
}
74
 
75
static int
76
KBD_Poll(void)
77
{
78
        if (bioskey(1)!=0)
79
          return 1;
80
        else
81
          return 0;
82
}

powered by: WebSVN 2.1.0

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