Untitled
unknown
plain_text
a year ago
1.2 kB
10
Indexable
#include <dos.h>
#include <stdio.h>
#include <conio.h>
void show_mouse();
void hide_mouse();
void get_mouse_position(int *x, int *y, int *buttons);
void update_status(int x, int y, int buttons);
int main() {
union REGS in, out;
int x, y, buttons;
in.x.ax = 0x0000;
int86(0x33, &in, &out);
if (out.x.ax == 0) {
printf("Mouse driver is not installed.\n");
return 1;
}
show_mouse();
while (!kbhit()) {
get_mouse_position(&x, &y, &buttons);
update_status(x, y, buttons);
}
hide_mouse();
return 0;
}
void show_mouse() {
union REGS in;
in.x.ax = 0x0001;
int86(0x33, &in, &in);
}
void hide_mouse() {
union REGS in;
in.x.ax = 0x0002;
int86(0x33, &in, &in);
}
void get_mouse_position(int *x, int *y, int *buttons) {
union REGS in, out;
in.x.ax = 0x0003;
int86(0x33, &in, &out);
*x = out.x.cx / 8;
*y = out.x.dx / 8;
*buttons = out.x.bx;
}
void update_status(int x, int y, int buttons) {
gotoxy(1, 1);
clreol();
printf("Position: (%d, %d) Buttons: %s%s%s",
x, y,
(buttons & 1) ? "Left " : "",
(buttons & 2) ? "Right " : "",
(buttons & 4) ? "Middle" : "");
}
Editor is loading...
Leave a Comment