home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_08_08
/
8n08086a
< prev
next >
Wrap
Text File
|
1990-07-18
|
3KB
|
90 lines
/* MINFO.C Mouse information demo program*/
/* Version 1.00 03-Mar-90 for Microsoft C 5.1 or QuickC 2.01 */
/* by Bill Byrom = Applications Engineer = Tektronix Dallas TX */
/* MINFO displays information about the current mouse driver to
stdout, and returns an exit code corresponding to the COM port
number used. The mouse_info() function is used to interrogate
the mouse driver via INT 33H Function 24H (Get Mouse
Information). This function works with Microsoft MOUSE.COM
drivers currently available, but may fail with other drivers or
old versions of MOUSE.COM (tested with version 6.24).
int mouse_info( int *major_version, int *minor_version,
int *mouse_type, int *mouse_irq );
RETURN VALUE: COM port number associated with interrupt vector
used by mouse driver. IRQ4 gives COM1, while IRQ3 gives COM2.
If interrupt is other than IRQ4 or IRQ3, 0 is returned.
The driver version number is returned in major_version (decimal)
and minor_version (hex). The type of mouse is returned as an INT
in mouse_type (see example below for description of the five
types). The IRQ number used by the driver is returned in
mouse_irq (the PS/2 mouse returns 0, while serial mice normally
return 3 or 4). If the mouse driver is not loaded, all returned
values are 0. */
#include <dos.h>
#include <stdio.h>
int main(void);
int mouse_info( int *major_version, int *minor_version,
int *mouse_type, int *mouse_irq );
int main()
{
int portnum, major, minor, type, irqnum;
char *TypeMsg;
portnum = mouse_info( &major, &minor, &type, &irqnum );
switch( type )
{
case 1: TypeMsg = "Bus"; break;
case 2: TypeMsg = "Serial"; break;
case 3: TypeMsg = "InPort"; break;
case 4: TypeMsg = "PS/2"; break;
case 5: TypeMsg = "HP"; break;
default: TypeMsg = "Unknown";
}
if( type > 0 )
printf ( "Driver Version: %d.%x\n"
" Mouse Type: %s\n"
" Interrupt: IRQ%d\n"
" Port: COM%d\n",
major, minor, TypeMsg, irqnum, portnum );
else
printf( "Mouse driver is not installed or is an old version.\n" );
return( portnum );
}
int mouse_info( int *major_version, int *minor_version,
int *mouse_type, int *mouse_irq )
{
union REGS inregs, outregs;
int com_port;
inregs.x.ax = 0x0024;
inregs.x.bx = 0x0000;
inregs.x.cx = 0x0000;
int86( 0x33, &inregs, &outregs );
*major_version = (int)outregs.h.bh;
*minor_version = (int)outregs.h.bl;
*mouse_type = (int)outregs.h.ch;
*mouse_irq = (int)outregs.h.cl;
switch( outregs.h.cl )
{
case 4: com_port = 1; break;
case 3: com_port = 2; break;
default: com_port = 0;
}
return( com_port );
}
*********