home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / flash-c1.zip / KBDDEMO.C < prev    next >
Text File  |  1990-02-11  |  4KB  |  195 lines

  1. #include <fpclib.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <conio.h>
  6.  
  7. void TestBiosKbdClr( void );
  8. void TestBiosKbdGetElmt( void );
  9. void TestBiosKbdHit( void );
  10. void TestBiosKbdRead( void );
  11. void TestBiosKbdStat( void );
  12. void TestDosKbdClr( void );
  13. void TestDosKbdGetElmt( void );
  14. void TestDosKbdHit( void );
  15. void TestDosKbdRead( void );
  16. int  GetMenuSelection( void );
  17.  
  18.  
  19. void TestBiosKbdClr()
  20. {
  21.    char Ch = 0;
  22.    int  i;
  23.  
  24.    printf( "BiosKbdClr - Press 'A' to quit\n" );
  25.    while ( Ch != 'A' ) {
  26.       for ( i = 0; i < 20000; i++ )
  27.       ;
  28.       BiosKbdClr();
  29.       Ch = ReadKey();
  30.       printf( "%c", Ch );
  31.    }
  32. };
  33.  
  34. void TestBiosKbdGetElmt()
  35. {
  36.    int Ch = 0;
  37.  
  38.    printf( "BiosKbdGetElmt - Press [ESC] to quit\n" );
  39.    while ( Ch != 1 ) {
  40.       Ch = BiosKbdGetElmt();
  41.       printf( "Ch = %c ==> %u\n", (Ch < 133) ? (Ch) : (Ch-132), Ch );
  42.    }
  43. };
  44.  
  45. void TestBiosKbdHit()
  46. {
  47.    BiosKbdClr();
  48.    while ( !BiosKbdHit() )
  49.       printf( "Press any key to end test\n" );
  50. };
  51.  
  52. void TestBiosKbdRead()
  53. {
  54.    char St[3];
  55.  
  56.    printf( "BiosKbdRead - Press 'A' to quit\n" );
  57.    St[0] = 0;
  58.    while ( St[0] != 'A' ) {
  59.       BiosKbdRead( St );
  60.       printf( "St = %s   St[0] = %c  St[1] = %c   Len = %u\n",
  61.                St, St[0], St[1], strlen( St ) );
  62.    }
  63. };
  64.  
  65. void TestBiosKbdStat()
  66. {
  67.    char  St[9];
  68.    int   Ch = 0,Stat,i,Remainder;
  69.  
  70.    ClrWin( 1, 1, 80, 25, 7 );
  71.    memset( St, 0, 9 );
  72.  
  73.    printf( "BiosKbdStat - Press any key to quit\n" );
  74.    while ( !Ch ) {
  75.       GotoxyAbs( 1, 1 );
  76.       Stat = BiosKbdStat();
  77.  
  78.       for ( i = 0; i < 8; St[i++] = '0' )
  79.       ;
  80.  
  81.       for ( i = 7; i >= 0 && Stat > 0; i-- ) {
  82.          Remainder = Stat % 2;
  83.          St[i] = Remainder + 48;
  84.          Stat /= 2;
  85.       }
  86.  
  87.       printf( "BiosKbdStat = %s \n", St );
  88.       Ch = BiosKbdGetElmt();
  89.    }
  90. }
  91.  
  92. void TestDosKbdClr()
  93. {
  94.    char Ch = 0;
  95.    int  i  = 0;
  96.  
  97.    printf( "DosKbdClr - Press 'A' to quit\n" );
  98.    while ( Ch != 'A' ) {
  99.       for ( i = 0; i < 32767; i++ )
  100.       ;
  101.       DosKbdClr();
  102.       Ch = ReadKey();
  103.       printf( "%c", Ch );
  104.    }
  105. };
  106.  
  107. void TestDosKbdGetElmt()
  108. {
  109.    int Ch = 0;
  110.  
  111.    printf( "DosKbdGetElmt - Press 'A' to quit\n" );
  112.    while ( Ch != 197 ) {
  113.       Ch = DosKbdGetElmt();
  114.       printf( "Ch = %c ==> %u\n", (Ch < 133) ? (Ch) : (Ch-132), Ch );
  115.    }
  116. }
  117.  
  118. void TestDosKbdHit()
  119. {
  120.    printf( "DosKbdClr - Press any key to quit\n" );
  121.    DosKbdClr();
  122.    while ( !DosKbdHit() )
  123.       printf( "Press any key to end test\n" );
  124.  
  125. }
  126.  
  127. void TestDosKbdRead()
  128. {
  129.    char St[3];
  130.  
  131.    printf( "DosKbdRead - Press 'A' to quit\n" );
  132.    St[0] = '\0';
  133.    while ( St[0] != 'A' ) {
  134.       DosKbdRead( St );
  135.       printf( "St = %s   St[0] = %u   St[1] = %u     ", St, St[0], St[1] );
  136.       printf( "Len = %u   \n", strlen( St ) );
  137.    }
  138. }
  139.  
  140. int GetMenuSelection()
  141. {
  142.    int Item;
  143.  
  144.    ClrWin( 1, 1, 80, 25, 7 );
  145.    GotoxyAbs(1,1);
  146.  
  147.    printf( "\n 1. BiosKbdClr      " );
  148.    printf( "\n 2. BiosKbdGetElmt  " );
  149.    printf( "\n 3. BiosKbdHit      " );
  150.    printf( "\n 4. BiosKbdRead     " );
  151.    printf( "\n 5. BiosKbdStat     " );
  152.    printf( "\n 6. DosKbdClr       " );
  153.    printf( "\n 7. DosKbdGetElmt   " );
  154.    printf( "\n 8. DosKbdHit       " );
  155.    printf( "\n 9. DosKbdRead      " );
  156.    printf( "\n" );
  157.    printf( "\n 0. Quit" );
  158.    printf( "\n" );
  159.    printf( "\nEnter selection to test ==> " );
  160.  
  161.    do {
  162.  
  163.       Item = ReadKey() - 48;
  164.  
  165.    } while ( Item < 0 || Item > 9 );
  166.  
  167.    printf( "\n\n" );
  168.    return( Item );
  169. }
  170.  
  171. void main( void )
  172. {
  173.    int done = 0;
  174.  
  175.    VioInit();
  176.  
  177.    ClrWin( 1, 1, 80, 25, 7 );
  178.    GotoxyAbs( 1, 1 );
  179.  
  180.    while ( !done ) {
  181.       switch ( GetMenuSelection() ) {
  182.           case 0 : done = 1;               break;
  183.           case 1 : TestBiosKbdClr();       break;
  184.           case 2 : TestBiosKbdGetElmt();   break;
  185.           case 3 : TestBiosKbdHit();       break;
  186.           case 4 : TestBiosKbdRead();      break;
  187.           case 5 : TestBiosKbdStat();      break;
  188.           case 6 : TestDosKbdClr();        break;
  189.           case 7 : TestDosKbdGetElmt();    break;
  190.           case 8 : TestDosKbdHit();        break;
  191.           case 9 : TestDosKbdRead();       break;
  192.       };
  193.    };
  194. }
  195.