home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cenvi23.zip / KBDRATE.CMD < prev    next >
OS/2 REXX Batch file  |  1995-03-28  |  2KB  |  73 lines

  1. EXTPROC CEnvi2
  2. /********************************************************************
  3.  *** KbdRate.cmd - CEnvi2 sample file which will, on most systems, ***
  4.  *** ver.1         set the keyboard typematic values.             ***
  5.  ********************************************************************/
  6.  
  7. #define MIN_DELAY    1
  8. #define MAX_DELAY    5000
  9. #define MIN_RATE     1
  10. #define MAX_RATE     5000
  11.  
  12. main(argc,argv)
  13. {
  14.    if ( argc != 3 )
  15.       Instructions()
  16.    else {
  17.       // check input values for valid ranges
  18.       delay = atoi(argv[1]);
  19.       rate = atoi(argv[2]);
  20.       if ( delay < MIN_DELAY  ||  MAX_DELAY < delay
  21.         || rate < MIN_RATE  ||  MAX_RATE < rate ) {
  22.          printf("\aInvalid input value; enter /? for instructions\n");
  23.       } else {
  24.          SetDelayAndRate(delay,rate);
  25.       }
  26.    }
  27. }
  28.  
  29. SetDelayAndRate(delay,rate)  // DynamicLink to Dos Calls to set rate and delay
  30. {
  31.    // Open $Kbd device
  32.    #define ORD_DOS32OPEN   273
  33.    rc = DynamicLink("doscalls",ORD_DOS32OPEN,BIT32,CDECL,
  34.                     "\\DEV\\KBD$",FileHandle,ActionTaken,0,
  35.                     0,0x01,0x40,0);
  36.    assert( 0 == rc );
  37.  
  38.    // call DosDevIOCTL to set kbd delay and rate
  39.    #define ORD_DOS32DEVIOCTL     284
  40.    #define KEYBOARD_CATEGORY     4
  41.    #define KBD_SETTYPAMATICRATE  0x0054
  42.    BLObPut(Parms,delay,UWORD16);
  43.    BLObPut(Parms,rate,UWORD16);
  44.    // rc = DosDevIOCtl(DevHandle, ulCategory,
  45.    //      ulFunction, pParmList,
  46.    //      ulParmLengthMax,
  47.    //      pParmLengthInOut, pDataArea,
  48.    //      ulDataLengthMax, pDataLengthInOut);
  49.    DynamicLink("doscalls",ORD_DOS32DEVIOCTL,BIT32,CDECL,
  50.                FileHandle,KEYBOARD_CATEGORY,KBD_SETTYPAMATICRATE,
  51.                Parms,BLObSize(Parms),NULL,NULL,0,NULL);
  52.  
  53.    // close device
  54.    #define ORD_DOS32CLOSE  257
  55.    DynamicLink("doscalls",ORD_DOS32CLOSE,BIT32,CDECL,FileHandle);
  56. }
  57.  
  58.  
  59.  
  60.  
  61. Instructions()
  62. {
  63.    printf("\n")
  64.    printf("KbdRate - Set keyboard typematic rates.  This works with most BIOS's\n")
  65.    printf("\n")
  66.    printf("USAGE: KbdRate Delay Rate\n")
  67.    printf("\n")
  68.    printf("Where: Delay - Delay in milliseconds before repeat; min = %d, max = %d\n",MIN_DELAY,MAX_DELAY);
  69.    printf("       Rate  - Repetitions of key per second; min = %d, max = %d\n",MIN_RATE,MAX_RATE);
  70.    printf("\n")
  71. }
  72.  
  73.