Subversion Repositories eduke32

Rev

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