Subversion Repositories eduke32

Rev

Rev 1632 | Rev 2664 | 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
2456 hendricks2 24
Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
5 Plagman 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
 
1492 terminx 49
#define BUTTON(x) ((CONTROL_ButtonState>> ((uint64_t)(x)) ) & 1)
50
#define BUTTONHELD(x) ((CONTROL_ButtonHeldState>> ((uint64_t)(x)) ) & 1)
1144 terminx 51
 
5 Plagman 52
#define BUTTONJUSTPRESSED(x) \
53
    ( BUTTON( x ) && !BUTTONHELD( x ) )
54
#define BUTTONRELEASED(x) \
55
    ( !BUTTON( x ) && BUTTONHELD( x ) )
56
#define BUTTONSTATECHANGED(x) \
57
    ( BUTTON( x ) != BUTTONHELD( x ) )
58
 
59
 
60
//***************************************************************************
61
//
62
// TYPEDEFS
63
//
64
//***************************************************************************
65
typedef enum
66
   {
67
   axis_up,
68
   axis_down,
69
   axis_left,
70
   axis_right
71
   } axisdirection;
72
 
73
typedef enum
74
   {
75
   analog_turning=0,
76
   analog_strafing=1,
77
   analog_lookingupanddown=2,
78
   analog_elevation=3,
79
   analog_rolling=4,
80
   analog_moving=5,
81
   analog_maxtype
82
   } analogcontrol;
83
 
84
typedef enum
85
   {
86
   dir_North,
87
   dir_NorthEast,
88
   dir_East,
89
   dir_SouthEast,
90
   dir_South,
91
   dir_SouthWest,
92
   dir_West,
93
   dir_NorthWest,
94
   dir_None
95
   } direction;
96
 
97
typedef struct
98
   {
1346 terminx 99
   int32_t   button0;
100
   int32_t   button1;
5 Plagman 101
   direction dir;
102
   } UserInput;
103
 
104
typedef struct
105
   {
1346 terminx 106
   int32_t     dx;
107
   int32_t     dy;
108
   int32_t     dz;
109
   int32_t     dyaw;
110
   int32_t     dpitch;
111
   int32_t     droll;
5 Plagman 112
   } ControlInfo;
113
 
114
typedef enum
115
   {
116
   controltype_keyboard,
117
   controltype_keyboardandmouse,
118
   controltype_keyboardandjoystick
119
   } controltype;
120
 
121
typedef enum
122
   {
123
   controldevice_keyboard,
124
   controldevice_mouse,
125
   controldevice_joystick
126
   } controldevice;
127
 
128
 
129
//***************************************************************************
130
//
131
// GLOBALS
132
//
133
//***************************************************************************
134
 
1552 terminx 135
extern int32_t  CONTROL_Started;
1346 terminx 136
extern int32_t  CONTROL_MousePresent;
137
extern int32_t  CONTROL_JoyPresent;
138
extern int32_t  CONTROL_MouseEnabled;
139
extern int32_t  CONTROL_JoystickEnabled;
1492 terminx 140
extern uint64_t   CONTROL_ButtonState;
141
extern uint64_t   CONTROL_ButtonHeldState;
5 Plagman 142
 
143
 
144
//***************************************************************************
145
//
146
// PROTOTYPES
147
//
148
//***************************************************************************
149
 
1346 terminx 150
void CONTROL_MapKey( int32_t which, kb_scancode key1, kb_scancode key2 );
5 Plagman 151
void CONTROL_MapButton
152
        (
1346 terminx 153
        int32_t whichfunction,
154
        int32_t whichbutton,
155
        int32_t doubleclicked,
1632 terminx 156
    controldevice device
5 Plagman 157
        );
1346 terminx 158
void CONTROL_DefineFlag( int32_t which, int32_t toggle );
159
int32_t CONTROL_FlagActive( int32_t which );
5 Plagman 160
void CONTROL_ClearAssignments( void );
161
void CONTROL_GetInput( ControlInfo *info );
1346 terminx 162
void CONTROL_ClearButton( int32_t whichbutton );
1355 terminx 163
float CONTROL_MouseSensitivity;
1346 terminx 164
int32_t CONTROL_Startup
5 Plagman 165
   (
166
   controltype which,
1346 terminx 167
   int32_t ( *TimeFunction )( void ),
168
   int32_t ticspersecond
5 Plagman 169
   );
170
void CONTROL_Shutdown( void );
171
 
1346 terminx 172
void CONTROL_SetDoubleClickDelay(int32_t delay);
173
int32_t CONTROL_GetDoubleClickDelay(void);
5 Plagman 174
 
175
void CONTROL_MapAnalogAxis
176
   (
1346 terminx 177
   int32_t whichaxis,
178
   int32_t whichanalog,
5 Plagman 179
   controldevice device
180
   );
181
 
182
void CONTROL_MapDigitalAxis
183
   (
1346 terminx 184
   int32_t whichaxis,
185
   int32_t whichfunction,
186
   int32_t direction,
5 Plagman 187
   controldevice device
188
   );
189
void CONTROL_SetAnalogAxisScale
190
   (
1346 terminx 191
   int32_t whichaxis,
192
   int32_t axisscale,
5 Plagman 193
   controldevice device
194
   );
195
 
196
void CONTROL_PrintKeyMap(void);
1346 terminx 197
void CONTROL_PrintControlFlag(int32_t which);
5 Plagman 198
void CONTROL_PrintAxes( void );
199
 
808 terminx 200
#define MAXBINDSTRINGLENGTH 128
201
#define MAXBOUNDKEYS 256
202
 
203
typedef struct binding {
204
    char *key;
834 terminx 205
    char cmd[MAXBINDSTRINGLENGTH];
808 terminx 206
    char repeat;
207
    char laststate;
208
} keybind;
209
 
1089 terminx 210
#define MAXMOUSEBUTTONS 10
808 terminx 211
 
1206 terminx 212
extern keybind KeyBindings[MAXBOUNDKEYS], MouseBindings[MAXMOUSEBUTTONS];
1205 terminx 213
extern int32_t bindsenabled;
834 terminx 214
 
808 terminx 215
void CONTROL_ProcessBinds(void);
216
 
813 terminx 217
#define CONTROL_NUM_FLAGS   64
1205 terminx 218
extern int32_t extinput[CONTROL_NUM_FLAGS];
219
extern int32_t control_smoothmouse;
813 terminx 220
 
5 Plagman 221
#ifdef __cplusplus
222
};
223
#endif
224
#endif