#include <dos.h>
#include <stdio.h>
#define MOUSE_INT 0x33
#define MOUSE_RESET 0x00
#define MOUSE_SHOW 0x01
#define MOUSE_HIDE 0x02
#define MOUSE_BUTT_POS 0x03
#define MOUSE_SET_SENSITIVITY 0x1A
#define MOUSE_MOTION_REL 0x0B
#define MOUSE_LEFT_BUTTON 0x01
#define MOUSE_RIGHT_BUTTON 0x02
#define MOUSE_CENTER_BUTTON 0x04
int Squeeze_Mouse(int command,int *x,int *y,int *buttons)
{
union REGS inregs,outregs;
switch(command)
{
case MOUSE_RESET:
{
inregs.x.ax=0x00;
int86(MOUSE_INT,&inregs,&outregs);
*buttons=outregs.x.bx;
return(outregs.x.ax);
}break;
case MOUSE_SHOW:
{
inregs.x.ax=0x01;
int86(MOUSE_INT,&inregs,&outregs);
return(1);
}break;
case MOUSE_HIDE:
{
inregs.x.ax=0x02;
int86(MOUSE_INT,&inregs,&outregs);
return(1);
}break;
case MOUSE_BUTT_POS:
{
inregs.x.ax=0x03;
int86(MOUSE_INT,&inregs,&outregs);
*x=outregs.x.cx;
*y=outregs.x.dx;
*buttons=outregs.x.bx;
return(1);
}break;
case MOUSE_MOTION_REL:
{
inregs.x.ax=0x03;
int86(MOUSE_INT,&inregs,&outregs);
*x=outregs.x.cx;
*y=outregs.x.dx;
return(1);
}break;
case MOUSE_SET_SENSITIVITY:
{
inregs.x.ax=0x04;
inregs.x.bx=*buttons;
inregs.x.cx=*x;
inregs.x.dx=*y;
int86(MOUSE_INT,&inregs,&outregs);
return(1);
}break;
default:break;
}
}
void main(void)
{
int xmouse,ymouse,btnmouse,done=0,old=0,i=0;
Squeeze_Mouse(MOUSE_RESET,0,0,0);
Squeeze_Mouse(MOUSE_SHOW,0,0,0);
while(done==0)
{
Squeeze_Mouse(MOUSE_BUTT_POS,&xmouse,&ymouse,&btnmouse);
if(btnmouse==1&&old!=1)
{
old=1;
Squeeze_Mouse(MOUSE_HIDE,0,0,0);
printf("x=%d,y=%d,button=%d\n",xmouse,ymouse,btnmouse);
Squeeze_Mouse(MOUSE_SHOW,0,0,0);
}
if(btnmouse==2&&old!=2)
{
old=2;
Squeeze_Mouse(MOUSE_HIDE,0,0,0);
printf("x=%d,y=%d,button=%d\n",xmouse,ymouse,btnmouse);
Squeeze_Mouse(MOUSE_SHOW,0,0,0);
}
i++;
if(i==5000)
{
old=0;
i=0;
}
if(kbhit())
done=1;
}
}