home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / prog_c / input2.lzh / INPUT / INPUT.LZH / my_include / DeviceToolKits / Input.h next >
Encoding:
C/C++ Source or Header  |  1991-01-05  |  4.7 KB  |  170 lines

  1. /*
  2. ****************************************************************************
  3.  
  4.       Input Device ToolKit Subroutines.
  5.       Standard Include File.
  6.  
  7.       Input.h.
  8.       Version 1.1.
  9.  
  10.       Paris E. Bingham Jr.
  11.       Copyright © 1986 - 1990  All Rights Reserved.
  12.  
  13.  
  14.       History:
  15.  
  16.     Version      Date      Comments
  17.     -------    --------    -----------------------------------------------
  18.       1.0      12/01/89    PEB - Created.
  19.       1.1      09/04/90    PEB - Add support for Manx C V5.0.
  20.                09/22/90    PEB - Add support for SAS C V5.10.
  21.  
  22. ****************************************************************************
  23. */
  24.  
  25. #ifndef  DT_INPUT_H
  26. #define  DT_INPUT_H
  27.  
  28. /*
  29.       Compiler Definitions
  30. */
  31.  
  32. #ifdef   SAS
  33. #define  ANSI_PROTO        1
  34. #endif
  35.  
  36. #ifdef   MANXV3
  37. #undef   ANSI_PROTO
  38. #undef   NO_PRAGMAS
  39. #define  NO_PRAGMAS        1
  40. #define  MANX              1
  41. #endif
  42.  
  43. #ifdef   MANXV5
  44. #define  ANSI_PROTO        1
  45. #define  MANX              1
  46. #endif
  47.  
  48. /*
  49.       Include Files
  50. */
  51.  
  52. #include <exec/types.h>
  53. #include <exec/exec.h>
  54. #include <exec/execbase.h>
  55. #include <exec/interrupts.h>
  56. #include <devices/input.h>
  57. #include <devices/gameport.h>
  58. #include <devices/timer.h>
  59. #include <devices/inputevent.h>
  60.  
  61. #ifdef   SAS
  62. #include <proto/exec.h>
  63. #endif
  64.  
  65. #ifdef   MANX
  66. #ifndef  NOPRAGMAS
  67. #include <pragmas.h>
  68. #else
  69. #include <functions.h>
  70. #endif
  71. #endif
  72.  
  73. /*
  74.       Definitions
  75. */
  76.  
  77. /*
  78. ****************************************************************************
  79.       DTInput - Input Control Structure
  80. ****************************************************************************
  81. */
  82.  
  83. struct   DTInput  {
  84.    ULONG                in_flags;            /* Control flags */
  85.    struct   MsgPort     *in_wport;           /* Write reply port */
  86.    struct   IOStdReq    *in_wreq;            /* Write request block */
  87.    struct   MsgPort     *in_tport;           /* Timer reply port */
  88.    struct   timerequest *in_treq;            /* Timer request block */
  89.    LONG                 in_error;            /* Error on request */
  90. };
  91.  
  92. /*  Flag bits  */
  93. #define  DTINB_GOTWPORT    0                 /* Got write reply port */
  94. #define  DTINF_GOTWPORT    (1 << DTINB_GOTWPORT)
  95.  
  96. #define  DTINB_GOTWREQB    1                 /* Got write request block */
  97. #define  DTINF_GOTWREQB    (1 << DTINB_GOTWREQB)
  98.  
  99. #define  DTINB_GOTTPORT    2                 /* Got timer reply port */
  100. #define  DTINF_GOTTPORT    (1 << DTINB_GOTWPORT)
  101.  
  102. #define  DTINB_GOTTREQB    3                 /* Got timer request block */
  103. #define  DTINF_GOTTREQB    (1 << DTINB_GOTTREQB)
  104.  
  105. #define  DTINB_GOTDEVICE   4                 /* Got device */
  106. #define  DTINF_GOTDEVICE   (1 << DTINB_GOTDEVICE)
  107.  
  108. #define  DTINB_INIT        5                 /* All done */
  109. #define  DTINF_INIT        (1 << DTINB_INIT)
  110.  
  111. #define  DTINB_COPY        6                 /* Is copy */
  112. #define  DTINF_COPY        (1 << DTINB_COPY)
  113.  
  114. /*  Typedef for User */
  115. typedef  struct   DTInput  *DTInput_t;
  116.  
  117.  
  118. /*
  119. ****************************************************************************
  120.       Error Codes
  121. ****************************************************************************
  122. */
  123.  
  124. #define  DTINE_NO_ERROR       0L             /* No error */
  125. #define  DTINE_NO_STRUCTURE   1L             /* No control structure */
  126. #define  DTINE_NO_WPORT       2L             /* Write reply port not alloc. */
  127. #define  DTINE_NO_WREQB       3L             /* Write req. not alloc. */
  128. #define  DTINE_NO_TPORT       4L             /* Timer reply port not alloc. */
  129. #define  DTINE_NO_TREQB       5L             /* Timer req. not alloc. */
  130. #define  DTINE_NO_DEVICE      6L             /* Device not opened */
  131. #define  DTINE_NO_INIT        7L             /* Control not initialized */
  132. #define  DTINE_NO_DATA        8L             /* No pointer to data */
  133. #define  DTINE_NO_LENGTH      9L             /* No data length */
  134.  
  135.  
  136. /*
  137. ****************************************************************************
  138.       Useful Macros
  139. ****************************************************************************
  140. */
  141.  
  142. #define  DTInputFree(i)          { DTInputDestroy(i); i = NULL; }
  143. #define  DTInputWriteLength(c)   ((i)->in_wreq->io_Actual)
  144.  
  145. #ifndef  DTBuildStdRequest
  146. #define  DTBuildStdRequest(r,c,f,o,d,l) \
  147.    { (r)->io_Command = (UWORD) c; \
  148.      (r)->io_Flags = (UBYTE) f; \
  149.      (r)->io_Offset = (ULONG) o; \
  150.      (r)->io_Data = (APTR) d; \
  151.      (r)->io_Length = (ULONG) l; }
  152. #endif
  153.  
  154. #ifndef  DTBuildTimerRequest
  155. #define  DTBuildTimerRequest(t,c,f,s,m) \
  156.    { (t)->tr_node.io_Command = (UWORD) c; \
  157.      (t)->tr_node.io_Flags = (UBYTE) f; \
  158.      (t)->tr_time.tv_secs = (ULONG) s; \
  159.      (t)->tr_time.tv_micro = (ULONG) m; }
  160. #endif
  161.  
  162. /*
  163. ****************************************************************************
  164.       End of Input.h
  165. ****************************************************************************
  166. */
  167.  
  168. #endif
  169.  
  170.