Subversion Repositories eduke32

Rev

Rev 1206 | Rev 1355 | 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
 
1144 terminx 49
#define BUTTON(x) ((CONTROL_ButtonState>> ((uint64)(x)) ) & 1)
50
#define BUTTONHELD(x) ((CONTROL_ButtonHeldState>> ((uint64)(x)) ) & 1)
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
 
1346 terminx 135
extern int32_t  CONTROL_MousePresent;
136
extern int32_t  CONTROL_JoyPresent;
137
extern int32_t  CONTROL_MouseEnabled;
138
extern int32_t  CONTROL_JoystickEnabled;
1144 terminx 139
extern uint64   CONTROL_ButtonState;
140
extern uint64   CONTROL_ButtonHeldState;
5 Plagman 141
 
142
 
143
//***************************************************************************
144
//
145
// PROTOTYPES
146
//
147
//***************************************************************************
148
 
1346 terminx 149
void CONTROL_MapKey( int32_t which, kb_scancode key1, kb_scancode key2 );
5 Plagman 150
void CONTROL_MapButton
151
        (
1346 terminx 152
        int32_t whichfunction,
153
        int32_t whichbutton,
154
        int32_t doubleclicked,
5 Plagman 155
        controldevice device
156
        );
1346 terminx 157
void CONTROL_DefineFlag( int32_t which, int32_t toggle );
158
int32_t CONTROL_FlagActive( int32_t which );
5 Plagman 159
void CONTROL_ClearAssignments( void );
160
void CONTROL_GetUserInput( UserInput *info );
161
void CONTROL_GetInput( ControlInfo *info );
1346 terminx 162
void CONTROL_ClearButton( int32_t whichbutton );
5 Plagman 163
void CONTROL_ClearUserInput( UserInput *info );
164
void CONTROL_WaitRelease( void );
165
void CONTROL_Ack( void );
1346 terminx 166
int32_t CONTROL_GetMouseSensitivity( void );
167
void CONTROL_SetMouseSensitivity( int32_t newsensitivity );
168
int32_t CONTROL_Startup
5 Plagman 169
   (
170
   controltype which,
1346 terminx 171
   int32_t ( *TimeFunction )( void ),
172
   int32_t ticspersecond
5 Plagman 173
   );
174
void CONTROL_Shutdown( void );
175
 
1346 terminx 176
void CONTROL_SetDoubleClickDelay(int32_t delay);
177
int32_t CONTROL_GetDoubleClickDelay(void);
5 Plagman 178
 
179
void CONTROL_MapAnalogAxis
180
   (
1346 terminx 181
   int32_t whichaxis,
182
   int32_t whichanalog,
5 Plagman 183
   controldevice device
184
   );
185
 
186
void CONTROL_MapDigitalAxis
187
   (
1346 terminx 188
   int32_t whichaxis,
189
   int32_t whichfunction,
190
   int32_t direction,
5 Plagman 191
   controldevice device
192
   );
193
void CONTROL_SetAnalogAxisScale
194
   (
1346 terminx 195
   int32_t whichaxis,
196
   int32_t axisscale,
5 Plagman 197
   controldevice device
198
   );
199
 
200
void CONTROL_PrintKeyMap(void);
1346 terminx 201
void CONTROL_PrintControlFlag(int32_t which);
5 Plagman 202
void CONTROL_PrintAxes( void );
203
 
808 terminx 204
#define MAXBINDSTRINGLENGTH 128
205
#define MAXBOUNDKEYS 256
206
 
207
typedef struct binding {
208
    char *key;
834 terminx 209
    char cmd[MAXBINDSTRINGLENGTH];
808 terminx 210
    char repeat;
211
    char laststate;
212
} keybind;
213
 
1089 terminx 214
#define MAXMOUSEBUTTONS 10
808 terminx 215
 
1206 terminx 216
extern keybind KeyBindings[MAXBOUNDKEYS], MouseBindings[MAXMOUSEBUTTONS];
1205 terminx 217
extern int32_t bindsenabled;
834 terminx 218
 
808 terminx 219
void CONTROL_ProcessBinds(void);
220
 
813 terminx 221
#define CONTROL_NUM_FLAGS   64
1205 terminx 222
extern int32_t extinput[CONTROL_NUM_FLAGS];
223
extern int32_t control_smoothmouse;
813 terminx 224
 
5 Plagman 225
#ifdef __cplusplus
226
};
227
#endif
228
#endif