#include <conio.h>
#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
#define MOUSE 0x33
#define IRET 0xcf
int main(void)
{
union REGS in_reg, out_reg;
void (interrupt far *int_handle)();
long vector;
unsigned char first_byte;
char buffer[64];
int_handle = getvect(MOUSE);
first_byte = *(unsigned char far *)int_handle;
vector = (long)int_handle;
/* vector should not be 0 and first byte should not be IRET */
if ( (vector == 0) || (first_byte == IRET) )
{
fprintf(stdout,"Mouse driver not found.\n");
return(0);
}
in_reg.x.ax = 0; /* mouse reset and status */
int86(MOUSE, &in_reg, &out_reg);
if (out_reg.x.ax != (unsigned int)-1)
{
fprintf(stdout,"Mouse not found.\n");
return(0);
}
in_reg.x.ax = 36; /* get mouse info */
int86(MOUSE, &in_reg, &out_reg);
switch(out_reg.h.ch)
{
case 1:
sprintf(buffer,"a bus mouse");
break;
case 2:
sprintf(buffer,"a serial mouse");
break;
case 3:
sprintf(buffer,"an InPort mouse");
break;
case 4:
sprintf(buffer,"a PS/2 mouse");
break;
case 5:
sprintf(buffer,"an HP mouse");
break;
}
fprintf(stdout,"Mouse driver v%x.%x is loaded for %s.\n",
out_reg.h.bh, out_reg.h.bl, buffer);
return((int)out_reg.h.bh);
}