Subversion Repositories eduke32

Rev

Rev 649 | Rev 813 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5 Plagman 1
//-------------------------------------------------------------------------
2
/*
3
Copyright (C) 1996, 2003 - 3D Realms Entertainment
4
 
5
This file is part of Duke Nukem 3D version 1.5 - Atomic Edition
6
 
7
Duke Nukem 3D is free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public License
9
as published by the Free Software Foundation; either version 2
10
of the License, or (at your option) any later version.
11
 
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
 
16
See the GNU General Public License for more details.
17
 
18
You should have received a copy of the GNU General Public License
19
along with this program; if not, write to the Free Software
20
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
 
22
Original Source: 1996 - Todd Replogle
23
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
24
Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com)
25
*/
26
//-------------------------------------------------------------------------
27
 
28
//***************************************************************************
29
//
30
// Public header for CONTROL.C.
31
//
32
//***************************************************************************
33
 
34
#ifndef _control_public
35
#define _control_public
36
#ifdef __cplusplus
37
extern "C" {
38
#endif
39
 
40
 
41
//***************************************************************************
42
//
43
// DEFINES
44
//
45
//***************************************************************************
46
 
47
#define MAXGAMEBUTTONS      64
48
 
49
#define BUTTON(x) \
50
    ( \
51
    ((x)>31) ? \
52
    ((CONTROL_ButtonState2>>( (x) - 32) ) & 1) :\
53
    ((CONTROL_ButtonState1>> (x) ) & 1)          \
54
    )
55
#define BUTTONHELD(x) \
56
    ( \
57
    ((x)>31) ? \
58
    ((CONTROL_ButtonHeldState2>>((x)-32)) & 1) :\
59
    ((CONTROL_ButtonHeldState1>>(x)) & 1)\
60
    )
61
#define BUTTONJUSTPRESSED(x) \
62
    ( BUTTON( x ) && !BUTTONHELD( x ) )
63
#define BUTTONRELEASED(x) \
64
    ( !BUTTON( x ) && BUTTONHELD( x ) )
65
#define BUTTONSTATECHANGED(x) \
66
    ( BUTTON( x ) != BUTTONHELD( x ) )
67
 
68
 
69
//***************************************************************************
70
//
71
// TYPEDEFS
72
//
73
//***************************************************************************
74
typedef enum
75
   {
76
   axis_up,
77
   axis_down,
78
   axis_left,
79
   axis_right
80
   } axisdirection;
81
 
82
typedef enum
83
   {
84
   analog_turning=0,
85
   analog_strafing=1,
86
   analog_lookingupanddown=2,
87
   analog_elevation=3,
88
   analog_rolling=4,
89
   analog_moving=5,
90
   analog_maxtype
91
   } analogcontrol;
92
 
93
typedef enum
94
   {
95
   dir_North,
96
   dir_NorthEast,
97
   dir_East,
98
   dir_SouthEast,
99
   dir_South,
100
   dir_SouthWest,
101
   dir_West,
102
   dir_NorthWest,
103
   dir_None
104
   } direction;
105
 
106
typedef struct
107
   {
108
   boolean   button0;
109
   boolean   button1;
110
   direction dir;
111
   } UserInput;
112
 
113
typedef struct
114
   {
115
   fixed     dx;
116
   fixed     dy;
117
   fixed     dz;
118
   fixed     dyaw;
119
   fixed     dpitch;
120
   fixed     droll;
121
   } ControlInfo;
122
 
123
typedef enum
124
   {
125
   controltype_keyboard,
126
   controltype_keyboardandmouse,
127
   controltype_keyboardandjoystick
128
   } controltype;
129
 
130
typedef enum
131
   {
132
   controldevice_keyboard,
133
   controldevice_mouse,
134
   controldevice_joystick
135
   } controldevice;
136
 
137
 
138
//***************************************************************************
139
//
140
// GLOBALS
141
//
142
//***************************************************************************
143
 
144
extern boolean  CONTROL_MousePresent;
145
extern boolean  CONTROL_JoyPresent;
146
extern boolean  CONTROL_MouseEnabled;
147
extern boolean  CONTROL_JoystickEnabled;
148
extern uint32   CONTROL_ButtonState1;
149
extern uint32   CONTROL_ButtonHeldState1;
150
extern uint32   CONTROL_ButtonState2;
151
extern uint32   CONTROL_ButtonHeldState2;
152
 
153
 
154
//***************************************************************************
155
//
156
// PROTOTYPES
157
//
158
//***************************************************************************
159
 
160
void CONTROL_MapKey( int32 which, kb_scancode key1, kb_scancode key2 );
161
void CONTROL_MapButton
162
        (
163
        int32 whichfunction,
164
        int32 whichbutton,
165
        boolean doubleclicked,
166
        controldevice device
167
        );
168
void CONTROL_DefineFlag( int32 which, boolean toggle );
169
boolean CONTROL_FlagActive( int32 which );
170
void CONTROL_ClearAssignments( void );
171
void CONTROL_GetUserInput( UserInput *info );
172
void CONTROL_GetInput( ControlInfo *info );
173
void CONTROL_ClearButton( int32 whichbutton );
174
void CONTROL_ClearUserInput( UserInput *info );
175
void CONTROL_WaitRelease( void );
176
void CONTROL_Ack( void );
177
int32 CONTROL_GetMouseSensitivity( void );
178
void CONTROL_SetMouseSensitivity( int32 newsensitivity );
179
boolean CONTROL_Startup
180
   (
181
   controltype which,
182
   int32 ( *TimeFunction )( void ),
183
   int32 ticspersecond
184
   );
185
void CONTROL_Shutdown( void );
186
 
187
void CONTROL_SetDoubleClickDelay(int32 delay);
188
int32 CONTROL_GetDoubleClickDelay(void);
189
 
190
void CONTROL_MapAnalogAxis
191
   (
192
   int32 whichaxis,
193
   int32 whichanalog,
194
   controldevice device
195
   );
196
 
197
void CONTROL_MapDigitalAxis
198
   (
199
   int32 whichaxis,
200
   int32 whichfunction,
201
   int32 direction,
202
   controldevice device
203
   );
204
void CONTROL_SetAnalogAxisScale
205
   (
206
   int32 whichaxis,
207
   int32 axisscale,
208
   controldevice device
209
   );
210
 
211
void CONTROL_PrintKeyMap(void);
212
void CONTROL_PrintControlFlag(int32 which);
213
void CONTROL_PrintAxes( void );
214
 
808 terminx 215
#define MAXBINDSTRINGLENGTH 128
216
#define MAXBOUNDKEYS 256
217
 
218
typedef struct binding {
219
    char *key;
220
    char name[MAXBINDSTRINGLENGTH];
221
    char repeat;
222
    char laststate;
223
} keybind;
224
 
225
extern keybind boundkeys[MAXBOUNDKEYS];
226
 
227
void CONTROL_ProcessBinds(void);
228
 
5 Plagman 229
#ifdef __cplusplus
230
};
231
#endif
232
#endif