Category : C Source Code
Archive   : TSTMOUSE.ZIP
Filename : TSTMOUSE.C

 
Output of file : TSTMOUSE.C contained in archive : TSTMOUSE.ZIP
/***************************************************************************
*
* tstmouse.c -- test program for mouse package
*
***************************************************************************/

#include
#include
#include

int right_button = 0;
int mouse_event = 0;
int mouse_code = 0;
int mouse_cx = 0;
int mouse_dx = 0;

unsigned short cursor[] =
{
0x0001, 0x0200, 0x0000, 0x0000,
0x0001, 0x0200, 0x0000, 0x0000,
0x0001, 0x0200, 0x0000, 0x0000,
0x0001, 0x0200, 0x0000, 0x0000,
0x0001, 0x0200, 0x0000, 0x0000,
0x0001, 0x0200, 0x0000, 0x0000,
0x0001, 0x0200, 0x0000, 0x0000,
0x0001, 0x0200, 0x0000, 0x0000,
0x0001, 0x0200, 0x0000, 0x0000,
0x0001, 0x0200, 0x0000, 0x0000,
0x0001, 0x0200, 0x0000, 0x0000,
0x0001, 0x0200, 0x0000, 0x0000,
0x0001, 0x0200, 0x0000, 0x0000,
0x0001, 0x0200, 0x0000, 0x0000,
0x0001, 0x0200, 0x0000, 0x0000,
0x0001, 0x0200, 0x0000, 0x0000
};

#pragma off (check_stack)
void _loadds far click_handler (int max, int mcx, int mdx)
{
#pragma aux click_handler parm [EAX] [ECX] [EDX]
mouse_event = 1;
mouse_code = max;
mouse_cx = mcx;
mouse_dx = mdx;
if(mouse_code & 8) right_button = 1;
}
#pragma on (check_stack)

main ()
{
struct SREGS sregs;
union REGS inregs, outregs;
int installed = 0;
int orig_mode = 0;
int far *ptr;
int (far *function_ptr)();

segread(&sregs);
/* get original video mode */

inregs.w.ax = 0x0f00;
int386 (0x10, &inregs, &outregs);

printf ("Current Mode = %u\n", orig_mode = outregs.h.al);

/* check for mouse driver */

inregs.w.ax = 0;
int386 (0x33, &inregs, &outregs);
if (installed = (outregs.w.ax == -1))
printf ("Mouse Installed...\n");
else
printf ("Mouse NOT Installed...\n");

/* install click watcher */

if (installed)
{

/* goto graphics mode */

inregs.h.ah = 0x00;
inregs.h.al = 0x4;
int386 (0x10, &inregs, &outregs);

/* show mouse cursor */

inregs.w.ax = 0x1;
int386 (0x33, &inregs, &outregs);

/* set mouse cursor form */

inregs.w.ax = 0x9;
inregs.w.bx = 0x0;
inregs.w.cx = 0x0;
ptr = cursor;
inregs.x.edx = FP_OFF(ptr);
sregs.es = FP_SEG(ptr);
int386x (0x33, &inregs, &outregs, &sregs);

/* install click watcher */

inregs.w.ax = 0xC;
inregs.w.cx = 0x0002 + 0x0008;
function_ptr = click_handler;
inregs.x.edx = FP_OFF(function_ptr);
sregs.es = FP_SEG(function_ptr);
int386x (0x33, &inregs, &outregs, &sregs);

while (!right_button)
{
if (mouse_event)
{
printf ("Event = %x : CX = %u DX = %u\n", mouse_code, mouse_cx, mouse_dx);
mouse_event = 0;
}
}
}

/* check installation again (to clear watcher) */

inregs.w.ax = 0;
int386 (0x33, &inregs, &outregs);
if (outregs.w.ax == -1)
printf ("DONE : Mouse Still Installed...\n");
else
printf ("DONE : Mouse NOT Installed...\n");


inregs.h.ah = 0x00;
inregs.h.al = orig_mode;
int386 (0x10, &inregs, &outregs);
}


  3 Responses to “Category : C Source Code
Archive   : TSTMOUSE.ZIP
Filename : TSTMOUSE.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/