home *** CD-ROM | disk | FTP | other *** search
- /*
- * menu.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"
-
- void FunctionSelect()
- {
-
- int function;
- int bStatus, hPosition, vPosition;
- int mouseStatus, numberOfButtons;
- int status, buttonPresses, horizontalCursor, verticalCursor;
- unsigned horizontalCoordinate, verticalCoordinate;
- unsigned minimumPosition, maximumPosition;
-
- BlankMenu();
- SetCursor(0, 7);
- printf("Select number to test mouse function");
- SetCursor(0, 9);
- printf("0 - Mouse reset and status\n");
- printf("1 - Show cursor\n");
- if (cursorLevel)
- printf("2 - Hide cursor (level = %d)\n", cursorLevel);
- else
- printf("2 - Hide cursor\n");
- printf("3 - Get button status and mouse position");
- SetCursor(0, 13);
- printf("4 - Set mouse cursor position\n");
- printf("5 - Get button press information\n");
- printf("6 - Get button release information\n");
- printf("7 - Set min & max horiz cursor position\n");
- printf("8 - Select next menu\n");
- printf("9 to EXIT");
- ClearKB();
-
- switch (function = getch())
- {
- case '0':
- MouseResetAndStatus(&mouseStatus, &numberOfButtons);
- cursorLevel = fUserSub = 0;
- SetCursor(0, 9);
- BlankLine();
- SetCursor(0, 9);
- printf("status = %d, # of buttons = %d",
- mouseStatus,
- numberOfButtons
- );
- SetCursor(0, 18);
- printf("Hit any key to EXIT");
- getch();
- break;
- case '1':
- ShowCursor();
-
- if (cursorLevel != 0)
- cursorLevel--;
-
- break;
- case '2':
- HideCursor();
- cursorLevel++;
- break;
- case '3':
- SetCursor(0, 4);
- printf("_____ button pressed at X=__, Y=__\n");
- printf("Press BOTH button to quit testing.");
- ShowCursor();
- MInput(&bStatus, &hPosition, &vPosition);
- while (bStatus != BOTH) {
- HideCursor();
- SetCursor(0, 4);
- BlankLine();
- SetCursor(0, 4);
- if (bStatus == LEFT)
- printf("LEFT ");
- else
- printf("RIGHT ");
- printf("button pressed at X=%d, Y=%d",
- hPosition,
- vPosition
- );
- ShowCursor();
- bStatus = 0;
- MInput(&bStatus, &hPosition, &vPosition);
- }
- HideCursor();
- SetCursor(0, 4);
- BlankLine();
- SetCursor(0, 5);
- BlankLine();
- break;
- case '4':
- SetCursor(0, 14);
- BlankLine();
- SetCursor(0, 14);
- printf("Input x and y : ");
- scanf("%u %u", &horizontalCoordinate, &verticalCoordinate);
- SetMouseCursorPosition(horizontalCoordinate,
- verticalCoordinate
- );
- break;
- case '5':
- SetCursor(0, 15);
- BlankLine();
- SetCursor(0, 15);
- printf("Input button (0 = Left, 1 = Right) : ");
- scanf("%d", &buttonPresses);
- GetButtonPressInformation(&status,
- &buttonPresses,
- &horizontalCursor,
- &verticalCursor
- );
- SetCursor(0, 15);
- BlankLine();
- SetCursor(0, 15);
- printf("M1 = %d, M2 = %d, M3 = %d, M4 = %d",
- status,
- buttonPresses,
- horizontalCursor,
- verticalCursor
- );
- SetCursor(0, 18);
- printf("Hit any key to EXIT");
- getch();
- break;
- case '6':
- SetCursor(0, 16);
- BlankLine();
- SetCursor(0, 16);
- printf("Input button (0 = Left, 1 = Right) : ");
- scanf("%d", &buttonPresses);
- GetButtonReleaseInformation(&status,
- &buttonPresses,
- &horizontalCursor,
- &verticalCursor
- );
- SetCursor(0, 16);
- BlankLine();
- SetCursor(0, 16);
- printf("M1 = %d, M2 = %d, M3 = %d, M4 = %d",
- status,
- buttonPresses,
- horizontalCursor,
- verticalCursor
- );
- SetCursor(0, 18);
- printf("Hit any key to EXIT");
- getch();
- break;
- case '7':
- SetCursor(0, 17);
- BlankLine();
- SetCursor(0, 17);
- printf("Input x min and x max : ");
- scanf("%u %u", &minimumPosition, &maximumPosition);
- SetMinimumAndMaximumHorizontalCursorPosition(minimumPosition,
- maximumPosition
- );
- break;
- case '8':
- Menu2();
- ShowCursor();
- return;
- default:
- break;
- }
-
- if (function == '1')
- HideCursor();
-
- BlankMenu();
-
- if (function == '1')
- ShowCursor();
-
- }
-
- void Menu2()
- {
-
- unsigned minimumPosition, maximumPosition;
- unsigned screenMask, cursorMask;
- int scanLineStart, scanLineStop;
- int horizontalCount, verticalCount;
- unsigned horizontalMickeyPixelRatio, verticalMickeyPixelRatio;
- unsigned callMask;
-
- BlankMenu();
- HideCursor();
- SetCursor(0, 7);
- printf("Select number to test mouse function");
- SetCursor(0, 9);
- printf("0 - Set min & max vert cursor position\n");
- printf("1 - Function #9 already tested\n");
- printf("2 - Set text cursor\n");
- printf("3 - Read mouse motion counters\n");
- printf("4 - Set int sub call mask & address\n");
- printf("5 - Light pen emulation mode on\n");
- printf("6 - Light pen emulation mode off\n");
- printf("7 - Set mickey/pixel ratio\n");
- printf("8 - Select next menu\n");
- printf("9 to EXIT");
- ClearKB();
-
- switch (getch())
- {
- case '0':
- SetCursor(0, 9);
- BlankLine();
- SetCursor(0, 9);
- printf("Input y min and y max : ");
- scanf("%u %u", &minimumPosition, &maximumPosition);
- SetMinimumAndMaximumVerticalCursorPosition(minimumPosition,
- maximumPosition
- );
- break;
- case '2':
- SetCursor(0, 11);
- BlankLine();
- SetCursor(0, 11);
- printf("Input cursor (0 = soft, 1 = hard) : ");
- if (getch() == '0')
- {
- SetCursor(0, 11);
- BlankLine();
- SetCursor(0, 11);
- printf("Input screen & cursor masks : ");
- scanf("%x %x", &screenMask, &cursorMask);
- SetTextCursor(0, screenMask, cursorMask);
- }
- else
- {
- SetCursor(0, 11);
- BlankLine();
- SetCursor(0, 11);
- printf("Input line start & line stop : ");
- scanf("%d %d", &scanLineStart, &scanLineStop);
- /* Must print message here since it moves cursor */
- SetCursor(0, 18);
- printf("Hit any key to EXIT");
- SetTextCursor(1, scanLineStart, scanLineStop);
- ShowCursor();
- ShowCursor();
- getch();
- HideCursor();
- HideCursor();
- }
- break;
- case '3':
- ReadMouseMotionCounters(&horizontalCount, &verticalCount);
- SetCursor(0, 12);
- BlankLine();
- SetCursor(0, 12);
- printf("horiz count = %d, vert count = %d",
- horizontalCount,
- verticalCount
- );
- SetCursor(0, 18);
- printf("Hit any key to EXIT");
- getch();
- break;
- case '4':
- SetCursor(0, 13);
- BlankLine();
- SetCursor(0, 13);
- printf("Input call mask : ");
- scanf("%x", &callMask);
- SetInterruptSubroutineCallMaskAndAddress(callMask, Function12);
- fUserSub++;
- break;
- case '5':
- LightPenEmulationModeOn();
- break;
- case '6':
- LightPenEmulationModeOff();
- break;
- case '7':
- SetCursor(0, 16);
- BlankLine();
- SetCursor(0, 16);
- printf("Input horiz & vert ratios : ");
- scanf("%u %u",
- &horizontalMickeyPixelRatio,
- &verticalMickeyPixelRatio
- );
- SetMickeyPixelRatio(horizontalMickeyPixelRatio,
- verticalMickeyPixelRatio
- );
- break;
- case '8':
- Menu3();
- ShowCursor();
- return;
- default:
- break;
- }
-
- BlankMenu();
- ShowCursor();
- }
-
- void Menu3()
- {
-
- unsigned conditionalOffRegion[4];
- unsigned thresholdSpeed;
- unsigned storageSize;
- unsigned eventMask;
- int errorStatus;
- unsigned callMask;
- unsigned segment, offset;
- void (*pFunction)();
-
- BlankMenu();
- HideCursor();
- SetCursor(0, 7);
- printf("Select number to test mouse function");
- SetCursor(0, 9);
- printf("0 - Conditional off\n");
- printf("1 - Set double-speed threshold\n");
- printf("2 - Swap interrupt subroutines\n");
- printf("3 - Get mouse storage requirements\n");
- printf("4 - Save & Restore mouse driver state\n");
- printf("5 - Save & Restore mouse driver state\n");
- printf("6 - Set alternate mouse user sub\n");
- printf("7 - Get user alternate int vector\n");
- printf("8 - Select next menu\n");
- printf("9 to EXIT");
- ClearKB();
-
- switch (getch())
- {
- case '0':
- SetCursor(0, 9);
- BlankLine();
- SetCursor(0, 9);
- printf("Input left x & upper y : ");
- scanf("%u %u",
- &conditionalOffRegion[0],
- &conditionalOffRegion[1]
- );
- SetCursor(0, 9);
- BlankLine();
- SetCursor(0, 9);
- printf("Input right x & lower y : ");
- scanf("%u %u",
- &conditionalOffRegion[2],
- &conditionalOffRegion[3]
- );
- SetCursor(0, 18);
- printf("Hit any key to EXIT");
- ShowCursor();
- ShowCursor();
- ShowCursor();
- ConditionalOff((int *)conditionalOffRegion);
- getch();
- HideCursor();
- HideCursor();
- HideCursor();
- break;
- case '1':
- SetCursor(0, 10);
- BlankLine();
- SetCursor(0, 10);
- printf("Input threshold speed : ");
- scanf("%u", &thresholdSpeed);
- SetDoubleSpeedThreshold(thresholdSpeed);
- break;
- case '2':
- SetCursor(0, 11);
- BlankLine();
- SetCursor(0, 11);
- printf("Input call mask : ");
- scanf("%x", &callMask);
- pFunction = Function12;
- segment = FP_SEG(pFunction);
- offset = FP_OFF(pFunction);
-
- /* Note: Segment doesn't need to be passed for small and compact models,
- mouse lib knows it */
-
- SwapInterruptSubroutines(&segment,
- &callMask,
- &offset
- );
- SetCursor(0, 11);
- BlankLine();
- SetCursor(0, 11);
- printf("segment:%x, offset:%x, call mask:%x",
- segment,
- offset,
- callMask
- );
- SetCursor(0, 18);
- printf("Hit any key to EXIT");
- getch();
- fUserSub++;
- break;
- case '3':
- SetCursor(0, 12);
- BlankLine();
- SetCursor(0, 12);
- GetMouseDriverStateStorageRequirements(&storageSize);
- printf("Required Storage Buffer Size = %d bytes", storageSize);
- SetCursor(0, 18);
- printf("Hit any key to EXIT");
- getch();
- break;
- case '4':
- case '5':
- SaveAndRestoreMouseDriverState();
- break;
- case '6':
- SetCursor(0, 15);
- BlankLine();
- SetCursor(0, 15);
- printf("Input event mask : ");
- scanf("%x", &eventMask);
- SetAlternateMouseUserSubroutine(&errorStatus,
- eventMask,
- Function12
- );
-
- if (errorStatus == -1)
- {
- SetCursor(0, 15);
- BlankLine();
- SetCursor(0, 15);
- printf("Error occured");
- SetCursor(0, 18);
- printf("Hit any key to EXIT");
- getch();
- }
- fUserSub++;
- break;
- case '7':
- SetCursor(0, 16);
- BlankLine();
- SetCursor(0, 16);
- printf("Input event mask : ");
- scanf("%x", &eventMask);
- GetUserAlternateInterruptVector(&segment, &eventMask, &offset);
- SetCursor(0, 16);
- BlankLine();
- SetCursor(0, 16);
- printf("segment:%x, offset:%x, event mask:%x",
- segment,
- offset,
- eventMask
- );
- SetCursor(0, 18);
- printf("Hit any key to EXIT");
- getch();
- break;
- case '8':
- Menu4();
- ShowCursor();
- return;
- default:
- break;
- }
-
- BlankMenu();
- ShowCursor();
- }
-
- void Menu4()
- {
-
- int horizontalSensitivity, verticalSensitivity, doubleSpeedThreshold;
- int interruptRate;
- int CRTPageNumber;
- int mouseStatus, numberOfButtons;
- unsigned segment, offset;
- int errorStatus;
-
- BlankMenu();
- HideCursor();
- SetCursor(0, 7);
- printf("Select number to test mouse function");
- SetCursor(0, 9);
- printf("0 - Set mouse sensitivity\n");
- printf("1 - Get mouse sensitivity\n");
- printf("2 - Set mouse maximum interrupt rate\n");
- printf("3 - Set CRT page number\n");
- printf("4 - Get CRT page number\n");
- printf("5 - Disable mouse driver\n");
- printf("6 - Enable mouse driver\n");
- printf("7 - Software reset\n");
- printf("8 - Select next menu\n");
- printf("9 to EXIT");
- ClearKB();
-
- switch (getch())
- {
- case '0':
- SetCursor(0, 9);
- BlankLine();
- SetCursor(0, 9);
- printf("Input horiz & vert sensitivity : ");
- scanf("%d %d", &horizontalSensitivity, &verticalSensitivity);
- SetCursor(0, 9);
- BlankLine();
- SetCursor(0, 9);
- printf("Input double speed threshold : ");
- scanf("%d", &doubleSpeedThreshold);
- SetMouseSensitivity(horizontalSensitivity,
- verticalSensitivity,
- doubleSpeedThreshold
- );
- break;
- case '1':
- GetMouseSensitivity(&horizontalSensitivity,
- &verticalSensitivity,
- &doubleSpeedThreshold
- );
- SetCursor(0, 10);
- BlankLine();
- SetCursor(0, 10);
- printf("horiz = %d, vert = %d, threshold = %d",
- horizontalSensitivity,
- verticalSensitivity,
- doubleSpeedThreshold
- );
- SetCursor(0, 18);
- printf("Hit any key to EXIT");
- getch();
- break;
- case '2':
- SetCursor(0, 11);
- BlankLine();
- SetCursor(0, 11);
- printf("Input interrupt rate : ");
- scanf("%d", &interruptRate);
- SetMouseInterruptRate(interruptRate);
- break;
- case '3':
- SetCursor(0, 12);
- BlankLine();
- SetCursor(0, 12);
- printf("Input CRT page number : ");
- scanf("%d", &CRTPageNumber);
- SetCRTPageNumber(CRTPageNumber);
- break;
- case '4':
- GetCRTPageNumber(&CRTPageNumber);
- SetCursor(0, 13);
- BlankLine();
- SetCursor(0, 13);
- printf("CRT page number = %d", CRTPageNumber);
- SetCursor(0, 18);
- printf("Hit any key to EXIT");
- getch();
- break;
- case '5':
- DisableMouseDriver(&errorStatus,
- &offset,
- &segment
- );
- if (errorStatus != 31)
- {
- SetCursor(0, 14);
- BlankLine();
- SetCursor(0, 14);
- printf("Error occured");
- }
- else
- {
- SetCursor(0, 14);
- BlankLine();
- SetCursor(0, 14);
- printf("segment:%x, offset:%x", segment, offset);
- }
- SetCursor(0, 18);
- printf("Hit any key to EXIT");
- getch();
- break;
- case '6':
- EnableMouseDriver();
- break;
- case '7':
- SoftwareReset(&mouseStatus, &numberOfButtons);
- cursorLevel = fUserSub = 0;
- SetCursor(0, 16);
- BlankLine();
- SetCursor(0, 16);
- printf("status = %d, # of buttons = %d",
- mouseStatus,
- numberOfButtons
- );
- SetCursor(0, 18);
- printf("Hit any key to EXIT");
- getch();
- break;
- case '8':
- Menu5();
- ShowCursor();
- return;
- default:
- break;
- }
-
- BlankMenu();
- ShowCursor();
- }
-
- void Menu5()
- {
-
- int languageNumber;
- int majorVersionNumber, minorVersionNumber, mouseType, IRQNumber;
-
- BlankMenu();
- HideCursor();
- SetCursor(0, 7);
- printf("Select number to test mouse function");
- SetCursor(0, 9);
- printf("0 - Set language number\n");
- printf("1 - Get language number\n");
- printf("2 - Get version number, type, and IRQ #");
- SetCursor(0, 17);
- printf("8 - Select first menu\n");
- printf("9 to EXIT");
- ClearKB();
-
- switch (getch())
- {
- case '0':
- SetCursor(0, 9);
- BlankLine();
- SetCursor(0, 9);
- printf("Input language number : ");
- scanf("%d", &languageNumber);
- SetLanguageForMessages(languageNumber);
- break;
- case '1':
- GetLanguageNumber(&languageNumber);
- SetCursor(0, 10);
- BlankLine();
- SetCursor(0, 10);
- printf("Language number = %d", languageNumber);
- SetCursor(0, 18);
- printf("Hit any key to EXIT");
- getch();
- break;
- case '2':
- GetDriverVersionMouseTypeAndIRQNumber(&majorVersionNumber,
- &minorVersionNumber,
- &mouseType,
- &IRQNumber
- );
- BlankMenu();
- SetCursor(0, 11);
- printf("Mouse driver version number = %x.%x\n",
- majorVersionNumber,
- minorVersionNumber
- );
- printf("Mouse type = %d, IRQ # = %d", mouseType, IRQNumber);
- SetCursor(0, 18);
- printf("Hit any key to EXIT");
- getch();
- break;
- case '8':
- FunctionSelect();
- ShowCursor();
- return;
- default:
- break;
- }
-
- BlankMenu();
- ShowCursor();
- }
-