49 lines
1.0 KiB
C
49 lines
1.0 KiB
C
|
#include <dos.h>
|
||
|
#include <conio.h>
|
||
|
|
||
|
#include "mouse_io.h"
|
||
|
|
||
|
int activateMouse(struct MouseStatus *status) {
|
||
|
union REGS regs;
|
||
|
int mouseActivated;
|
||
|
|
||
|
regs.w.ax = MOUSE_DRIVER_RESET;
|
||
|
int386(MOUSE_DRIVER_INTERRUPT, ®s, ®s);
|
||
|
|
||
|
mouseActivated = regs.w.ax;
|
||
|
|
||
|
if (mouseActivated) {
|
||
|
status->isActive = regs.w.ax;
|
||
|
status->buttonCount = regs.w.bx;
|
||
|
|
||
|
// set horiz and vert range
|
||
|
regs.w.ax = 0x07;
|
||
|
regs.w.cx = 0;
|
||
|
regs.w.dx = VGA_DISPLAY_WIDTH - 1;
|
||
|
int386(MOUSE_DRIVER_INTERRUPT, ®s, ®s);
|
||
|
|
||
|
regs.w.ax = 0x08;
|
||
|
regs.w.cx = 0;
|
||
|
regs.w.dx = VGA_DISPLAY_HEIGHT - 1;
|
||
|
int386(MOUSE_DRIVER_INTERRUPT, ®s, ®s);
|
||
|
}
|
||
|
|
||
|
return mouseActivated;
|
||
|
}
|
||
|
|
||
|
void readMouse(struct MouseStatus *status) {
|
||
|
union REGS regs;
|
||
|
int buttonStatus;
|
||
|
|
||
|
regs.w.ax = MOUSE_DRIVER_READ_STATE;
|
||
|
int386(MOUSE_DRIVER_INTERRUPT, ®s, ®s);
|
||
|
|
||
|
buttonStatus = regs.w.bx;
|
||
|
status->xPosition = regs.w.cx;
|
||
|
status->yPosition = regs.w.dx;
|
||
|
|
||
|
status->leftButtonDown = buttonStatus & 1;
|
||
|
status->rightButtonDown = (buttonStatus >> 1) & 1;
|
||
|
}
|
||
|
|