📄 kbint.c
字号:
/************************************************************************
*
* Module name : KBINT.C
*
* Module description :
* This module contains functions to handler keyboard interrupt
* for DOS development environment.
*
* Project : RTMK
*
* Target platform : DOS
*
* Compiler & Library : BC++ 3.1
*
* Author : Richard Shen
*
* Creation date : 28 August, 1995
*
************************************************************************/
#ifdef __DOS__
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#include <signal.h>
#include <types.h>
#include <kbint.h>
#include "rtmkloc.h"
extern void interrupt Int09Handler(__CPPARGS);
extern void interrupt (*SaveInt09)(__CPPARGS);
bool (*ApplCheckFunc)(int key) = 0;
PROCESS ackProcess = 0;
uint armEvent = 0;
/***********************************************************************
* Function name : SetKeyboardInt
* Description : Install keyboard hardware interrupt (int 09h)
* : handler
* Parameters : -
* Returns : -
* Author : Richard Shen
*----------------------------------------------------------------------
* Date By Description
*----------------------------------------------------------------------
* 28Aug95 RCS Created
***********************************************************************/
void SetKeyboardInt(void)
{
uchar andValue;
disable();
SaveInt09 = getvect(0x09);
ApplCheckFunc = NULL;
ackProcess = NULL;
armEvent = 0;
setvect(0x09, Int09Handler);
outportb(0x60, 0xf6);
outportb(0x60, 0xf4);
enable();
} /* SetKeyboardInt() */
/***********************************************************************
* Function name : RestoreKeyboardInt
* Description : Restore keyboard interrupt handler
* :
* Parameters : -
* Returns : -
* Author : Richard Shen
*----------------------------------------------------------------------
* Date By Description
*----------------------------------------------------------------------
* 28Aug95 RCS Created
***********************************************************************/
void RestoreKeyboardInt(void)
{
disable();
if (SaveInt09)
{
setvect(0x09, SaveInt09);
} /* end of if */
ApplCheckFunc = NULL;
enable();
} /* RestoreKeyboardInt() */
/***********************************************************************
* Function name : SetKeyHitEvent
* Description : Arm an event on key hit
* :
* Parameters : process - Process to arm key hit event
* : event - Key hit event
* Returns : -
* Author : Richard Shen
*----------------------------------------------------------------------
* Date By Description
*----------------------------------------------------------------------
* 28Aug95 RCS Created
***********************************************************************/
void SetKeyHitEvent(PROCESS process, uint event)
{
disable();
ackProcess = process;
armEvent = event;
enable();
} /* SetKeyHitEvent() */
/***********************************************************************
* Function name : ClearKeyHitEvent
* Description : Clear key hit event
* :
* Parameters : -
* Returns : -
* Author : Richard Shen
*----------------------------------------------------------------------
* Date By Description
*----------------------------------------------------------------------
* 28Aug95 RCS Created
***********************************************************************/
void ClearKeyHitEvent()
{
ackProcess = NULL;
armEvent = 0;
} /* ClearKeyHitEvent() */
/***********************************************************************
* Function name : ApplKeyHitCheck
* Description : Set up application specific handle function to
* : handle or check on key hit event
* Parameters : checkFunc - Application function entry
* Returns : -
* Author : Richard Shen
*----------------------------------------------------------------------
* Date By Description
*----------------------------------------------------------------------
* 28Aug95 RCS Created
***********************************************************************/
void ApplKeyHitCheck(bool (*checkFunc)(int key))
{
disable();
ApplCheckFunc = checkFunc;
enable();
} /* ApplKeyHitCheck() */
void KeyHitEventFromMouse(void)
{
servingInt++;
if (ackProcess != NULL)
{
RtmkSend(ackProcess, armEvent);
ClearKeyHitEvent();
} /* end of if */
servingInt--;
} /* KeyHitEventFromMouse() */
#endif /* __DOS__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -