2018-04-30 20:53:07 -04:00
|
|
|
#include "mouse.h"
|
2020-07-19 19:24:48 -04:00
|
|
|
#include "dglmouse.h"
|
2018-04-30 20:53:07 -04:00
|
|
|
#include <dos.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "helpers.h"
|
|
|
|
|
|
|
|
void test_mouse(void) {
|
2020-07-19 19:24:48 -04:00
|
|
|
bool result;
|
2018-04-30 20:53:07 -04:00
|
|
|
|
|
|
|
clrscr(0);
|
|
|
|
|
2020-07-19 19:24:48 -04:00
|
|
|
ASSERT(mouse_is_initialized() == false);
|
2018-04-30 20:53:07 -04:00
|
|
|
|
|
|
|
result = mouse_init();
|
2020-07-19 19:24:48 -04:00
|
|
|
ASSERT(result == true);
|
|
|
|
ASSERT(mouse_is_initialized() == true);
|
2018-04-30 20:53:07 -04:00
|
|
|
|
|
|
|
// this may seem a little weird to check for a mouse AFTER init, but
|
|
|
|
// it's the init call that determines if a mouse is present :)
|
|
|
|
if (mouse_is_present()) {
|
|
|
|
printf("Mouse detected. Showing mouse state.\n");
|
|
|
|
|
|
|
|
mouse_show();
|
|
|
|
|
|
|
|
while (!kbhit()) {
|
|
|
|
gotoxy(0, 2);
|
|
|
|
printf("X: %03d\n", mouse_x);
|
|
|
|
printf("Y: %03d\n", mouse_y);
|
|
|
|
printf("Buttons: %03d\n", mouse_buttons);
|
|
|
|
}
|
|
|
|
|
|
|
|
mouse_hide();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
printf("Mouse not detected. Skipping.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
// need to close down the mouse subsystem even if one is not present
|
|
|
|
result = mouse_shutdown();
|
2020-07-19 19:24:48 -04:00
|
|
|
ASSERT(result == true);
|
|
|
|
ASSERT(mouse_is_initialized() == false);
|
2018-04-30 20:53:07 -04:00
|
|
|
|
|
|
|
gotoxy(0, 23);
|
|
|
|
printf("Press a key to continue...\n");
|
|
|
|
|
|
|
|
getch();
|
|
|
|
}
|
|
|
|
|