📄 mouse.h
字号:
#define RESET_MOUSE 0
#define GET_MOUSE_STATUS 3
#define CHECK_BUTTON_PRESS
#define CHECK_BUTTON_RELEASE
#define GET_MOUSE_MOVEMENT 0
#define SET_MOUSE_COORD 4
#define SHOW_MOUSE 1
#define HIDE_MOUSE 2
#define LEFT_BUTTON
#define RIGHT_BUTTON
#define EITHER_BUTTON
void mouse(int *m1,int *m2,int *m3,int *m4);
{
union REGS inregs,outregs;
inregs.x.ax=*m1;
inregs.x.bx=*m2;
inregs.x.cx=*m3;
inregs.x.dx=*m4;
int86(0x33,&inregs,&outregs);
*m1=outregs.x.ax;
*m2=outregs.x.bx;
*m3=outregs.x.cx;
*m4=outregs.x.dx;
}
int resetmouse(void)
{
int m1,m2,m3,m4;
m1=RESET_MOUSE;
mouse(&m1,&m2,&m3,&m4);
return(m1);
}
void movemouse(int x,int y)
{
int m1,m2;
if(mouseexits())
{
m1=SET_MOUSE_COORD;
if(getmaxx()==319)
x*=2;
mouse(&m1,&m2,&x,&y);
}
}
int inimouse(void)
{
mouseexits=TURE;
if(resetmouse())
{
movemouse(200,200);
showmouse();
return(1);
}
}
void getmousecoords(int *x,int *y)
{
int m1,m2;
m1=GET_MOUSE_STATUS;
mouse(&m1,&m2,&x,&y);
if(getmaxx()=319)
(*x)/=2;
}
void showmouse(void)
{
int m1,m2,m3,m4;
if(mouseexits())
{
m1=SHOW_MOUSE;
mouse(&m1,&m2,&m3,&m4);
}
}
void hidemouse(void)
{
int m1,m2,m3,m4;
if(mouseexits())
{
m1=HIDE_MOUSE;
mouse(&m1,&m2,&m3,&m4);
}
}
void getmousemovment(int *x,int *y)
{
int m1,m2;
m1=GET_MOUSE_MOVMENT;
mouse(&m1,&m2,&x,&y);
if(getmaxx()=319)
(*x)/=2;
}
int testbutton(int testtype,int whichbutton)
{
int m1,m2,m3,m4;
m1=testtype;
if(whichbutton==LEFT_BUTTON||whichbutton==EITHER_BUTTON)
{
m2=LEFT_BUTTON;
mouse(&m1,&m2,&m3,&m4);
if(m2)
return(TRUE);
}
if(whichbutton==RIGHT_BUTTON||whichbutton==EITHER_BUTTON)
{
m2=RIGHT_BUTTON;
mouse(&m1,&m2,&m3,&m4);
if(m2)
return(TRUE);
}
return(FLASE);
}
int mousebuttonreleased(int whichbutton)
{
return(testbutton(CHECK_BUTTON_RELEASED,whichbutton));
}
int mousebuttonpressed(int whichbutton)
{
return(testbutton(CHECK_BUTTON_PRESS,whichbutton));
}
int getinput(int whichbutton)
{
if(!mouseexits)
{
printf("No mouse!");
return(0);
}
else
{
if(mousebuttonpressed(whichbutton))
{
while(!mousebuttonreleased(whichbutton))
return(-1);
}
else if(mousebuttonreleasd(whichbutton))
return(-1);
else if(mousebuttonpressd(whichbutton))
return(1);
return(0);
}
}
int left_pressed(void);
int right_pressed(void);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -