请问TC中怎样允许键盘鼠标同时操作界面
#define __MOUSE_H__
/*****************************************************************************************
概念定义及程序说明
程序名称:鼠标I/O程序
日期:7/28/98
说明:本程序提供鼠标的基本输入输出功能。目前已经使用到的函数加有说明。
程序使用的是INT 33H 鼠标中断。
其他:包含mouse.h和mouse.cpp两个文件
*****************************************************************************************/
intreset_mouse(void);//reset mouse. return -1 if sucess and return others if mouse hard/soft-ware do not exist
voidshow_mouse(void);//打开鼠标,1号调用,图形方式下出现的是缺省的“箭头”
voidhide_mouse(void);//隐藏鼠标,2号调用
void BeginLongPeriodHideMouse();
void EndLongPeriodHideMouse();
intMonitorMouse(int *AX,int *BX,int *CX,int *DX);//检测鼠标,3号调用,结果返回的是AX,BX,CX,DX寄存器的值
//int push_button(void);
//void release_button(int button, int hor, int ver);
//void put_mouse(int mousex, int mousey);
//void max_hor(int min, int max);
//void max_ver(int min, int max);
//void max_ver_hor(int left, int top, int right, int bottom);
//void setcursor(int XHotSpot, int YHotSpot, int shape_tables, int seg_shape_tables);
//void mouse_move_ratio(int ratio);
//void hidden_area(int left, int top, int right, int bottom);
//void SetMouseEventHandle(unsigned char mask, int offset, int segment);
//void GetMouseRet(int *AX,int *BX,int *CX,int *DX);//3号调用的返回值
#endif
*********************************
/************************************************************************
* Mouse IO function
*
*
************************************************************************/
#include <dos.h>
#include "mouse.h"
#include "global.h"
#define MOUSE 0x33
union REGS inregs, outregs;
/* Initalize the Mouse Driver */
int LongPeriodHideMouse=FALSE;
int reset_mouse(void)
{
inregs.x.ax = 0;
int86(MOUSE,&inregs,&inregs);
return inregs.x.ax;
}
/* Show the mouse */
void show_mouse(void)
{
if (LongPeriodHideMouse==TRUE) return;
inregs.x.ax = 1;
int86(MOUSE,&inregs,&inregs);
}
/* Hide the mouse */
void hide_mouse(void)
{
if (LongPeriodHideMouse==TRUE) return;
inregs.x.ax = 2;
int86(MOUSE,&inregs,&inregs);
}
void BeginLongPeriodHideMouse()
{
LongPeriodHideMouse=TRUE;
inregs.x.ax = 2;
int86(MOUSE,&inregs,&inregs);
}
void EndLongPeriodHideMouse()
{
LongPeriodHideMouse=FALSE;
inregs.x.ax = 1;
int86(MOUSE,&inregs,&inregs);
}
/* Monitors the status of the mouse */
/* 已经修改!*/
int MonitorMouse(int *AX,int *BX,int *CX,int *DX)
{
inregs.x.ax = 3;
int86(MOUSE,&inregs,&outregs);
*AX = outregs.x.ax;
*BX = outregs.x.bx;
*CX = outregs.x.cx;
*DX = outregs.x.dx;
return *BX;
}
/* Retrieves the amount of times a button has been pressed */
/*
int push_button(void)
{
inregs.x.ax = 5;
int86(0x33,&inregs,&outregs);
globax = outregs.x.ax;
globbx = outregs.x.bx;
globcx = outregs.x.cx;
globdx = outregs.x.dx;
return(globbx,globcx,globdx);
}
*/
/* Retrieves the amount of times a button was released */
/*
void release_button(int button, int *hor, int *ver)
{
inregs.x.ax = 6;
inregs.x.bx = button;
int86(MOUSE,&inregs,&outregs);
globax = outregs.x.ax;
globbx = outregs.x.bx;
globcx = outregs.x.cx;
globdx = outregs.x.dx;
*ver = globcx; //????
*hor = globdx; //????
}
*/
/* Moves the mouse to the position specified */
/*
void put_mouse(int mousex, int mousey)
{
inregs.x.ax = 4;
inregs.x.cx = mousey;
inregs.x.dx = mousex;
int86(MOUSE,&inregs,&outregs);
globax = outregs.x.ax;
globbx = outregs.x.bx;
globcx = outregs.x.cx;
globdx = outregs.x.dx;
}
*/
/* Sets the Maximum Horizontal positions */
/*
void max_hor(int min, int max)
{
inregs.x.ax = 7;
inregs.x.cx = min;
inregs.x.dx = max;
int86(MOUSE,&inregs,&inregs);
}
*/
/* Sets the Maximum Vertical positions */
/*
void max_ver(int min, int max)
{
inregs.x.ax = 8;
inregs.x.cx = min;
inregs.x.dx = max;
int86(MOUSE,&inregs,&inregs);
}
*/
/* Sets both the Maximum Vertical and Horizontal positions */
/*
void max_ver_hor(int left, int top, int right, int bottom)
{
max_hor(left,right);
max_ver(top,bottom);
}
*/
/* Defines the cursor to use for graphics modes */
/*
void setcursor(int XHotSpot, int YHotSpot, int shape_tables, int seg_shape_tables)
{
struct SREGS segregs;
inregs.x.ax = 9;
inregs.x.bx = XHotSpot;
inregs.x.cx = YHotSpot;
inregs.x.dx = shape_tables;
segregs.es = seg_shape_tables;
int86x(MOUSE,&inregs,&inregs,&segregs);
}
*/
/* Sets the movement ratio of the mouse */
/*
void mouse_move_ratio(int ratio)
{
inregs.x.ax = 15;
inregs.x.cx = ratio;
inregs.x.dx = ratio;
int86(MOUSE,&inregs,&outregs);
globax = outregs.x.ax;
globbx = outregs.x.bx;
globcx = outregs.x.cx;
globdx = outregs.x.dx;
}
*/
/* Defines a hidden area of the screen for the mouse; it won't show the
cursor in that rectangle or square */
/*
void hidden_area(int left, int top, int right, int bottom)
{
inregs.x.ax = 16;
inregs.x.cx = left;
inregs.x.dx = top;
inregs.x.si = right;
inregs.x.di = bottom;
int86(MOUSE,&inregs,&outregs);
globax = outregs.x.ax;
globbx = outregs.x.bx;
globcx = outregs.x.cx;
globdx = outregs.x.dx;
}
*/
/* Defines mouse event handle */
/*
void SetMouseEventHandle(unsigned char mask, int offset, int segment)
{
struct SREGS segregs;
inregs.x.ax = 0x0C;
inregs.x.cx = mask;
inregs.x.dx = offset;
segregs.es = segment;
int86x(MOUSE,&inregs,&inregs,&segregs);
}
*/
/*
void GetMouseRet(int *AX,int *BX,int *CX,int *DX)
{
*AX=globax;
*BX=globbx;
*CX=globcx;
*DX=globdx;
}
*/
while(1)
{
如果有键盘动作,处理按键动作;
如果有鼠标动作,处理鼠标动作;
}
是否有键盘动作:if(kbhit())
是否有鼠标动作:if(LeftPressed()),if(RightPressed())
char LeftPressed()
{
union REGS ireg,oreg;
ireg.x.ax=3;
int86(0x33,&ireg,&oreg);
return(oreg.x.bx&1);
}
char RightPressed()
{
union REGS ireg,oreg;
ireg.x.ax=3;
int86(0x33,&ireg,&oreg);
return(oreg.x.bx&2);
}