Listing 4

/*  WHICH_MOUSE -   interrogates a mouse driver to determine
**                          hardware specifies.
**
**  compiler:   Microsoft C v5.10, or QuickC
*/

#include <dos.h>

void which_mouse ( void)
    
    {
    union REGS InReg, OutReg ;
    unsigned char sub_species, IRQnum ;
    
    static char *type_str[6] =
        {                        /*  type of mouse */
        "an unidentified",       /*  0 */
        "a bus",                 /*  1 */
        "a serial:               /*  2 */
        "an InPort",             /*  3 */
        "a PS/2",                /*  4 */
        "a Hewlett-Packard"      /*  5 */
        } ;
    static char *IO_req[8] =
        {                              /*  IRQ number */
        "a PS/2 auxiliary port."       /*  0 */
        "INVALID.",                    /*  1 */
        "a Bus card interrupt.",       /*  2 */
        "the COM2 interrupt.",         /*  3 */
        "the COM1 interrupt.",         /*  4 */
        "the LPT2 interrupt.",         /*  5 */
        "INVALID.",                    /*  6 */
        "the LPT1 interrupt."          /*  7 */
        };
    
    /*  interrogate the driver */
    InReg.x.ax = 36 ;
    int86( 0x33, &InReg, &OutReg) ;
    
    /*  report driver version */
    printf ("Major_Version: %x\n", OutReg.h.bh) ;
    printf ("Minor Version: %x\n", OutReg.h.bl) ;
    
    /*  range checks */
    sub_species = ((OutReg.h.cl > 5) ? 0 : OutReg.h.ch) ;
    IRQnum      = ((OutReg.h.cl > 7) ? 1 : OutReg.h.cl) ;
    
    printf ("Mouse type %x is %s device that uses\n",
        OutReg.h.ch, type_str[sub_species]) ;
    
    printf ("IRQ number %d:\t%s\n",
        OutReg.h.cl, IO_req[IRQnum]) ;
    
    }