-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy path_control.h
More file actions
271 lines (220 loc) · 6.15 KB
/
_control.h
File metadata and controls
271 lines (220 loc) · 6.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
//-------------------------------------------------------------------------
/*
Copyright (C) 1996, 2003 - 3D Realms Entertainment
This file is NOT part of Duke Nukem 3D version 1.5 - Atomic Edition
However, it is either an older version of a file that is, or is
some test code written during the development of Duke Nukem 3D.
This file is provided purely for educational interest.
Duke Nukem 3D is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
*/
//-------------------------------------------------------------------------
//****************************************************************************
//
// Private header for CONTROL.C
//
//****************************************************************************
#ifndef _control_private
#define _control_private
#ifdef __cplusplus
extern "C" {
#endif
//****************************************************************************
//
// DEFINES
//
//****************************************************************************
#define BUTTON0_SCAN_1 sc_Space
#define BUTTON0_SCAN_2 sc_Enter
#define BUTTON0_SCAN_3 sc_kpad_Enter
#define BUTTON1_SCAN sc_Escape
#define AXISUNDEFINED 0x7f
#define BUTTONUNDEFINED 0x7f
#define KEYUNDEFINED 0x7f
#define SENSITIVE 0x400
//#define MINSENSITIVE 0x30
#define THRESHOLD 30
#define MINTHRESHOLD 10
#define USERINPUTDELAY 200
#define ResetMouse 0
#define GetMouseButtons 3
#define GetMouseDelta 11
#define MouseInt 0x33
#define JoyMax 0xa00
#define MaxJoyValue 5000
#define MINIMUMMOUSESENSITIVITY 0x1000
#define DEFAULTMOUSESENSITIVITY 0x7000+MINIMUMMOUSESENSITIVITY
#define CONTROL_NUM_FLAGS 64
#define INSTANT_ONOFF 0
#define TOGGLE_ONOFF 1
#define MAXCONTROLVALUE 0x7fff
// Maximum number of buttons for any controller
#define MAXBUTTONS 32
// Number of Mouse buttons
#define MAXMOUSEBUTTONS 6
// Number of Mouse Axes
#define MAXMOUSEAXES 2
// Number of JOY buttons
#define MAXJOYBUTTONS 32
// Number of JOY axes
#define MAXJOYAXES 12
// Number of GamePad axes
#define MAXGAMEPADAXES 2
// Number of axes
#define MAXAXES 6
// NORMAL axis scale
#define NORMALAXISSCALE (65536)
#define BUTTONSET(x,value) \
(\
((x)>31) ?\
(CONTROL_ButtonState2 |= (value<<((x)-32))) :\
(CONTROL_ButtonState1 |= (value<<(x)))\
)
#define BUTTONCLEAR(x) \
(\
((x)>31) ?\
(CONTROL_ButtonState2 &= (~(1<<((x)-32)))) :\
(CONTROL_ButtonState1 &= (~(1<<(x))))\
)
#define BUTTONHELDSET(x,value)\
(\
((x)>31) ?\
(CONTROL_ButtonHeldState2 |= value<<((x)-32)) :\
(CONTROL_ButtonHeldState1 |= value<<(x))\
)
#define LIMITCONTROL(x)\
{\
if ((*x)>MAXCONTROLVALUE) \
{\
(*x) = MAXCONTROLVALUE;\
}\
if ((*x)<-MAXCONTROLVALUE) \
{\
(*x) = -MAXCONTROLVALUE;\
}\
}
#define SGN(x) \
( ( (x) > 0 ) ? 1 : ( (x) < 0 ) ? -1 : 0 )
//****************************************************************************
//
// TYPEDEFS
//
//****************************************************************************
typedef enum
{
motion_Left = -1,
motion_Up = -1,
motion_None = 0,
motion_Right = 1,
motion_Down = 1
} motion;
typedef struct
{
int32 joyMinX;
int32 joyMinY;
int32 threshMinX;
int32 threshMinY;
int32 threshMaxX;
int32 threshMaxY;
int32 joyMaxX;
int32 joyMaxY;
int32 joyMultXL;
int32 joyMultYL;
int32 joyMultXH;
int32 joyMultYH;
} JoystickDef;
// int32 ThrottleMin;
// int32 RudderMin;
// int32 ThrottlethreshMin;
// int32 RudderthreshMin;
// int32 ThrottlethreshMax;
// int32 RudderthreshMax;
// int32 ThrottleMax;
// int32 RudderMax;
// int32 ThrottleMultL;
// int32 RudderMultL;
// int32 ThrottleMultH;
// int32 RudderMultH;
/*
typedef struct
{
byte active : 1;
byte used : 1;
byte toggle : 1;
byte buttonheld : 1;
byte cleared : 1;
} controlflags;
typedef struct
{
volatile byte active : 1;
volatile byte used : 1;
volatile byte toggle : 1;
volatile byte buttonheld : 1;
volatile byte cleared : 1;
} controlflags;
*/
typedef struct
{
byte active ;
byte used ;
byte toggle ;
byte buttonheld ;
int32 cleared ;
} controlflags;
typedef struct
{
kb_scancode key1;
kb_scancode key2;
} controlkeymaptype;
typedef struct
{
byte singleclicked;
byte doubleclicked;
word extra;
} controlbuttontype;
typedef struct
{
byte analogmap;
byte minmap;
byte maxmap;
byte extra;
} controlaxismaptype;
typedef struct
{
int32 analog;
int32 digital;
} controlaxistype;
//***************************************************************************
//
// PROTOTYPES
//
//***************************************************************************
void CONTROL_GetMouseDelta( void );
byte CONTROL_GetMouseButtons( void );
boolean CONTROL_StartMouse( void );
void CONTROL_GetJoyAbs( void );
void CONTROL_GetJoyDelta( void );
void CONTROL_SetJoyScale( void );
boolean CONTROL_StartJoy( int32 joy );
void CONTROL_ShutJoy( int32 joy );
void CONTROL_SetFlag( int32 which, boolean active );
void CONTROL_ButtonFunctionState( boolean * state );
boolean CONTROL_KeyboardFunctionPressed( int32 whichfunction );
boolean CONTROL_CheckRange( int32 which );
int32 CONTROL_GetTime( void );
void CONTROL_AxisFunctionState( boolean * state );
void CONTROL_GetJoyMovement( ControlInfo * info );
#ifdef __cplusplus
};
#endif
#endif