home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c222 / 1.ddi / DEMOS / MS_TEST.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-14  |  2.1 KB  |  79 lines

  1. /*********************
  2.  *
  3.  *  ms_test.c - mouse test program.
  4.  *
  5.  *  Purpose: This file contains functions to test a mouse.
  6.  *
  7.  *  Blackstar C Function Library
  8.  *  (c) Copyright 1985 Sterling Castle Software
  9.  *
  10.  *******/
  11.  
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <dos.h>
  15. #include "blackstr.h"
  16. #include "gr_head.h"
  17. #include "sc_head.h"
  18. #include "ms_head.h"
  19.  
  20. void main()
  21. {
  22.     int i;
  23.     struct SREGS segs;
  24.  
  25.     /******************************************************
  26.      INITIALIZE SYSTEM AND SCREEN FOR PROPER ADAPTER TYPE
  27.     *******************************************************/
  28.     kb_init(NULL,NULL,NULL);
  29.     sc_init(NUL,NUL,NUL);          /* just get current parms */
  30.     if(!ms_stat()) {
  31.     sc_clr();
  32.     sc_puts("\n\rSorry, no mouse driver detected.\n");
  33.     exit(0);
  34.     }
  35.     switch (sc_adp_) {
  36.     case MON_ADP:
  37.         sc_clr();
  38.         sy_beep();
  39.         sc_puts("\n\rSorry, you need a color adapter to run this demo.\n");
  40.         exit(0);
  41.  
  42.     case CGA_ADP:
  43.         gr_init(GR320,WHITE,BLUE,gr_cgap1_);
  44.         break;
  45.  
  46.     case EGA_ADP:
  47.         gr_init(EGA_10,WHITE,BLUE,NULL);
  48.         break;
  49.  
  50.     default:
  51.         sc_puts("Screen adapter not recognized..\n\r");
  52.         exit(0);
  53.     }
  54.  
  55.     /**************************************************
  56.      JUST MOVE ON SCREEN AND SHOW/HIDE CURSOR
  57.     ***************************************************/
  58.     sc_puts("Starting mouse tests\n\r");
  59.     sc_puts(" Move mouse   - move cursor on screen\n\r");
  60.     sc_puts(" Left button  - mouse cursor on\n\r");
  61.     sc_puts(" Right button - mouse cursor off\n\r");
  62.     sc_puts(" Both buttons - end test\n\r");
  63.  
  64.     ms_init();                          /* set up mouse cursor     */
  65.     ms_cset(250,100);                   /* initial cursor position */
  66.  
  67.     while((mlbut_ | mrbut_)!= 0x03) {
  68.     while(!ms_press());             /* wait for button down    */
  69.     for (i = 0; i < 2000; i++);     /* wait for de-bounce      */
  70.     ms_press();                     /* get updated value       */
  71.     if (mlbut_ != 0)
  72.         ms_cson();
  73.     if (mrbut_ != 0)
  74.         ms_csof();
  75.     }
  76.     sc_init(MO_BW80,BLACK,WHITE);
  77.     sc_clr();
  78. }
  79.