I am trying to implement mouse interfecing but somethings wrong with the input function.It should tell me that wheater i have made a left click or a right click but its not printing anything.Have a look:
#include<graphics.h>
#include<dos.h>
union REGS in,out;
void Graphics(void);
void DetectMouse(void);
void ShowMouse(void);
void HideMouse(void);
void InputMouse(void);
int main()
{
Graphics();
DetectMouse();
ShowMouse();
// HideMouse();
InputMouse();
getch();
closegraph();
return 0;
}
void Graphics(void)
{
int driver=DETECT,mode;
initgraph(&driver,&mode,"C:\\TC\\bgi");
outtextxy(1,1,"Graphics mode activated!");
}
void DetectMouse(void)
{
int result;
in.x.ax=0;
result=int86(0x33,&in,&out);
if(result)
{
outtextxy(10,10,"Driver succesfully detected");
}
else
{
outtextxy(10,10,"Driver not detected");
}
}
void ShowMouse(void)
{
in.x.ax=1;
int86(0x33,&in,&out);
}
void HideMouse(void)
{
in.x.ax=2;
int86(0x33,&in,&out);
}
void InputMouse(void)
{
for(;kbhit();)
{
int x,y;
in.x.ax=3;
int86(0x33,&in,&out);
if(out.x.bx==1)
outtextxy(30,30,"Left click");
if(out.x.bx==2)
outtextxy(40,40,"Right click");
if(out.x.bx==3)
outtextxy(50,50,"Middle click");
delay(100);
}
}