Tuesday, 14 July 2015

Mouse.C

/****
*This file contains all the functions used in mouse programming in C language
*you can include this file in your program and directly use these functions in 
*your program.
****/

#include<stdlib.h>
#include<dos.h>

union REGS r,o;

int initmouse(void);
showmouseptr(void);
void hidemouseptr(void);
void getmousepos(int *,int *,int *);
void restrictmouseptr(int,int,int,int);
void setmousestatus();
void setmousepos(int,int);


  
int initmouse(void)
{
r.x.ax=0;
int86(0x33,&r,&o);
return o.x.ax;
}
showmouseptr()
{
r.x.ax=1;
int86(0x33,&r,&o);
return 0;
}

void setmousepos(int x,int y)
{
r.x.ax=4;
r.x.cx=x;
r.x.dx=y;
int86(0x33,&r,&o);
}

void setmousestatus()
{
r.x.ax=0x0c;
o.x.bx=0;
int86(0x33,&r,&o);
}

void getmousepos(int *x,int *y,int *button)
{
r.x.ax=3;
int86(0x33,&r,&o);
*button =o.x.bx;
*x=o.x.cx;
*y=o.x.dx;
}
void hidemouseptr()
{
r.x.ax=2;
int86(0x33,&r,&o);
}
void restrictmouseptr(int x1,int y1,int x2,int y2)
{
r.x.ax=7;
r.x.cx=x1;
r.x.dx=x2;
int86(0x33,&r,&o);
r.x.ax=8;
r.x.cx=y1;
r.x.dx=y2;
int86(0x33,&r,&o);
}

void reset_mouse()
{
r.x.ax=0x21;
int86(0x33,&r,&o);
}


No comments:

Post a Comment