1 //-------------------------------------------------------------------------
2 /*
3 Copyright (C) 2010-2020 EDuke32 developers and contributors
4 Copyright (C) 2020 sirlemonhead, Nuke.YKT
5 This file is part of ETekWar.
6 ETekWar is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License version 2
8 as published by the Free Software Foundation.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 See the GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16 */
17 //-------------------------------------------------------------------------
18 
19 #ifndef __config_h__
20 #define __config_h__
21 
22 #include "compat.h"
23 
24 #define kMaxGameFuncLen     64
25 
26 // KEEPINSYNC mact/include/_control.h, build/src/sdlayer.cpp
27 #define MAXJOYBUTTONS 32
28 #define MAXJOYBUTTONSANDHATS (MAXJOYBUTTONS+4)
29 
30 // KEEPINSYNC mact/include/_control.h, build/src/sdlayer.cpp
31 #define MAXMOUSEAXES 2
32 #define MAXMOUSEDIGITAL (MAXMOUSEAXES*2)
33 
34 // KEEPINSYNC mact/include/_control.h, build/src/sdlayer.cpp
35 #define MAXJOYAXES 9
36 #define MAXJOYDIGITAL (MAXJOYAXES*2)
37 
38 // default mouse scale
39 #define DEFAULTMOUSEANALOGUESCALE           65536
40 
41 // default joystick settings
42 #define DEFAULTJOYSTICKANALOGUESCALE        65536
43 #define DEFAULTJOYSTICKANALOGUEDEAD         2000
44 #define DEFAULTJOYSTICKANALOGUESATURATE     9500
45 
46 enum
47 {
48     gamefunc_Move_Forward,
49     gamefunc_Move_Backward,
50     gamefunc_Turn_Left,
51     gamefunc_Turn_Right,
52     gamefunc_Strafe,
53     gamefunc_Strafe_Left,
54     gamefunc_Strafe_Right,
55     gamefunc_Run,
56     gamefunc_Jump,
57     gamefunc_Crouch,
58     gamefunc_Fire,
59     gamefunc_Open,
60     gamefunc_Look_Up,
61     gamefunc_Look_Down,
62     gamefunc_Look_Straight,
63     gamefunc_Aim_Up,
64     gamefunc_Aim_Down,
65     gamefunc_SendMessage,
66     gamefunc_ConcealWeapon,
67     gamefunc_SwitchPlayer,
68     gamefunc_RearView,
69     gamefunc_MatrixMeter,
70     gamefunc_HealthMeter,
71     gamefunc_ElapsedTime,
72     gamefunc_Score,
73     gamefunc_Inventory,
74     gamefunc_Weapon_1,
75     gamefunc_Weapon_2,
76     gamefunc_Weapon_3,
77     gamefunc_Weapon_4,
78     gamefunc_Weapon_5,
79     gamefunc_Weapon_6,
80     gamefunc_Weapon_7,
81     gamefunc_Weapon_8,
82     gamefunc_Weapon_9,
83     gamefunc_Pause,
84     gamefunc_Map,
85     gamefunc_Zoom_In,
86     gamefunc_Zoom_Out,
87     gamefunc_Gamma_Correction,
88     gamefunc_Escape,
89     gamefunc_Shrink_Screen,
90     gamefunc_Enlarge_Screen,
91     gamefunc_Mouse_Sensitivity_Up,
92     gamefunc_Mouse_Sensitivity_Down,
93     gamefunc_Show_Console,
94     gamefunc_Mouse_Aiming,
95     gamefunc_Toggle_Crosshair,
96     kMaxGameFunctions
97 };
98 
99 extern const char gamefunctions[kMaxGameFunctions][kMaxGameFuncLen];
100 extern const char keydefaults[kMaxGameFunctions * 2][kMaxGameFuncLen];
101 extern const char oldkeydefaults[kMaxGameFunctions * 2][kMaxGameFuncLen];
102 
103 typedef struct {
104     int32_t usejoystick;
105     int32_t usemouse;
106     int32_t fullscreen;
107     int32_t xdim;
108     int32_t ydim;
109     int32_t bpp;
110     int32_t forcesetup;
111     int32_t noautoload;
112 } ud_setup_t;
113 
114 #define kSetupFilename  "etekwar.cfg"
115 extern char setupfilename[BMAX_PATH];
116 
117 extern hashtable_t h_gamefuncs;
118 
119 void SetupInput();
120 
121 int CONFIG_ReadSetup();
122 void CONFIG_WriteSetup(uint32_t flags);
123 
124 extern int lMouseSens;
125 
126 extern ud_setup_t gSetup;
127 extern int32_t scripthandle;
128 extern int32_t setupread;
129 extern int32_t useprecache;
130 extern int32_t MouseDeadZone, MouseBias;
131 
132 extern int32_t FXVolume;
133 extern int32_t MusicVolume;
134 extern int32_t MixRate;
135 extern int32_t MidiPort;
136 extern int32_t NumVoices;
137 extern int32_t NumChannels;
138 extern int32_t NumBits;
139 extern int32_t ReverseStereo;
140 extern int32_t MusicDevice;
141 extern int32_t FXDevice;
142 
143 // JBF 20031211: Store the input settings because
144 // (currently) mact can't regurgitate them
145 extern int32_t MouseFunctions[MAXMOUSEBUTTONS][2];
146 extern int32_t MouseDigitalFunctions[MAXMOUSEAXES][2];
147 extern int32_t MouseAnalogueAxes[MAXMOUSEAXES];
148 extern int32_t MouseAnalogueScale[MAXMOUSEAXES];
149 extern int32_t JoystickFunctions[MAXJOYBUTTONSANDHATS][2];
150 extern int32_t JoystickDigitalFunctions[MAXJOYAXES][2];
151 extern int32_t JoystickAnalogueAxes[MAXJOYAXES];
152 extern int32_t JoystickAnalogueScale[MAXJOYAXES];
153 extern int32_t JoystickAnalogueInvert[MAXJOYAXES];
154 extern int32_t JoystickAnalogueDead[MAXJOYAXES];
155 extern int32_t JoystickAnalogueSaturate[MAXJOYAXES];
156 extern uint8_t KeyboardKeys[kMaxGameFunctions][2];
157 
158 extern int32_t MAXCACHE1DSIZE;
159 
160 extern int32_t difficulty;
161 
162 void CONFIG_SetDefaultKeys(const char(*keyptr)[kMaxGameFuncLen], bool lazy=false);
163 void CONFIG_MapKey(int which, kb_scancode key1, kb_scancode oldkey1, kb_scancode key2, kb_scancode oldkey2);
164 int32_t CONFIG_FunctionNameToNum(const char* func);
165 
166 #endif
167