home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 377b.lha / devices / input / inputset.c < prev    next >
Encoding:
C/C++ Source or Header  |  1980-02-03  |  2.5 KB  |  67 lines

  1. /* Copyright (c) 1990 Commodore-Amiga, Inc.
  2.  *
  3.  * This example is provided in electronic form by Commodore-Amiga, Inc. for
  4.  * use with the 1.3 revisions of the Addison-Wesley Amiga reference manuals.
  5.  * The 1.3 Addison-Wesley Amiga Reference Manual series contains additional
  6.  * information on the correct usage of the techniques and operating system
  7.  * functions presented in this example.  The source and executable code of
  8.  * this example may only be distributed in free electronic form, via bulletin
  9.  * board or as part of a fully non-commercial and freely redistributable
  10.  * diskette.  Both the source and executable code (including comments) must
  11.  * be included, without modification, in any copy.  This example may not be
  12.  * published in printed form or distributed with any commercial product.
  13.  * However, the programming techniques and support routines set forth in
  14.  * this example may be used in the development of original executable
  15.  * software products for Commodore Amiga computers.
  16.  * All other rights reserved.
  17.  * This example is provided "as-is" and is subject to change; no warranties
  18.  * are made.  All use is at your own risk.  No liability or responsibility
  19.  * is assumed.
  20.  */
  21.  
  22. /*
  23.  * InputDevice example
  24.  *
  25.  * This example changes the threshold and period of the key repeat...
  26.  */
  27.  
  28. #include <exec/types.h>
  29. #include <exec/memory.h>
  30. #include <devices/input.h>
  31. #include <devices/timer.h>
  32.  
  33. #include <proto/all.h>
  34.  
  35. VOID main(VOID)
  36. {
  37. struct timerequest *inputReqBlk;
  38. struct MsgPort     *inputPort;
  39.  
  40.     if (inputPort=CreatePort(NULL,NULL))
  41.     {
  42.         if (inputReqBlk=(struct timerequest *)CreateExtIO(inputPort,
  43.                                                   sizeof(struct timerequest)))
  44.         {
  45.             if (!OpenDevice("input.device",NULL,
  46.                              (struct IORequest *)inputReqBlk,NULL))
  47.             {
  48.                 inputReqBlk->tr_node.io_Command=IND_SETTHRESH;
  49.                 inputReqBlk->tr_time.tv_secs=1;
  50.                 inputReqBlk->tr_time.tv_micro=500000;  /* 1.5 seconds */
  51.  
  52.                 DoIO((struct IORequest *)inputReqBlk);
  53.  
  54.                 inputReqBlk->tr_node.io_Command=IND_SETPERIOD;
  55.                 inputReqBlk->tr_time.tv_secs=0;
  56.                 inputReqBlk->tr_time.tv_micro=12000;  /* .012 seconds */
  57.  
  58.                 DoIO((struct IORequest *)inputReqBlk);
  59.  
  60.                 CloseDevice((struct IORequest *)inputReqBlk);
  61.             }
  62.             DeleteExtIO((struct IORequest *)inputReqBlk);
  63.         }
  64.         DeletePort(inputPort);
  65.     }
  66. }
  67.