#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;
/* Mengetahui posisi koordinat pointer mouse */
void getMousePos(void);
public:
Mouse(void); /* Konstruktor default */
~Mouse(void); /* Destruktor default */
UCHAR getState(void);
UCHAR getNumButton(void);
UCHAR disableMouse(void);
void enableMouse(void);
/* Mendeteksi penekanan tombol mouse */
USHORT getButtonClick(UCHAR btn, USHORT maxclick);
/* Mendeteksi pelepasan tombol mouse */
USHORT getButtonRelease(UCHAR btn, USHORT maxrel);
/* Mengetahui klik kiri atau klik kanan setelah */
/* fungsi getMousePos dijalankan */
UCHAR getClickMode(void);
USHORT getX(void);
USHORT getY(void);
void hideMouse(void);
void showMouse(void);
/*Memindahkan pointer mouse di posisi tertentu */
void setMousePos(USHORT row, USHORT col);
/*Membatasi posisi koordinat mouse di layar */
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 < maxclick)
{
asm mov ah, 0x00;
asm mov al, 0x05;
asm mov bh, 0x00;
asm mov bl, btn;
asm int MOUSE_INT;
asm mov click, bx;
asm mov x, cx;
asm mov y, dx;
nclick += click;
}
this->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 < maxrel)
{
asm mov ah, 0x00;
asm mov al, 0x06;
asm mov bh, 0x00;
asm mov bl, btn;
asm int MOUSE_INT;
asm mov rel, bx;
asm mov x, cx;
asm mov y, dx;
nrel += rel;
}
this->y = y; this->x = x;
return rel;
}
void Mouse::getMousePos(void)
{
USHORT x, y;
UCHAR cmode;
asm mov ax, 0x0003; /* AH= 0, AL= 3, AX = 3 */
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; /* AH = 0, AL = 2, AX = 2 */
asm int MOUSE_INT;
return;
}
void Mouse::setMousePos(USHORT row, USHORT col)
{
asm mov ax, 0x0004; /* AH = 0, AL = 4, AX = 4 */
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;
}
#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;
/* Mengetahui posisi koordinat pointer mouse */
void getMousePos(void);
public:
Mouse(void); /* Konstruktor default */
~Mouse(void); /* Destruktor default */
UCHAR getState(void);
UCHAR getNumButton(void);
UCHAR disableMouse(void);
void enableMouse(void);
/* Mendeteksi penekanan tombol mouse */
USHORT getButtonClick(UCHAR btn, USHORT maxclick);
/* Mendeteksi pelepasan tombol mouse */
USHORT getButtonRelease(UCHAR btn, USHORT maxrel);
/* Mengetahui klik kiri atau klik kanan setelah */
/* fungsi getMousePos dijalankan */
UCHAR getClickMode(void);
USHORT getX(void);
USHORT getY(void);
void hideMouse(void);
void showMouse(void);
/*Memindahkan pointer mouse di posisi tertentu */
void setMousePos(USHORT row, USHORT col);
/*Membatasi posisi koordinat mouse di layar */
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 < maxclick)
{
asm mov ah, 0x00;
asm mov al, 0x05;
asm mov bh, 0x00;
asm mov bl, btn;
asm int MOUSE_INT;
asm mov click, bx;
asm mov x, cx;
asm mov y, dx;
nclick += click;
}
this->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 < maxrel)
{
asm mov ah, 0x00;
asm mov al, 0x06;
asm mov bh, 0x00;
asm mov bl, btn;
asm int MOUSE_INT;
asm mov rel, bx;
asm mov x, cx;
asm mov y, dx;
nrel += rel;
}
this->y = y; this->x = x;
return rel;
}
void Mouse::getMousePos(void)
{
USHORT x, y;
UCHAR cmode;
asm mov ax, 0x0003; /* AH= 0, AL= 3, AX = 3 */
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; /* AH = 0, AL = 2, AX = 2 */
asm int MOUSE_INT;
return;
}
void Mouse::setMousePos(USHORT row, USHORT col)
{
asm mov ax, 0x0004; /* AH = 0, AL = 4, AX = 4 */
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;
}
0 komentar:
Posting Komentar