home *** CD-ROM | disk | FTP | other *** search
/ Total Meltdown / dukenukemtotalmeltdown.img / util / dukectrl / control.h next >
C/C++ Source or Header  |  1996-02-13  |  4KB  |  173 lines

  1. //***************************************************************************
  2. //
  3. // Public header for CONTROL.C.
  4. //
  5. //***************************************************************************
  6.  
  7. #ifndef _control_public
  8. #define _control_public
  9.  
  10.  
  11. //***************************************************************************
  12. //
  13. // DEFINES
  14. //
  15. //***************************************************************************
  16.  
  17. #define MaxJoys             2
  18. #define MAXGAMEBUTTONS      64
  19.  
  20. #define BUTTON(x) \
  21.     ( \
  22.     ((x)>31) ? \
  23.     ((CONTROL_ButtonState2>>( (x) - 32) ) & 1) :\
  24.     ((CONTROL_ButtonState1>> (x) ) & 1)          \
  25.     )
  26. #define BUTTONHELD(x) \
  27.     ( \
  28.     ((x)>31) ? \
  29.     ((CONTROL_ButtonHeldState2>>((x)-32)) & 1) :\
  30.     ((CONTROL_ButtonHeldState1>>(x)) & 1)\
  31.     )
  32.  
  33.  
  34. //***************************************************************************
  35. //
  36. // TYPEDEFS
  37. //
  38. //***************************************************************************
  39. typedef enum
  40.    {
  41.    axis_up,
  42.    axis_down,
  43.    axis_left,
  44.    axis_right
  45.    } axisdirection;
  46.  
  47. typedef enum
  48.    {
  49.    analog_turning=0,
  50.    analog_strafing=1,
  51.    analog_lookingupanddown=2,
  52.    analog_elevation=3,
  53.    analog_rolling=4,
  54.    analog_moving=5,
  55.    analog_maxtype
  56.    } analogcontrol;
  57.  
  58. typedef enum
  59.    {
  60.    dir_North,
  61.    dir_NorthEast,
  62.    dir_East,
  63.    dir_SouthEast,
  64.    dir_South,
  65.    dir_SouthWest,
  66.    dir_West,
  67.    dir_NorthWest,
  68.    dir_None
  69.    } direction;
  70.  
  71. typedef struct
  72.    {
  73.    boolean   button0;
  74.    boolean   button1;
  75.    direction dir;
  76.    } UserInput;
  77.  
  78. typedef struct
  79.    {
  80.    fixed     dx;
  81.    fixed     dy;
  82.    fixed     dz;
  83.    fixed     dyaw;
  84.    fixed     dpitch;
  85.    fixed     droll;
  86.    } ControlInfo;
  87.  
  88. typedef enum
  89.    {
  90.    controltype_keyboard,
  91.    controltype_keyboardandmouse,
  92.    controltype_keyboardandjoystick,
  93.    controltype_keyboardandexternal,
  94.    controltype_keyboardandgamepad,
  95.    controltype_keyboardandflightstick,
  96.    controltype_keyboardandthrustmaster
  97.    } controltype;
  98.  
  99.  
  100. //***************************************************************************
  101. //
  102. // GLOBALS
  103. //
  104. //***************************************************************************
  105.  
  106. extern boolean  CONTROL_RudderEnabled;
  107. extern boolean  CONTROL_MousePresent;
  108. extern boolean  CONTROL_JoysPresent[ MaxJoys ];
  109. extern boolean  CONTROL_MouseEnabled;
  110. extern boolean  CONTROL_JoystickEnabled;
  111. extern byte     CONTROL_JoystickPort;
  112. extern uint32   CONTROL_ButtonState1;
  113. extern uint32   CONTROL_ButtonHeldState1;
  114. extern uint32   CONTROL_ButtonState2;
  115. extern uint32   CONTROL_ButtonHeldState2;
  116.  
  117.  
  118. //***************************************************************************
  119. //
  120. // PROTOTYPES
  121. //
  122. //***************************************************************************
  123.  
  124. void CONTROL_MapKey( int32 which, kb_scancode key1, kb_scancode key2 );
  125. void CONTROL_MapButton
  126.         (
  127.         int32 whichfunction,
  128.         int32 whichbutton,
  129.         boolean doubleclicked
  130.         );
  131. void CONTROL_DefineFlag( int32 which, boolean toggle );
  132. boolean CONTROL_FlagActive( int32 which );
  133. void CONTROL_ClearAssignments( void );
  134. void CONTROL_GetUserInput( UserInput *info );
  135. void CONTROL_GetInput( ControlInfo *info );
  136. void CONTROL_ClearButton( int32 whichbutton );
  137. void CONTROL_ClearUserInput( UserInput *info );
  138. void CONTROL_WaitRelease( void );
  139. void CONTROL_Ack( void );
  140. void CONTROL_CenterJoystick
  141.    (
  142.    void ( *CenterCenter )( void ),
  143.    void ( *UpperLeft )( void ),
  144.    void ( *LowerRight )( void ),
  145.    void ( *CenterThrottle )( void ),
  146.    void ( *CenterRudder )( void )
  147.    );
  148. int32 CONTROL_GetMouseSensitivity( void );
  149. void CONTROL_SetMouseSensitivity( int32 newsensitivity );
  150. void CONTROL_Startup
  151.    (
  152.    controltype which,
  153.    int32 ( *TimeFunction )( void ),
  154.    int32 ticspersecond
  155.    );
  156. void CONTROL_Shutdown( void );
  157.  
  158. void CONTROL_MapAnalogAxis
  159.    (
  160.    int32 whichaxis,
  161.    int32 whichanalog
  162.    );
  163.  
  164. void CONTROL_MapDigitalAxis
  165.    (
  166.    int32 whichaxis,
  167.    int32 whichfunction,
  168.    int32 direction
  169.    );
  170. void CONTROL_PrintAxes( void );
  171.  
  172. #endif
  173.