home *** CD-ROM | disk | FTP | other *** search
- /*
- * mousutil.c
- *
- * Module for mouse test utility
- *
- * Copyright (c) 1988-1989, Microsoft Corporation. All rights reserved.
- *
- *
- * Disclaimer: This code is example code only,
- * and does not warranty any product
- * as being Microsoft compatible.
- * Microsoft will not be held responsible
- * for claims made pertaining to this software.
- *
- */
-
- #include "mousetst.h"
-
- unsigned savedMode;
-
- void
- SetCursor(x, y)
- unsigned int x, y;
- {
- union REGS inregs, outregs;
-
- inregs.h.ah = 2;
- inregs.h.bh = 0;
- inregs.h.dh = (char) y;
- inregs.h.dl = (char) x;
- int86(0x10, &inregs, &outregs);
- }
-
- void
- cls()
- {
- union REGS inregs, outregs;
-
- inregs.x.ax = 0x0600;
- inregs.h.bh = 7;
- inregs.x.cx = 0;
- inregs.h.dh = 24;
- inregs.h.dl = 79;
- int86(0x10, &inregs, &outregs);
- }
-
- void
- BlankLine()
- {
- printf(" ");
- }
-
- void
- BlankMenu()
- {
-
- int i;
-
- for ( i = 7 ; i <= 18 ; i++ )
- {
- SetCursor(0, i);
- BlankLine();
- }
-
- }
-
- void
- Cleanup()
- {
- int dummy, errorStatus, eventMask;
- extern unsigned originalSegment, originalCallMask, originalOffset;
-
- MouseResetAndStatus(&dummy, &dummy);
- SwapInterruptSubroutines(&originalSegment,
- &originalCallMask,
- &originalOffset
- );
- VideoModeSaveRestore(RESTORE);
-
- /* Now disable all possible function 24 subroutines */
-
- eventMask = 0x20; /* Disable Shift Key subroutine */
- SetAlternateMouseUserSubroutine(&errorStatus, eventMask, Function12);
-
- if (errorStatus == -1)
- printf("Error occured disabling Function 24 Shift Key subroutine\n");
-
- eventMask = 0x40; /* Disable Ctrl Key subroutine */
- SetAlternateMouseUserSubroutine(&errorStatus, eventMask, Function12);
-
- if (errorStatus == -1)
- printf("Error occured disabling Function 24 Ctrl Key subroutine\n");
-
- eventMask = 0x80; /* Disable Alt Key subroutine */
- SetAlternateMouseUserSubroutine(&errorStatus, eventMask, Function12);
-
- if (errorStatus == -1)
- printf("Error occured disabling Function 24 Alt Key subroutine\n");
- }
-
- void
- VideoModeSaveRestore(function)
-
- unsigned int function;
-
- {
- union REGS inregs, outregs;
-
- switch (function)
- {
- case SAVE:
- inregs.h.ah = 0x0f;
- int86(0x10, &inregs, &outregs);
- savedMode = outregs.h.al;
- break;
- case RESTORE:
- inregs.h.ah = 0;
- inregs.h.al = (char) savedMode;
- int86(0x10, &inregs, &outregs);
- break;
- default:
- printf("Bad function for VideoModeSaveRestore\n");
- break;
- }
- }
-
- void
- SetVideoMode(vMode)
-
- unsigned int vMode;
-
- {
- union REGS inregs, outregs;
- int videoModeNumber = 0;
-
- inregs.h.ah = 0;
- inregs.h.al = (char) vMode;
- int86(0x10, &inregs, &outregs);
-
- }
-
- void
- Pause(s)
- /* timer, when t=1 is about 1 sec
- */
- int s;
- {
- int i, j;
-
- for ( i = 0; i < s; i++ )
- for ( j = 0 ; j < 500 ; j++ )
- printf("");
- }
-
- void
- ShowLogo()
- {
- int i;
- union REGS inregs, outregs;
- char lu = 0xc9, lb = 0xc8, ru = 0xbb, rb = 0xbc, hbar= 0xcd, vbar= 0xba;
-
- cls();
-
- /* Draw upper corners of box */
-
- SetCursor(8, 10);
- putch(lu);
- SetCursor(72, 10);
- putch(ru);
-
- /* Draw horizontal section of box */
-
- for ( i = 9 ; i <= 71 ; i++)
- {
- SetCursor(i, 10);
- putch(hbar);
- SetCursor(i, 15);
- putch(hbar);
- }
-
- /* Draw lower corners of box */
-
- SetCursor(8, 15);
- putch(lb);
- SetCursor(72, 15);
- putch(rb);
-
- /* Draw vertical section of box */
-
- for ( i = 11 ; i <= 14 ; i++ )
- {
- SetCursor(8, i);
- putch(vbar);
- SetCursor(72, i);
- putch(vbar);
- }
-
- SetCursor(15, 12);
- puts("Microsoft (R) Mouse Test Program Version 1.00");
- SetCursor(10, 13);
- puts("Copyright (C) Microsoft Corp 1986-1989. All rights reserved.");
-
- /* Display "mouse" hanging off of box */
-
- SetCursor(60, 15);
- putch(0x5e);
- SetCursor(60, 16);
- putch(0x99);
- SetCursor(60, 17);
- putch(0xf5);
-
- /* set the text cursor to minimun */
-
- inregs.h.ah = 1;
- inregs.h.ch = 32;
- inregs.h.cl = 0;
- int86(0x10, &inregs, &outregs);
- Pause(20);
- }
-
- void
- CFunction12()
- {
- unsigned conditionMask, buttonState;
- int horizCursorCoordinate, vertCursorCoordinate;
- int horizMouseCounts, vertMouseCounts;
-
- Function12Info(&conditionMask,
- &buttonState,
- &horizCursorCoordinate,
- &vertCursorCoordinate,
- &horizMouseCounts,
- &vertMouseCounts
- );
- HideCursor();
- SetCursor(0, 13);
- BlankLine();
- SetCursor(0, 13);
- printf("Condition Mask = %x", conditionMask);
- SetCursor(0, 14);
- BlankLine();
- SetCursor(0, 14);
- printf("Button State = %x", buttonState);
- SetCursor(0, 15);
- BlankLine();
- SetCursor(0, 15);
- printf("Horizontal Cursor Coordinate = %d", horizCursorCoordinate);
- SetCursor(0, 16);
- BlankLine();
- SetCursor(0, 16);
- printf("Vertical Cursor Coordinate = %d", vertCursorCoordinate);
- SetCursor(0, 17);
- BlankLine();
- SetCursor(0, 17);
- printf("Horizontal Mouse Counts = %d", horizMouseCounts);
- SetCursor(0, 18);
- BlankLine();
- SetCursor(0, 18);
- printf("Vertical Mouse Counts = %d", vertMouseCounts);
- ShowCursor();
- }
-
- void
- SaveAndRestoreMouseDriverState()
- {
- int X = 0;
- int Y = 0;
- unsigned buff;
- int *bufptr;
-
- BlankMenu();
- SetCursor(0, 7);
- printf("Save & Restore Mouse Driver State Test:");
- SetCursor(0, 11);
- printf("Move Mouse Cursor to LOWER RIGHT corner\n");
- printf(" then hit any key ...");
- ShowCursor();
- ShowCursor();
- ShowCursor();
- getch();
- SetCursor(0, 11);
- BlankLine();
- SetCursor(0, 12);
- BlankLine();
- GetMouseDriverStateStorageRequirements(&buff);
- if ((bufptr = malloc(buff)) == NULL) {
- SetCursor(0, 15);
- printf("Insufficient memory for this test routine.");
- SetCursor(0, 18);
- printf("Hit any key to EXIT");
- getch();
- HideCursor();
- HideCursor();
- HideCursor();
- return;
- }
- SaveMouseDriverState(bufptr);
- SetCursor(0, 11);
- printf("Move cursor to another spot on screen");
- SetCursor(0, 12);
- BlankLine();
- SetCursor(5, 12);
- printf("hit a key when done moving...");
- getch();
- SetCursor(0, 11);
- BlankLine();
- SetCursor(0, 12);
- BlankLine();
- HideCursor();
- RestoreMouseDriverState(bufptr);
- SetCursor(0, 11);
- printf("Is cursor back at LOWER RIGHT again ? ");
- if (tolower(getch()) == 'y') {
- SetCursor(0, 11);
- BlankLine();
- SetCursor(0, 11);
- printf("Function 22 Save Driver State PASSED.\n");
- printf("Function 23 Restore Driver State PASSED.");
- }
- else
- {
- SetCursor(0, 11);
- BlankLine();
- SetCursor(0, 11);
- printf("Save & Restore Driver State FAILED.");
- }
-
- free(bufptr);
- SetCursor(0, 18);
- printf("Hit any key to EXIT");
- getch();
- HideCursor();
- HideCursor();
- }
-