/*
|
/*
|
* Copyright (c) 1999 Greg Haerr <greg@censoft.com>
|
* Copyright (c) 1999 Greg Haerr <greg@censoft.com>
|
*
|
*
|
* Copyright (c) 2000 Victor Larionov, Victor Rogachev <rogach@sut.ru>
|
* Copyright (c) 2000 Victor Larionov, Victor Rogachev <rogach@sut.ru>
|
*
|
*
|
* Keyboard Driver, TURBO C version
|
* Keyboard Driver, TURBO C version
|
*/
|
*/
|
|
|
#include "device.h"
|
#include "device.h"
|
#include <bios.h>
|
#include <bios.h>
|
|
|
static int KBD_Open(KBDDEVICE *pkd);
|
static int KBD_Open(KBDDEVICE *pkd);
|
static void KBD_Close(void);
|
static void KBD_Close(void);
|
static void KBD_GetModifierInfo(int *modifiers);
|
static void KBD_GetModifierInfo(int *modifiers);
|
static int KBD_Read(MWUCHAR *buf, int *modifiers);
|
static int KBD_Read(MWUCHAR *buf, int *modifiers);
|
static int KBD_Poll(void);
|
static int KBD_Poll(void);
|
|
|
KBDDEVICE kbddev = {
|
KBDDEVICE kbddev = {
|
KBD_Open,
|
KBD_Open,
|
KBD_Close,
|
KBD_Close,
|
KBD_GetModifierInfo,
|
KBD_GetModifierInfo,
|
KBD_Read,
|
KBD_Read,
|
KBD_Poll
|
KBD_Poll
|
};
|
};
|
|
|
/*
|
/*
|
* Open the keyboard.
|
* Open the keyboard.
|
*/
|
*/
|
static int
|
static int
|
KBD_Open(KBDDEVICE *pkd)
|
KBD_Open(KBDDEVICE *pkd)
|
{
|
{
|
return 1;
|
return 1;
|
}
|
}
|
|
|
/*
|
/*
|
* Close the keyboard.
|
* Close the keyboard.
|
*/
|
*/
|
static void
|
static void
|
KBD_Close(void)
|
KBD_Close(void)
|
{
|
{
|
}
|
}
|
|
|
/*
|
/*
|
* Return the possible modifiers for the keyboard.
|
* Return the possible modifiers for the keyboard.
|
*/
|
*/
|
static void
|
static void
|
KBD_GetModifierInfo(int *modifiers)
|
KBD_GetModifierInfo(int *modifiers)
|
{
|
{
|
*modifiers = bioskey(2); /* no modifiers available */
|
*modifiers = bioskey(2); /* no modifiers available */
|
}
|
}
|
|
|
/*
|
/*
|
* This reads one keystroke from the keyboard, and the current state of
|
* This reads one keystroke from the keyboard, and the current state of
|
* the mode keys (ALT, SHIFT, CTRL). Returns -1 on error, 0 if no data
|
* the mode keys (ALT, SHIFT, CTRL). Returns -1 on error, 0 if no data
|
* is ready, and 1 if data was read. This is a non-blocking call.
|
* is ready, and 1 if data was read. This is a non-blocking call.
|
*/
|
*/
|
static int
|
static int
|
KBD_Read(MWUCHAR *buf, int *modifiers)
|
KBD_Read(MWUCHAR *buf, int *modifiers)
|
{
|
{
|
/* wait until a char is ready*/
|
/* wait until a char is ready*/
|
if(!bioskey(1))
|
if(!bioskey(1))
|
return 0;
|
return 0;
|
|
|
/* read keyboard shift status*/
|
/* read keyboard shift status*/
|
*modifiers = bioskey(2);
|
*modifiers = bioskey(2);
|
|
|
/* read keyboard character*/
|
/* read keyboard character*/
|
*buf = bioskey(0);
|
*buf = bioskey(0);
|
|
|
if(*buf == 0x1b) /* special case ESC*/
|
if(*buf == 0x1b) /* special case ESC*/
|
return -2;
|
return -2;
|
return 1;
|
return 1;
|
}
|
}
|
|
|
static int
|
static int
|
KBD_Poll(void)
|
KBD_Poll(void)
|
{
|
{
|
if (bioskey(1)!=0)
|
if (bioskey(1)!=0)
|
return 1;
|
return 1;
|
else
|
else
|
return 0;
|
return 0;
|
}
|
}
|
|
|