RSS

mouse.cpp

18 Jun

#define MOUSE_INT 0x33
#define MOUSE_READY 0xff
#define MOUSE_NOT_READY 0x00
#define MOUSE_SUCCESS 0x1f
#define MOUSE_FAILURE 0xff
#define MOUSE_LEFT_CLICK 0x01
#define MOUSE_RIGHT_CLICK 0x02
#define MOUSE_LEFT_BUTTON 0x00
#define MOUSE_RIGHT_BUTTON 0x01

#define UCHAR unsigned char
#define USHORT unsigned short int

class Mouse
{
private:
UCHAR button;
UCHAR isReady;
UCHAR clickMode;
USHORT x, y;

void getMousePos(void);

public:
Mouse(void);
~Mouse(void);

UCHAR getState(void);
UCHAR getNumButton(void);

UCHAR disableMouse(void);
void enableMouse(void);

USHORT getButtonClick(UCHAR btn, USHORT maxclick);

USHORT getButtonRelease(UCHAR btn, USHORT maxrel);

UCHAR getClickMode(void);

USHORT getX(void);
USHORT getY(void);

void hideMouse(void);
void showMouse(void);

void setMousePos(USHORT row, USHORT col);

void setMouseRegion(USHORT y1, USHORT x1, USHORT y2, USHORT x2);
};

Mouse::Mouse(void)
{
UCHAR state, button;

asm mov ah, 0x00;
asm mov al, 0x00;
asm int MOUSE_INT;
asm mov state, al;
asm mov button, bl;

this->isReady = state;
this->button = button;

return;
}

Mouse::~Mouse(void)
{
return;
}

UCHAR Mouse::getState(void)
{
return this->isReady;
}

UCHAR Mouse::getNumButton(void)
{
return this->button;
}

UCHAR Mouse::disableMouse(void)
{
UCHAR state;

asm mov ah, 0x00;
asm mov al, 0x1f;
asm int MOUSE_INT;
asm mov state, al;

return state;
}

void Mouse::enableMouse(void)
{
asm mov ax, 0x0020;
asm int MOUSE_INT;

return;
}

USHORT Mouse::getButtonClick(UCHAR btn, USHORT maxclick)
{
USHORT click, nclick, x, y;

click = nclick = x = y = 0;

while(nclick y = y; this->x = x;

return click;
}

USHORT Mouse::getButtonRelease(UCHAR btn, USHORT maxrel)
{
USHORT rel, nrel, x, y;

rel = nrel = x = y = 0;

while(nrel y = y; this->x = x;

return rel;
}

void Mouse::getMousePos(void)
{
USHORT x, y;
UCHAR cmode;

asm mov ax, 0x0003;
asm int MOUSE_INT;
asm mov x, cx;
asm mov y, dx;
asm mov cmode, bl;

this->y = y; this->x = x;
this->clickMode = cmode;

return;
}

UCHAR Mouse::getClickMode(void)
{
this->getMousePos();
return this->clickMode;
}

USHORT Mouse::getX(void)
{
return this->x;
}

USHORT Mouse::getY(void)
{
return this->y;
}

void Mouse::hideMouse(void)
{
asm mov ax, 0x0002;
asm int MOUSE_INT;

return;
}

void Mouse::setMousePos(USHORT row, USHORT col)
{
asm mov ax, 0x0004;
asm mov cx, col;
asm mov dx, row;
asm int MOUSE_INT;

return;
}

void Mouse::setMouseRegion(USHORT y1, USHORT x1, USHORT y2, USHORT x2)
{
asm mov ax, 0x0007;
asm mov cx, x1;
asm mov dx, x2;
asm int MOUSE_INT;

asm mov ax, 0x0008;
asm mov cx, y1;
asm mov dx, y2;
asm int MOUSE_INT;

return;
}

void Mouse::showMouse(void)
{
asm mov ax, 0x0001;
asm int MOUSE_INT;

return;
}

 
Leave a comment

Posted by on June 18, 2011 in C ++, Computer

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: