Subversion Repositories eduke32

Rev

Rev 3116 | Rev 3195 | 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
3116 hendricks2 36
#ifdef EXTERNC
37
{
5 Plagman 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
 
3124 helixhorne 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 );
2940 helixhorne 161
// void CONTROL_GetFunctionInput( void );
5 Plagman 162
void CONTROL_GetInput( ControlInfo *info );
1346 terminx 163
void CONTROL_ClearButton( int32_t whichbutton );
2664 terminx 164
extern float CONTROL_MouseSensitivity;
1346 terminx 165
int32_t CONTROL_Startup
5 Plagman 166
   (
167
   controltype which,
1346 terminx 168
   int32_t ( *TimeFunction )( void ),
169
   int32_t ticspersecond
5 Plagman 170
   );
171
void CONTROL_Shutdown( void );
172
 
1346 terminx 173
void CONTROL_SetDoubleClickDelay(int32_t delay);
174
int32_t CONTROL_GetDoubleClickDelay(void);
5 Plagman 175
 
176
void CONTROL_MapAnalogAxis
177
   (
1346 terminx 178
   int32_t whichaxis,
179
   int32_t whichanalog,
5 Plagman 180
   controldevice device
181
   );
182
 
183
void CONTROL_MapDigitalAxis
184
   (
1346 terminx 185
   int32_t whichaxis,
186
   int32_t whichfunction,
187
   int32_t direction,
5 Plagman 188
   controldevice device
189
   );
190
void CONTROL_SetAnalogAxisScale
191
   (
1346 terminx 192
   int32_t whichaxis,
193
   int32_t axisscale,
5 Plagman 194
   controldevice device
195
   );
196
 
197
void CONTROL_PrintKeyMap(void);
1346 terminx 198
void CONTROL_PrintControlFlag(int32_t which);
5 Plagman 199
void CONTROL_PrintAxes( void );
200
 
808 terminx 201
#define MAXBINDSTRINGLENGTH 128
202
#define MAXBOUNDKEYS 256
203
 
204
typedef struct binding {
2796 helixhorne 205
    const char *key;
834 terminx 206
    char cmd[MAXBINDSTRINGLENGTH];
808 terminx 207
    char repeat;
208
    char laststate;
209
} keybind;
210
 
1089 terminx 211
#define MAXMOUSEBUTTONS 10
808 terminx 212
 
1206 terminx 213
extern keybind KeyBindings[MAXBOUNDKEYS], MouseBindings[MAXMOUSEBUTTONS];
1205 terminx 214
extern int32_t bindsenabled;
834 terminx 215
 
808 terminx 216
void CONTROL_ProcessBinds(void);
217
 
813 terminx 218
#define CONTROL_NUM_FLAGS   64
1205 terminx 219
extern int32_t extinput[CONTROL_NUM_FLAGS];
220
extern int32_t control_smoothmouse;
813 terminx 221
 
3116 hendricks2 222
#ifdef EXTERNC
5 Plagman 223
};
224
#endif
225
#endif