home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / fish / libraries / input_446 / src / devicetoolkits / input / test_proto / test7.c < prev   
C/C++ Source or Header  |  1991-01-05  |  2KB  |  83 lines

  1. #include <stdio.h>
  2.  
  3. #include "DeviceToolKits/Input.h"
  4. #ifndef  TESTPROTO
  5. #define  NO_PRAGMAS  1
  6. #endif
  7. #include "DeviceToolKits/proto/Input.h"
  8. #include "DeviceToolKits/InputBase.h"
  9.  
  10. DTInput_t         Unit0;
  11. struct   timeval  period;
  12. struct   timeval  threshold;
  13.  
  14. main(argc,argv)
  15. int   argc;
  16. char  *argv[];
  17. {
  18.    int   period_s, period_u;
  19.    int   threshold_s, threshold_u;
  20.    long  status;
  21.  
  22.    if (argc != 5) {
  23.       fprintf(stderr,"Usage: %s period_s period_u thresh_s thresh_u\n",
  24.                argv[0]);
  25.       fflush(stderr);
  26.       exit(1);
  27.    }
  28.  
  29.    period_s = atoi(argv[1]);
  30.    period_u = atoi(argv[2]);
  31.    period.tv_secs = period_s;
  32.    period.tv_micro = period_u;
  33.  
  34.    threshold_s = atoi(argv[3]);
  35.    threshold_u = atoi(argv[4]);
  36.    threshold.tv_secs = threshold_s;
  37.    threshold.tv_micro = threshold_u;
  38.  
  39. #ifdef   TESTSHARED
  40. /*  Open the Input library  */
  41.  
  42.    DTInputOpen(DTINPUTREV);
  43. #endif
  44.  
  45. /*  Try to initialize unit 0 of the Input  */
  46.  
  47.    if ((Unit0 = DTInputCreate(&status)) == NULL) {
  48.       fprintf(stderr,"Error initializing unit 0 = %ld.\n",status);
  49.       fflush(stderr);
  50.       goto cleanup;
  51.    }
  52.  
  53.    fprintf(stderr,"Unit0 = %lX\n",(long) Unit0);
  54.    fflush(stderr);
  55.  
  56. /*  Set the keyboard repeat threshold  */
  57.  
  58.    if ((status = DTInputSetThresh(Unit0,&threshold)) != 0) {
  59.       fprintf(stderr,"Error setting unit 0 threshold = %ld,%ld.\n",
  60.                status,Unit0->in_error);
  61.       fflush(stderr);
  62.       goto cleanup;
  63.    }
  64.  
  65. /*  Set the keyboard repeat period  */
  66.  
  67.    if ((status = DTInputSetPeriod(Unit0,&period)) != 0) {
  68.       fprintf(stderr,"Error setting unit 0 period = %ld,%ld.\n",
  69.                status,Unit0->in_error);
  70.       fflush(stderr);
  71.       goto cleanup;
  72.    }
  73.  
  74. /*  Free the stuff  */
  75.  
  76. cleanup:
  77.    DTInputFree(Unit0);
  78. #ifdef   TESTSHARED
  79.    DTInputClose();
  80. #endif
  81. }
  82.  
  83.