home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Washington_1988 / DevCon88.1 / Takeover / idio.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  3.8 KB  |  141 lines

  1. /*********************************************************************/
  2. /*                                                                   */
  3. /*                     Copyright (c) 1985                            */
  4. /*                    Commodore-Amiga, Inc.                          */
  5. /*                    All rights reserved.                           */
  6. /*                                                                   */
  7. /*     No part of this program may be reproduced, transmitted,       */
  8. /*     transcribed, stored in retrieval system, or translated        */
  9. /*     into any language or computer language, in any form or        */
  10. /*     by any means, electronic, mechanical, magnetic, optical,      */
  11. /*     chemical, manual or otherwise, without the prior written      */
  12. /*     permission of:                                                */
  13. /*                     Commodore-Amiga, Inc.                         */
  14. /*                     983 University Ave #D                         */
  15. /*                     Los Gatos, CA. 95030                          */
  16. /*                                                                   */
  17. /*********************************************************************/
  18.  
  19. /*********************************************************************/
  20. /*                                                                   */
  21. /*  Program name:  idio                                              */
  22. /*                                                                   */
  23. /*  Purpose:  To provide standard input device interface routines    */
  24. /*                                                                   */
  25. /*********************************************************************/
  26.  
  27. #include "exec/types.h"
  28. #include "exec/nodes.h"
  29. #include "exec/lists.h"
  30. #include "exec/ports.h"
  31. #include "exec/interrupts.h"
  32. #include "exec/io.h"
  33.  
  34. #include "../inputevent.h"
  35. #include "../input.h"
  36.  
  37. struct IOStdReq inputIO = 0;
  38. struct IOStdReq inputREADIO = 0;
  39. struct MsgPort inputMsgPort = 0;
  40. UBYTE inputReadChar = 0;
  41.  
  42. int IDOpen()
  43. {
  44.     int error;
  45.         
  46. /* Open the input device */
  47.     if ((error = OpenDevice("input.device", 0, &inputIO, 0)) != 0)
  48.     {
  49.         kprintf("IDInit OpenDevice error: %d.\n", error);
  50.         return(error);
  51.     }
  52.  
  53. /* Set up the message port in the I/O request */
  54.     inputMsgPort.mp_Node.ln_Type = NT_MSGPORT;
  55.     inputMsgPort.mp_Node.ln_Name = "IDIO";
  56.     inputMsgPort.mp_Flags = 0;
  57.     inputMsgPort.mp_SigBit = AllocSignal(-1);
  58.     inputMsgPort.mp_SigTask = (struct Task *) FindTask((char *) NULL);
  59.     AddPort(&inputMsgPort);
  60.     inputIO.io_Message.mn_ReplyPort = &inputMsgPort;
  61.  
  62.     return(0);
  63. }
  64.  
  65.  
  66. IDClose()
  67. {
  68.     CloseDevice(&inputIO);
  69.     FreeSignal(inputMsgPort.mp_SigBit);
  70.     RemPort(&inputMsgPort);
  71. }
  72.  
  73.  
  74. IDStop()
  75. {
  76.     inputIO.io_Command = CMD_STOP;
  77.     DoIO(&inputIO);
  78. }
  79.  
  80.  
  81. IDStart()
  82. {
  83.     inputIO.io_Command = CMD_START;
  84.     DoIO(&inputIO);
  85. }
  86.  
  87.  
  88. IDAddHandler(handler)
  89. struct Interrupt *handler;
  90. {
  91.     inputIO.io_Command = IND_ADDHANDLER;
  92.     inputIO.io_Data = handler;
  93.     inputIO.io_Length = sizeof(struct Interrupt);
  94.     DoIO(&inputIO);
  95. }
  96.  
  97.  
  98. IDRemHandler(handler)
  99. struct Interrupt *handler;
  100. {
  101.     inputIO.io_Command = IND_REMHANDLER;
  102.     inputIO.io_Data = handler;
  103.     inputIO.io_Length = sizeof(struct Interrupt);
  104.     DoIO(&inputIO);
  105. }
  106.  
  107.  
  108. IDWriteEvent(event)
  109. struct InputEvent *event;
  110. {
  111.     inputIO.io_Command = IND_WRITEEVENT;
  112.     inputIO.io_Data = event;
  113.     inputIO.io_Length = sizeof(struct InputEvent);
  114.     DoIO(&inputIO);
  115. }
  116.  
  117.  
  118. IDSetRepeat(thresh, period)
  119. struct timeval *thresh;
  120. struct timeval *period;
  121. {
  122.     inputIO.io_Command = IND_SETTHRESH;
  123.     inputIO.io_Data = thresh;
  124.     inputIO.io_Length = sizeof(struct timeval);
  125.     DoIO(&inputIO);
  126.     inputIO.io_Command = IND_SETPERIOD;
  127.     inputIO.io_Data = period;
  128.     inputIO.io_Length = sizeof(struct timeval);
  129.     DoIO(&inputIO);
  130. }
  131.  
  132.  
  133. IDMPort(port)
  134. UBYTE port;
  135. {
  136.     inputIO.io_Command = IND_SETMPORT;
  137.     inputIO.io_Data = &port;
  138.     inputIO.io_Length = 1;
  139.     DoIO(&inputIO);
  140. }
  141.