鼠标不接受输入
我正在尝试实现鼠标干扰,但输入功能出了问题。它应该告诉我,我已经进行了左键单击或右键单击,但它没有打印任何内容。看看:
#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);
}
}
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);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试
if((out.x.bx & 1) != 0) ...
- 即仅检查位 0 - 我注意到对于 INT33 AX=3,许多标志“未使用” - 这是否能保证它们为零是任何人的猜测。Try
if((out.x.bx & 1) != 0) ...
- i.e. check just bit 0 - I note that many of the flags are 'unused' for INT33 AX=3 - whether this guarantees them zero or not is anyone's guess.您可能想要一个主循环。 INT 33 AX=0003 不会阻止等待鼠标输入。
You probably want to have a main loop. INT 33 AX=0003 doesn't block waiting for mouse input.