1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
#ifndef __MOUSE_H
#define __MOUSE_H
#include <dos.h>
#define LEFT 1
#define RIGHT 2
#define CENTER 3
class Mouse
{
private:
int mx, my,
got_mouse,
num_buttons,
button;
union REGS inREGS;
union REGS outREGS;
public:
Mouse(void);
~Mouse(void);
int GotMouse(void){return got_mouse;}
void SetLimits(int minXLimit, int maxXLimit, int minYLimit, int maxYLimit);
void ShowMouse(void);
void HideMouse(void);
int Event(void);
int GetButton(void){return button;}
void GetXY(int &x, int &y){x=mx;y=my;}
void ButtonUp(void);
};
extern Mouse mouse;
Mouse::Mouse(void)
{
got_mouse=0;
if(getvect(0x33))
{
inREGS.x.ax=0x0000;
int86(0x33,&inREGS,&outREGS);
got_mouse=outREGS.x.ax;
num_buttons=outREGS.x.bx;
}
}
Mouse::~Mouse(void)
{
inREGS.x.ax=0x0000;
int86(0x33,&inREGS,&outREGS);
}
void Mouse::SetLimits(int minXLimit, int maxXLimit, int minYLimit, int maxYLimit)
{
if(!got_mouse)
return;
inREGS.x.ax=0x0007;
inREGS.x.cx=minXLimit;
inREGS.x.dx=maxXLimit;
int86(0x33,&inREGS,&outREGS);
inREGS.x.ax=0x0008;
inREGS.x.cx=minYLimit;
inREGS.x.dx=maxYLimit;
int86(0x33,&inREGS,&outREGS);
}
void Mouse::ShowMouse(void)
{
if(!got_mouse)
return;
inREGS.x.ax=0x0001;
int86(0x33,&inREGS,&outREGS);
}
void Mouse::HideMouse(void)
{
if(!got_mouse)
return;
inREGS.x.ax=0x0002;
int86(0x33,&inREGS,&outREGS);
}
int Mouse::Event(void)
{
if(!got_mouse)
return 0;
inREGS.x.ax=0x0003;
int86(0x33,&inREGS,&outREGS);
button=outREGS.x.bx;
mx=outREGS.x.cx;
my=outREGS.x.dx;
if(button)
return 1;
else
return 0;
}
void Mouse::ButtonUp(void)
{
while(button)
Event();
}
#endif
|