home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / at / xkb.arc / XKB.C next >
Text File  |  1989-12-10  |  1KB  |  50 lines

  1. /* xkb.c - changes the keyboard repeat rate and the delay
  2.               (maximum) 30/cps : (minimum) delay 250 msec    */
  3.  
  4. #include <dos.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7.  
  8. union REGS rin,rout;
  9. void print_error();
  10.  
  11. main(ac,av)
  12.  
  13. int ac;
  14. char *av[];
  15.  
  16. {
  17.     unsigned int int1,int2;
  18.  
  19.     if(ac < 3)
  20.         {
  21.         print_error();
  22.         exit(1);
  23.         }
  24.     int1 = atoi(av[1]);                /* atoi() returns 0 if not number */
  25.     int2 = atoi(av[2]);           /* if non-numbers are entered as
  26.                                                 arguments, the results are the
  27.                                                 same as : XKB 0 0              */
  28.  
  29.     if(int1 >= 0 && int1 < 4 && int2 >= 0 && int2 < 33)
  30.         {
  31.         rin.h.ah = 0x03;                /* function 03H of INT 16H */
  32.         rin.h.al = 0x05;
  33.  
  34.         rin.h.bh = int1;                /* delay 00H-03H (250-1000 msec) */
  35.         rin.h.bl = int2;                /* repeat rate 00H-1FH (2-30cps) */
  36.  
  37.         int86(0x16,&rin,&rout);        /* call INT 16H   */
  38.         }
  39.     else
  40.         print_error();
  41. }
  42.  
  43. void print_error()
  44.  
  45. {
  46.     fprintf(stderr,"\nChange Keyboard Delay and Repeat Rate :\n");
  47.     fprintf(stderr,"   USAGE : XKB num1 num2\n");
  48.     fprintf(stderr,"              (0-3) (0-32)\n");
  49.     fprintf(stderr,"** XKB 0 0 (fast) ** XKB 3 32 (slow) **\n");
  50. }