Subversion Repositories eduke32

Rev

Rev 7986 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7986 Rev 8127
1
//-------------------------------------------------------------------------
1
//-------------------------------------------------------------------------
2
/*
2
/*
3
Copyright (C) 1996, 2003 - 3D Realms Entertainment
3
Copyright (C) 1996, 2003 - 3D Realms Entertainment
4

4

5
This file is NOT part of Duke Nukem 3D version 1.5 - Atomic Edition
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
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.
7
some test code written during the development of Duke Nukem 3D.
8
This file is provided purely for educational interest.
8
This file is provided purely for educational interest.
9

9

10
Duke Nukem 3D is free software; you can redistribute it and/or
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
11
modify it under the terms of the GNU General Public License
12
as published by the Free Software Foundation; either version 2
12
as published by the Free Software Foundation; either version 2
13
of the License, or (at your option) any later version.
13
of the License, or (at your option) any later version.
14

14

15
This program is distributed in the hope that it will be useful,
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18

18

19
See the GNU General Public License for more details.
19
See the GNU General Public License for more details.
20

20

21
You should have received a copy of the GNU General Public License
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
22
along with this program; if not, write to the Free Software
23
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
23
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
24

24

25
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
25
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
26
*/
26
*/
27
//-------------------------------------------------------------------------
27
//-------------------------------------------------------------------------
28
28
29
//****************************************************************************
29
//****************************************************************************
30
//
30
//
31
// Private header for CONTROL.C
31
// Private header for CONTROL.C
32
//
32
//
33
//****************************************************************************
33
//****************************************************************************
34
34
35
#pragma once
35
#pragma once
36
36
37
#ifndef control_private_h_
37
#ifndef control_private_h_
38
#define control_private_h_
38
#define control_private_h_
39
39
40
#include "compat.h"
40
#include "compat.h"
41
#include "keyboard.h"
41
#include "keyboard.h"
42
42
43
#ifdef __cplusplus
43
#ifdef __cplusplus
44
extern "C" {
44
extern "C" {
45
#endif
45
#endif
46
46
47
47
48
//****************************************************************************
48
//****************************************************************************
49
//
49
//
50
// DEFINES
50
// DEFINES
51
//
51
//
52
//****************************************************************************
52
//****************************************************************************
53
53
54
#define AXISUNDEFINED   0x7f
54
#define AXISUNDEFINED   0x7f
55
#define BUTTONUNDEFINED 0x7f
55
#define BUTTONUNDEFINED 0x7f
56
#define KEYUNDEFINED    0x7f
56
#define KEYUNDEFINED    0x7f
57
57
58
#define THRESHOLD        (0x200 * 32767 / 10000)
58
#define THRESHOLD        (0x200 * 32767 / 10000)
59
#define MINTHRESHOLD     (0x80 * 32767 / 10000)
59
#define MINTHRESHOLD     (0x80 * 32767 / 10000)
60
60
61
#define DEFAULTMOUSESENSITIVITY 4 // 0x7000+MINIMUMMOUSESENSITIVITY
61
#define DEFAULTMOUSESENSITIVITY 4 // 0x7000+MINIMUMMOUSESENSITIVITY
62
62
63
#define INSTANT_ONOFF       0
63
#define INSTANT_ONOFF       0
64
#define TOGGLE_ONOFF        1
64
#define TOGGLE_ONOFF        1
65
65
66
#define MAXCONTROLVALUE  0x7fff
66
#define MAXCONTROLVALUE  0x7fff
67
67
68
// Number of Mouse buttons
68
// Number of Mouse buttons
69
69
70
//#define MAXMOUSEBUTTONS 10
70
//#define MAXMOUSEBUTTONS 10
71
71
72
// Number of Mouse Axes
-
 
73
// KEEPINSYNC duke3d/src/gamedefs.h, build/src/sdlayer.cpp
-
 
74
#define MAXMOUSEAXES 2
-
 
75
#define MAXMOUSEDIGITAL (MAXMOUSEAXES*2)
-
 
76
-
 
77
// Number of JOY buttons
72
// Number of JOY buttons
78
// KEEPINSYNC duke3d/src/gamedefs.h, build/src/sdlayer.cpp
73
// KEEPINSYNC duke3d/src/gamedefs.h, build/src/sdlayer.cpp
79
#define MAXJOYBUTTONS 32
74
#define MAXJOYBUTTONS 32
80
#define MAXJOYBUTTONSANDHATS (MAXJOYBUTTONS+4)
75
#define MAXJOYBUTTONSANDHATS (MAXJOYBUTTONS+4)
81
76
82
// Number of JOY axes
77
// Number of JOY axes
83
// KEEPINSYNC duke3d/src/gamedefs.h, build/src/sdlayer.cpp
78
// KEEPINSYNC duke3d/src/gamedefs.h, build/src/sdlayer.cpp
84
#define MAXJOYAXES 9
79
#define MAXJOYAXES 9
85
#define MAXJOYDIGITAL (MAXJOYAXES*2)
80
#define MAXJOYDIGITAL (MAXJOYAXES*2)
86
81
87
// NORMAL axis scale
82
// NORMAL axis scale
88
#define NORMALAXISSCALE 65536
83
#define NORMALAXISSCALE 65536
89
84
90
#define BUTTONSET(x, value) (CONTROL_ButtonState |= ((uint64_t)value << ((uint64_t)(x))))
85
#define BUTTONSET(x, value) (CONTROL_ButtonState |= ((uint64_t)value << ((uint64_t)(x))))
91
#define BUTTONCLEAR(x) (CONTROL_ButtonState &= ~((uint64_t)1 << ((uint64_t)(x))))
86
#define BUTTONCLEAR(x) (CONTROL_ButtonState &= ~((uint64_t)1 << ((uint64_t)(x))))
92
#define BUTTONHELDSET(x, value) (CONTROL_ButtonHeldState |= (uint64_t)(value << ((uint64_t)(x))))
87
#define BUTTONHELDSET(x, value) (CONTROL_ButtonHeldState |= (uint64_t)(value << ((uint64_t)(x))))
93
#define LIMITCONTROL(x) (*x = clamp(*x, -MAXCONTROLVALUE, MAXCONTROLVALUE))
88
#define LIMITCONTROL(x) (*x = clamp(*x, -MAXCONTROLVALUE, MAXCONTROLVALUE))
94
89
95
//****************************************************************************
90
//****************************************************************************
96
//
91
//
97
// TYPEDEFS
92
// TYPEDEFS
98
//
93
//
99
//****************************************************************************
94
//****************************************************************************
100
95
101
typedef enum
96
typedef enum
102
{
97
{
103
    motion_Left = -1,
98
    motion_Left = -1,
104
    motion_Up = -1,
99
    motion_Up = -1,
105
    motion_None = 0,
100
    motion_None = 0,
106
    motion_Right = 1,
101
    motion_Right = 1,
107
    motion_Down = 1
102
    motion_Down = 1
108
} motion;
103
} motion;
109
104
110
105
111
typedef struct
106
typedef struct
112
{
107
{
113
    int32_t joyMinX;
108
    int32_t joyMinX;
114
    int32_t joyMinY;
109
    int32_t joyMinY;
115
    int32_t threshMinX;
110
    int32_t threshMinX;
116
    int32_t threshMinY;
111
    int32_t threshMinY;
117
    int32_t threshMaxX;
112
    int32_t threshMaxX;
118
    int32_t threshMaxY;
113
    int32_t threshMaxY;
119
    int32_t joyMaxX;
114
    int32_t joyMaxX;
120
    int32_t joyMaxY;
115
    int32_t joyMaxY;
121
    int32_t joyMultXL;
116
    int32_t joyMultXL;
122
    int32_t joyMultYL;
117
    int32_t joyMultYL;
123
    int32_t joyMultXH;
118
    int32_t joyMultXH;
124
    int32_t joyMultYH;
119
    int32_t joyMultYH;
125
} JoystickDef;
120
} JoystickDef;
126
121
127
//   int32_t ThrottleMin;
122
//   int32_t ThrottleMin;
128
//   int32_t RudderMin;
123
//   int32_t RudderMin;
129
//   int32_t ThrottlethreshMin;
124
//   int32_t ThrottlethreshMin;
130
//   int32_t RudderthreshMin;
125
//   int32_t RudderthreshMin;
131
//   int32_t ThrottlethreshMax;
126
//   int32_t ThrottlethreshMax;
132
//   int32_t RudderthreshMax;
127
//   int32_t RudderthreshMax;
133
//   int32_t ThrottleMax;
128
//   int32_t ThrottleMax;
134
//   int32_t RudderMax;
129
//   int32_t RudderMax;
135
//   int32_t ThrottleMultL;
130
//   int32_t ThrottleMultL;
136
//   int32_t RudderMultL;
131
//   int32_t RudderMultL;
137
//   int32_t ThrottleMultH;
132
//   int32_t ThrottleMultH;
138
//   int32_t RudderMultH;
133
//   int32_t RudderMultH;
139
134
140
135
141
typedef struct
136
typedef struct
142
{
137
{
143
    uint8_t active;
138
    uint8_t active;
144
    uint8_t used;
139
    uint8_t used;
145
    uint8_t toggle;
140
    uint8_t toggle;
146
    uint8_t buttonheld;
141
    uint8_t buttonheld;
147
    int32_t cleared;
142
    int32_t cleared;
148
} controlflags;
143
} controlflags;
149
144
150
typedef struct
145
typedef struct
151
{
146
{
152
    kb_scancode key1;
147
    kb_scancode key1;
153
    kb_scancode key2;
148
    kb_scancode key2;
154
} controlkeymaptype;
149
} controlkeymaptype;
155
150
156
typedef struct
151
typedef struct
157
{
152
{
158
    uint8_t singleclicked;
153
    uint8_t singleclicked;
159
    uint8_t doubleclicked;
154
    uint8_t doubleclicked;
160
    uint16_t extra;
155
    uint16_t extra;
161
} controlbuttontype;
156
} controlbuttontype;
162
157
163
typedef struct
158
typedef struct
164
{
159
{
165
    uint8_t analogmap;
160
    uint8_t analogmap;
166
    uint8_t minmap;
161
    uint8_t minmap;
167
    uint8_t maxmap;
162
    uint8_t maxmap;
168
    uint8_t extra;
163
    uint8_t extra;
169
} controlaxismaptype;
164
} controlaxismaptype;
170
165
171
typedef struct
166
typedef struct
172
{
167
{
173
    int32_t analog;
168
    int32_t analog;
174
    int8_t digital;
169
    int8_t digital;
175
    int8_t digitalClearedN, digitalClearedP;
170
    int8_t digitalClearedN, digitalClearedP;
176
} controlaxistype;
171
} controlaxistype;
177
172
178
173
179
//***************************************************************************
174
//***************************************************************************
180
//
175
//
181
// PROTOTYPES
176
// PROTOTYPES
182
//
177
//
183
//***************************************************************************
178
//***************************************************************************
184
179
185
#ifdef __cplusplus
180
#ifdef __cplusplus
186
}
181
}
187
#endif
182
#endif
188
#endif
183
#endif
189
 
184