taisei/src/config.h

242 lines
11 KiB
C
Raw Normal View History

/*
* This software is licensed under the terms of the MIT License.
* See COPYING for further information.
* ---
* Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
2019-07-03 20:00:56 +02:00
* Copyright (c) 2012-2019, Andrei Alexeyev <akari@taisei-project.org>.
*/
#ifndef IGUARD_config_h
#define IGUARD_config_h
#include "taisei.h"
2017-02-04 03:56:40 +01:00
#include <SDL_keycode.h>
2017-04-18 21:48:18 +02:00
#define CONFIG_FILE "storage/config"
2017-02-17 17:03:49 +01:00
/*
Define these macros, then use CONFIGDEFS to expand them all for all config entries, or KEYDEFS for just keybindings.
Don't forget to undef them afterwards.
Remember that the id won't have the CONFIG_ prefix, prepend it yourself if you want a ConfigIndex constant.
*/
2017-02-17 17:03:49 +01:00
// #define CONFIGDEF_KEYBINDING(id,entryname,default)
// #define CONFIGDEF_GPKEYBINDING(id,entryname,default)
// #define CONFIGDEF_INT(id,entryname,default)
// #define CONFIGDEF_FLOAT(id,entryname,default)
// #define CONFIGDEF_STRING(id,entryname,default)
/*
* DO NOT REORDER KEYBINDINGS.
2017-02-17 17:03:49 +01:00
*
* The KEY_* constants are used by replays. These are formed from KEYDEFS.
* Always add new keys at the end of KEYDEFS, never put them directly into CONFIGDEFS.
2017-02-17 17:03:49 +01:00
*
* KEYDEFS can be safely moved around within CONFIGDEFS, however.
* Stuff in GPKEYDEFS is safe to reorder.
*/
2017-02-17 17:03:49 +01:00
#define KEYDEFS \
CONFIGDEF_KEYBINDING(KEY_UP, "key_up", SDL_SCANCODE_UP) \
CONFIGDEF_KEYBINDING(KEY_DOWN, "key_down", SDL_SCANCODE_DOWN) \
CONFIGDEF_KEYBINDING(KEY_LEFT, "key_left", SDL_SCANCODE_LEFT) \
CONFIGDEF_KEYBINDING(KEY_RIGHT, "key_right", SDL_SCANCODE_RIGHT) \
CONFIGDEF_KEYBINDING(KEY_FOCUS, "key_focus", SDL_SCANCODE_LSHIFT) \
CONFIGDEF_KEYBINDING(KEY_SHOT, "key_shot", SDL_SCANCODE_Z) \
CONFIGDEF_KEYBINDING(KEY_BOMB, "key_bomb", SDL_SCANCODE_X) \
CONFIGDEF_KEYBINDING(KEY_SPECIAL, "key_special", SDL_SCANCODE_C) \
CONFIGDEF_KEYBINDING(KEY_SKIP, "key_skip", SDL_SCANCODE_LCTRL) \
CONFIGDEF_KEYBINDING(KEY_FULLSCREEN, "key_fullscreen", SDL_SCANCODE_F11) \
CONFIGDEF_KEYBINDING(KEY_SCREENSHOT, "key_screenshot", SDL_SCANCODE_P) \
CONFIGDEF_KEYBINDING(KEY_IDDQD, "key_iddqd", SDL_SCANCODE_Q) \
CONFIGDEF_KEYBINDING(KEY_HAHAIWIN, "key_skipstage", SDL_SCANCODE_E) \
CONFIGDEF_KEYBINDING(KEY_PAUSE, "key_pause", SDL_SCANCODE_PAUSE) \
CONFIGDEF_KEYBINDING(KEY_NOBACKGROUND, "key_nobackground", SDL_SCANCODE_LALT) \
CONFIGDEF_KEYBINDING(KEY_POWERUP, "key_powerup", SDL_SCANCODE_2) \
CONFIGDEF_KEYBINDING(KEY_POWERDOWN, "key_powerdown", SDL_SCANCODE_1) \
CONFIGDEF_KEYBINDING(KEY_FPSLIMIT_OFF, "key_fpslimit_off", SDL_SCANCODE_RSHIFT) \
CONFIGDEF_KEYBINDING(KEY_STOP, "key_stop", SDL_SCANCODE_F1) \
CONFIGDEF_KEYBINDING(KEY_RESTART, "key_restart", SDL_SCANCODE_F2) \
CONFIGDEF_KEYBINDING(KEY_HITAREAS, "key_hitareas", SDL_SCANCODE_H) \
CONFIGDEF_KEYBINDING(KEY_TOGGLE_AUDIO, "key_toggle_audio", SDL_SCANCODE_M) \
2017-02-17 17:03:49 +01:00
#define GPKEYDEFS \
CONFIGDEF_GPKEYBINDING(KEY_UP, "gamepad_key_up", GAMEPAD_BUTTON_DPAD_UP) \
CONFIGDEF_GPKEYBINDING(KEY_DOWN, "gamepad_key_down", GAMEPAD_BUTTON_DPAD_DOWN) \
CONFIGDEF_GPKEYBINDING(KEY_LEFT, "gamepad_key_left", GAMEPAD_BUTTON_DPAD_LEFT) \
CONFIGDEF_GPKEYBINDING(KEY_RIGHT, "gamepad_key_right", GAMEPAD_BUTTON_DPAD_RIGHT) \
CONFIGDEF_GPKEYBINDING(KEY_FOCUS, "gamepad_key_focus", GAMEPAD_BUTTON_X) \
CONFIGDEF_GPKEYBINDING(KEY_SHOT, "gamepad_key_shot", GAMEPAD_BUTTON_A) \
CONFIGDEF_GPKEYBINDING(KEY_BOMB, "gamepad_key_bomb", GAMEPAD_BUTTON_Y) \
CONFIGDEF_GPKEYBINDING(KEY_SPECIAL, "gamepad_key_special", GAMEPAD_BUTTON_SHOULDER_RIGHT) \
CONFIGDEF_GPKEYBINDING(KEY_SKIP, "gamepad_key_skip", GAMEPAD_BUTTON_B) \
2017-02-17 17:03:49 +01:00
Emscripten compatibility (#161) * Major refactoring of the main loop(s) and control flow (WIP) run_at_fps() is gone 🦀 Instead of nested blocking event loops, there is now an eventloop API that manages an explicit stack of scenes. This makes Taisei a lot more portable to async environments where spinning a loop forever without yielding control simply is not an option, and that is the entire point of this change. A prime example of such an environment is the Web (via emscripten). Taisei was able to run there through a terrible hack: inserting emscripten_sleep calls into the loop, which would yield to the browser. This has several major drawbacks: first of all, every function that could possibly call emscripten_sleep must be compiled into a special kind of bytecode, which then has to be interpreted at runtime, *much* slower than JITed WebAssembly. And that includes *everything* down the call stack, too! For more information, see https://emscripten.org/docs/porting/emterpreter.html Even though that method worked well enough for experimenting, despite suboptimal performance, there is another obvious drawback: emscripten_sleep is implemented via setTimeout(), which can be very imprecise and is generally not reliable for fluid animation. Browsers actually have an API specifically for that use case: window.requestAnimationFrame(), but Taisei's original blocking control flow style is simply not compatible with it. Emscripten exposes this API with its emscripten_set_main_loop(), which the eventloop backend now uses on that platform. Unfortunately, C is still C, with no fancy closures or coroutines. With blocking calls into menu/scene loops gone, the control flow is reimplemented via so-called (pun intended) "call chains". That is basically an euphemism for callback hell. With manual memory management and zero type-safety. Not that the menu system wasn't shitty enough already. I'll just keep telling myself that this is all temporary and will be replaced with scripts in v1.4. * improve build system for emscripten + various fixes * squish menu bugs * improve emscripten event loop; disable EMULATE_FUNCTION_POINTER_CASTS Note that stock freetype does not work without EMULATE_FUNCTION_POINTER_CASTS; use a patched version from the "emscripten" branch here: https://github.com/taisei-project/freetype2/tree/emscripten * Enable -Wcast-function-type Calling functions through incompatible pointers is nasal demons and doesn't work in WASM. * webgl: workaround a crash on some browsers * emscripten improvements: * Persist state (config, progress, replays, ...) in local IndexDB * Simpler HTML shell (temporary) * Enable more optimizations * fix build if validate_glsl=false * emscripten: improve asset packaging, with local cache Note that even though there are rules to build audio bundles, audio does *not* work yet. It looks like SDL2_mixer can not work without threads, which is a problem. Yet another reason to write an OpenAL backend - emscripten supports that natively. * emscripten: customize the html shell * emscripten: force "show log" checkbox unchecked initially * emscripten: remove quit shortcut from main menu (since there's no quit) * emscripten: log area fixes * emscripten/webgl: workaround for fullscreen viewport issue * emscripten: implement frameskip * emscripter: improve framerate limiter * align List to at least 8 bytes (shut up warnings) * fix non-emscripten builds * improve fullscreen handling, mainly for emscripten * Workaround to make audio work in chromium emscripten-core/emscripten#6511 * emscripten: better vsync handling; enable vsync & disable fxaa by default
2019-03-09 20:32:32 +01:00
#ifdef __EMSCRIPTEN__
#define CONFIG_VSYNC_DEFAULT 1
#define CONFIG_FXAA_DEFAULT 0
#else
#define CONFIG_VSYNC_DEFAULT 0
#define CONFIG_FXAA_DEFAULT 1
#endif
2017-02-17 17:03:49 +01:00
#define CONFIGDEFS \
/* @version must be on top. don't change its default value here, it does nothing. */ \
CONFIGDEF_INT (VERSION, "@version", 0) \
\
CONFIGDEF_STRING (PLAYERNAME, "playername", "Player") \
CONFIGDEF_INT (FULLSCREEN, "fullscreen", 0) \
CONFIGDEF_INT (FULLSCREEN_DESKTOP, "fullscreen_desktop_mode", 1) \
CONFIGDEF_INT (VID_WIDTH, "vid_width", RESX) \
CONFIGDEF_INT (VID_HEIGHT, "vid_height", RESY) \
CONFIGDEF_INT (VID_DISPLAY, "vid_display", 0) \
CONFIGDEF_INT (VID_RESIZABLE, "vid_resizable", 0) \
CONFIGDEF_INT (VID_FRAMESKIP, "vid_frameskip", 1) \
Emscripten compatibility (#161) * Major refactoring of the main loop(s) and control flow (WIP) run_at_fps() is gone 🦀 Instead of nested blocking event loops, there is now an eventloop API that manages an explicit stack of scenes. This makes Taisei a lot more portable to async environments where spinning a loop forever without yielding control simply is not an option, and that is the entire point of this change. A prime example of such an environment is the Web (via emscripten). Taisei was able to run there through a terrible hack: inserting emscripten_sleep calls into the loop, which would yield to the browser. This has several major drawbacks: first of all, every function that could possibly call emscripten_sleep must be compiled into a special kind of bytecode, which then has to be interpreted at runtime, *much* slower than JITed WebAssembly. And that includes *everything* down the call stack, too! For more information, see https://emscripten.org/docs/porting/emterpreter.html Even though that method worked well enough for experimenting, despite suboptimal performance, there is another obvious drawback: emscripten_sleep is implemented via setTimeout(), which can be very imprecise and is generally not reliable for fluid animation. Browsers actually have an API specifically for that use case: window.requestAnimationFrame(), but Taisei's original blocking control flow style is simply not compatible with it. Emscripten exposes this API with its emscripten_set_main_loop(), which the eventloop backend now uses on that platform. Unfortunately, C is still C, with no fancy closures or coroutines. With blocking calls into menu/scene loops gone, the control flow is reimplemented via so-called (pun intended) "call chains". That is basically an euphemism for callback hell. With manual memory management and zero type-safety. Not that the menu system wasn't shitty enough already. I'll just keep telling myself that this is all temporary and will be replaced with scripts in v1.4. * improve build system for emscripten + various fixes * squish menu bugs * improve emscripten event loop; disable EMULATE_FUNCTION_POINTER_CASTS Note that stock freetype does not work without EMULATE_FUNCTION_POINTER_CASTS; use a patched version from the "emscripten" branch here: https://github.com/taisei-project/freetype2/tree/emscripten * Enable -Wcast-function-type Calling functions through incompatible pointers is nasal demons and doesn't work in WASM. * webgl: workaround a crash on some browsers * emscripten improvements: * Persist state (config, progress, replays, ...) in local IndexDB * Simpler HTML shell (temporary) * Enable more optimizations * fix build if validate_glsl=false * emscripten: improve asset packaging, with local cache Note that even though there are rules to build audio bundles, audio does *not* work yet. It looks like SDL2_mixer can not work without threads, which is a problem. Yet another reason to write an OpenAL backend - emscripten supports that natively. * emscripten: customize the html shell * emscripten: force "show log" checkbox unchecked initially * emscripten: remove quit shortcut from main menu (since there's no quit) * emscripten: log area fixes * emscripten/webgl: workaround for fullscreen viewport issue * emscripten: implement frameskip * emscripter: improve framerate limiter * align List to at least 8 bytes (shut up warnings) * fix non-emscripten builds * improve fullscreen handling, mainly for emscripten * Workaround to make audio work in chromium emscripten-core/emscripten#6511 * emscripten: better vsync handling; enable vsync & disable fxaa by default
2019-03-09 20:32:32 +01:00
CONFIGDEF_INT (VSYNC, "vsync", CONFIG_VSYNC_DEFAULT) \
CONFIGDEF_INT (MIXER_CHUNKSIZE, "mixer_chunksize", 1024) \
2019-03-06 13:23:50 +01:00
CONFIGDEF_FLOAT (SFX_VOLUME, "sfx_volume", 0.5) \
CONFIGDEF_FLOAT (BGM_VOLUME, "bgm_volume", 1.0) \
CONFIGDEF_INT (MUTE_AUDIO, "mute_audio", 0) \
CONFIGDEF_INT (NO_STAGEBG, "disable_stagebg", 0) \
CONFIGDEF_INT (SAVE_RPY, "save_rpy", 2) \
CONFIGDEF_INT (SPELLSTAGE_AUTORESTART, "spellpractice_restart_on_fail", 0) \
CONFIGDEF_INT (PRACTICE_POWER, "practice_power", 200) \
CONFIGDEF_FLOAT (TEXT_QUALITY, "text_quality", 1.0) \
CONFIGDEF_FLOAT (FG_QUALITY, "fg_quality", 1.0) \
CONFIGDEF_FLOAT (BG_QUALITY, "bg_quality", 1.0) \
CONFIGDEF_INT (SHOT_INVERTED, "shot_inverted", 0) \
CONFIGDEF_INT (FOCUS_LOSS_PAUSE, "focus_loss_pause", 1) \
CONFIGDEF_INT (PARTICLES, "particles", 1) \
Emscripten compatibility (#161) * Major refactoring of the main loop(s) and control flow (WIP) run_at_fps() is gone 🦀 Instead of nested blocking event loops, there is now an eventloop API that manages an explicit stack of scenes. This makes Taisei a lot more portable to async environments where spinning a loop forever without yielding control simply is not an option, and that is the entire point of this change. A prime example of such an environment is the Web (via emscripten). Taisei was able to run there through a terrible hack: inserting emscripten_sleep calls into the loop, which would yield to the browser. This has several major drawbacks: first of all, every function that could possibly call emscripten_sleep must be compiled into a special kind of bytecode, which then has to be interpreted at runtime, *much* slower than JITed WebAssembly. And that includes *everything* down the call stack, too! For more information, see https://emscripten.org/docs/porting/emterpreter.html Even though that method worked well enough for experimenting, despite suboptimal performance, there is another obvious drawback: emscripten_sleep is implemented via setTimeout(), which can be very imprecise and is generally not reliable for fluid animation. Browsers actually have an API specifically for that use case: window.requestAnimationFrame(), but Taisei's original blocking control flow style is simply not compatible with it. Emscripten exposes this API with its emscripten_set_main_loop(), which the eventloop backend now uses on that platform. Unfortunately, C is still C, with no fancy closures or coroutines. With blocking calls into menu/scene loops gone, the control flow is reimplemented via so-called (pun intended) "call chains". That is basically an euphemism for callback hell. With manual memory management and zero type-safety. Not that the menu system wasn't shitty enough already. I'll just keep telling myself that this is all temporary and will be replaced with scripts in v1.4. * improve build system for emscripten + various fixes * squish menu bugs * improve emscripten event loop; disable EMULATE_FUNCTION_POINTER_CASTS Note that stock freetype does not work without EMULATE_FUNCTION_POINTER_CASTS; use a patched version from the "emscripten" branch here: https://github.com/taisei-project/freetype2/tree/emscripten * Enable -Wcast-function-type Calling functions through incompatible pointers is nasal demons and doesn't work in WASM. * webgl: workaround a crash on some browsers * emscripten improvements: * Persist state (config, progress, replays, ...) in local IndexDB * Simpler HTML shell (temporary) * Enable more optimizations * fix build if validate_glsl=false * emscripten: improve asset packaging, with local cache Note that even though there are rules to build audio bundles, audio does *not* work yet. It looks like SDL2_mixer can not work without threads, which is a problem. Yet another reason to write an OpenAL backend - emscripten supports that natively. * emscripten: customize the html shell * emscripten: force "show log" checkbox unchecked initially * emscripten: remove quit shortcut from main menu (since there's no quit) * emscripten: log area fixes * emscripten/webgl: workaround for fullscreen viewport issue * emscripten: implement frameskip * emscripter: improve framerate limiter * align List to at least 8 bytes (shut up warnings) * fix non-emscripten builds * improve fullscreen handling, mainly for emscripten * Workaround to make audio work in chromium emscripten-core/emscripten#6511 * emscripten: better vsync handling; enable vsync & disable fxaa by default
2019-03-09 20:32:32 +01:00
CONFIGDEF_INT (FXAA, "fxaa", CONFIG_FXAA_DEFAULT) \
Lots of disorganized (mostly) visual overhaul (#156) * WIP some projectile effects * fix segfault * Laser smoothing and glow via post-processing blur magic TODO: make it optional * fix memory corruption * fix memory corruption for realsies now * fix color_get_hsl for out-of-range colors * some more bullet flare tweaks * some lame clear effect workarounds * spawn bullet flares after frame 0; looks better and fixes some problems * New baryon explosion; fix petal_explosion; leanify everything * Add missing bullet flare sprite, rebuild main atlas * improve batching efficiency with bullet spawn flares * forgot git add * Group projectiles/particles by shader where possible * Another take on baryon explosion; make fg framebuffers 16bit * WIP some settings for toasters * remove stupid debug log * microoptimization that probably does nothing anyway * somewhat more intuitive quality settings * Whitelist more particles (MarisaB is on hold) * Whitelist (and fix) some more stage6 particles (mostly ToE) * Add a spell name background * Experimental radial healthbar for bosses * healthbar tweaks * thiccer healthbars in response to feedback * remove healthbar survival timer; just fade out on survivals * Add linear healthbars option; WIP other boss HUD tweaks * Use the proper spell card name format * New font and some random garbage to go along with it * Generate static font outlines for use in text shaders * Use outlines in overlay text shader * Complete boss HUD/healthbar fading logic * fix boss timer limit * stage5 bombs explosion effect * split PFLAG_NOSPAWNZOOM into PFLAG_NOSPAWNFLARE and PFLAG_NOSPAWNFADE; introduce PFLAG_NOSPAWNEFFECTS which disables both (it's just the two values OR'd together) simplify vampiric vapor bullet spawning effect * Remove spawn fade-in from super-fast stage5 fairy projectiles (limiters) * lower particle density in v.vapor in minimal mode * graze effect tweaks * fix text shortening, tweak replay menu layout * stupid debug spam * revisit grazing effects again * dumb debug spam again * improve boss attack timer * overlay effect for boss deaths (similar to the player one) * spice up spellcard declaration (HUD) * don't spawn boss death overlay if fleed * modify Exo2 font to use tabular figures * adjust replay menu for the font change * draw timer & power with standard font (phasing out the numbers font) * WIP new HUD; random fixes/tweaks * hud: move difficulty indicator * hud: move debug stuff around * preloads, mostly * fix youmuA batching conflict * shitty workaround for the shitty screenshake shit * remove extraspell lag by stopping to draw stagebg sooner which is possible because extra spells have a different spellcard_intro timing. Fun fact of the day: the duration of spellcard_intro is always ATTACK_START_DELAY_EXTRA even for normal spells! * new stain particle * i disabled background rendering… * "batch" marisa_b masterspark draws * remove these once a new atlas is generated * make toe quick again * hopefully fix all occurences of changed stain and ScaleFade behavior * tweaking reimu_a and toe boson launch effects * make lhc fast again * softer involnerability effect * fix stage 1 snow on the water bug (and improve performance) translated the time to the future a bit because it only seemed to be an issue for small time values * remove unnecessary spawnflare from toe * tone down extra spell start effect * experimental ReimuB gap shader optimization * fix python3 shebangs * generate simple blur shaders w/ hardcoded kernels * New loading screen * lasers: fix incorrect draw hook registration * add webp support for atlas generator * Use ImageMagick for atlas composition (adds 16-bit support) * Atlas maintenance * make the vampiric vapor bullets less prone to invisibility * Revert a few particles to the quadratic fade curve * experimental baryon effect * improve baryon sprites * disable the baryon effect on minimal postprocessing setting
2019-01-04 23:59:39 +01:00
CONFIGDEF_INT (POSTPROCESS, "postprocess", 2) \
CONFIGDEF_INT (HEALTHBAR_STYLE, "healthbar_style", 1) \
CONFIGDEF_INT (SKIP_SPEED, "skip_speed", 10) \
2019-04-07 00:55:13 +02:00
CONFIGDEF_FLOAT (SCORETEXT_ALPHA, "scoretext_alpha", 1) \
2017-02-17 17:03:49 +01:00
KEYDEFS \
2019-03-10 16:28:45 +01:00
CONFIGDEF_INT (GAMEPAD_ENABLED, "gamepad_enabled", 1) \
CONFIGDEF_STRING (GAMEPAD_DEVICE, "gamepad_device", "any") \
CONFIGDEF_INT (GAMEPAD_AXIS_UD, "gamepad_axis_ud", 1) \
CONFIGDEF_INT (GAMEPAD_AXIS_LR, "gamepad_axis_lr", 0) \
CONFIGDEF_INT (GAMEPAD_AXIS_FREE, "gamepad_axis_free", 1) \
CONFIGDEF_FLOAT (GAMEPAD_AXIS_UD_SENS, "gamepad_axis_ud_free_sensitivity", 1.0) \
CONFIGDEF_FLOAT (GAMEPAD_AXIS_LR_SENS, "gamepad_axis_lr_free_sensitivity", 1.0) \
CONFIGDEF_FLOAT (GAMEPAD_AXIS_DEADZONE, "gamepad_axis_deadzone", 0.1) \
2018-01-16 12:51:19 +01:00
CONFIGDEF_FLOAT (GAMEPAD_BTNREPEAT_DELAY, "gamepad_button_repeat_delay", 0.25) \
CONFIGDEF_FLOAT (GAMEPAD_BTNREPEAT_INTERVAL,"gamepad_button_repeat_interval", 0.02) \
2017-02-17 17:03:49 +01:00
GPKEYDEFS \
typedef enum ConfigIndex {
#define CONFIGDEF(id) CONFIG_##id,
#define CONFIGDEF_KEYBINDING(id,entryname,default) CONFIGDEF(id)
#define CONFIGDEF_GPKEYBINDING(id,entryname,default) CONFIGDEF(GAMEPAD_##id)
#define CONFIGDEF_INT(id,entryname,default) CONFIGDEF(id)
#define CONFIGDEF_FLOAT(id,entryname,default) CONFIGDEF(id)
#define CONFIGDEF_STRING(id,entryname,default) CONFIGDEF(id)
CONFIGDEFS
CONFIGIDX_NUM
#undef CONFIGDEF
#undef CONFIGDEF_KEYBINDING
#undef CONFIGDEF_GPKEYBINDING
#undef CONFIGDEF_INT
#undef CONFIGDEF_FLOAT
#undef CONFIGDEF_STRING
} ConfigIndex;
#define CONFIGIDX_FIRST 0
#define CONFIGIDX_LAST (CONFIGIDX_NUM - 1)
typedef enum KeyIndex {
#define CONFIGDEF_KEYBINDING(id,entryname,default) id,
KEYDEFS
KEYIDX_NUM
#undef CONFIGDEF_KEYBINDING
} KeyIndex;
#define KEYIDX_FIRST 0
#define KEYIDX_LAST (KEYIDX_NUM - 1)
#define CFGIDX_TO_KEYIDX(idx) (idx - CONFIG_KEY_FIRST + KEYIDX_FIRST)
#define KEYIDX_TO_CFGIDX(idx) (idx + CONFIG_KEY_FIRST - KEYIDX_FIRST)
#define CONFIG_KEY_FIRST CONFIG_KEY_UP
#define CONFIG_KEY_LAST (CONFIG_KEY_FIRST + KEYIDX_LAST - KEYIDX_FIRST)
typedef enum GamepadKeyIndex {
#define CONFIGDEF_GPKEYBINDING(id,entryname,default) GAMEPAD_##id,
GPKEYDEFS
GAMEPAD_KEYIDX_NUM
#undef CONFIGDEF_GPKEYBINDING
} GamepadKeyIndex;
#define GAMEPAD_KEYIDX_FIRST 0
#define GAMEPAD_KEYIDX_LAST (GAMEPAD_KEYIDX_NUM - 1)
#define CFGIDX_TO_GPKEYIDX(idx) (idx - CONFIG_GAMEPAD_KEY_FIRST + GAMEPAD_KEYIDX_FIRST)
#define GPKEYIDX_TO_CFGIDX(idx) (idx + CONFIG_GAMEPAD_KEY_FIRST - GAMEPAD_KEYIDX_FIRST)
#define CONFIG_GAMEPAD_KEY_FIRST CONFIG_GAMEPAD_KEY_UP
#define CONFIG_GAMEPAD_KEY_LAST (CONFIG_GAMEPAD_KEY_FIRST + GAMEPAD_KEYIDX_LAST - GAMEPAD_KEYIDX_FIRST)
typedef enum ConfigEntryType {
CONFIG_TYPE_INT,
CONFIG_TYPE_STRING,
CONFIG_TYPE_KEYBINDING,
CONFIG_TYPE_GPKEYBINDING,
2017-02-17 17:03:49 +01:00
CONFIG_TYPE_FLOAT
} ConfigEntryType;
typedef union ConfigValue {
int i;
double f;
char *s;
} ConfigValue;
typedef struct ConfigEntry {
2017-02-17 17:03:49 +01:00
ConfigEntryType type;
char *name;
ConfigValue val;
} ConfigEntry;
#define CONFIG_LOAD_BUFSIZE 256
2017-02-17 17:03:49 +01:00
KeyIndex config_key_from_scancode(int scan);
GamepadKeyIndex config_gamepad_key_from_gamepad_button(int btn);
KeyIndex config_key_from_gamepad_key(GamepadKeyIndex gpkey);
GamepadKeyIndex config_gamepad_key_from_key(KeyIndex key);
KeyIndex config_key_from_gamepad_button(int btn);
2012-08-15 02:41:21 +02:00
2017-02-17 17:03:49 +01:00
void config_reset(void);
void config_init(void);
void config_shutdown(void);
2017-04-18 21:48:18 +02:00
void config_load(void);
void config_save(void);
2017-02-17 17:03:49 +01:00
#ifndef DEBUG
#define CONFIG_RAWACCESS
#endif
#ifdef CONFIG_RAWACCESS
#define CONFIGDEFS_EXPORT
extern ConfigEntry configdefs[];
#define config_get(idx) (configdefs + (idx))
#else
#define CONFIGDEFS_EXPORT static
ConfigEntry* config_get(ConfigIndex idx);
#endif
#define config_get_int(idx) (config_get(idx)->val.i)
#define config_get_float(idx) (config_get(idx)->val.f)
#define config_get_str(idx) (config_get(idx)->val.s)
int config_set_int(ConfigIndex idx, int val);
double config_set_float(ConfigIndex idx, double val);
char* config_set_str(ConfigIndex idx, const char *val) attr_nonnull(2) attr_returns_nonnull;
#endif // IGUARD_config_h