2011-05-21 18:20:04 +02:00
|
|
|
/*
|
2019-08-03 19:43:48 +02:00
|
|
|
* This software is licensed under the terms of the MIT License.
|
2017-02-11 02:24:47 +01:00
|
|
|
* See COPYING for further information.
|
2011-05-21 18:20:04 +02:00
|
|
|
* ---
|
2019-01-23 21:10:43 +01:00
|
|
|
* 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>.
|
2011-05-21 18:20:04 +02:00
|
|
|
*/
|
2017-02-11 02:24:47 +01:00
|
|
|
|
2019-01-23 21:10:43 +01:00
|
|
|
#ifndef IGUARD_config_h
|
|
|
|
#define IGUARD_config_h
|
|
|
|
|
2017-11-25 20:45:11 +01:00
|
|
|
#include "taisei.h"
|
2011-05-21 18:20:04 +02:00
|
|
|
|
2017-02-04 03:56:40 +01:00
|
|
|
#include <SDL_keycode.h>
|
2011-05-21 18:20:04 +02:00
|
|
|
|
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.
|
|
|
|
*/
|
2011-05-21 18:20:04 +02:00
|
|
|
|
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)
|
2011-05-21 18:20:04 +02:00
|
|
|
|
2012-07-30 16:26:04 +02:00
|
|
|
/*
|
2018-01-12 19:26:07 +01:00
|
|
|
* DO NOT REORDER KEYBINDINGS.
|
2017-02-17 17:03:49 +01:00
|
|
|
*
|
2018-01-12 19:26:07 +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
|
|
|
*
|
2018-01-12 19:26:07 +01:00
|
|
|
* KEYDEFS can be safely moved around within CONFIGDEFS, however.
|
|
|
|
* Stuff in GPKEYDEFS is safe to reorder.
|
2012-07-30 16:26:04 +02:00
|
|
|
*/
|
|
|
|
|
2017-02-17 17:03:49 +01:00
|
|
|
#define KEYDEFS \
|
2018-01-12 19:26:07 +01:00
|
|
|
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) \
|
2019-02-22 00:56:03 +01:00
|
|
|
CONFIGDEF_KEYBINDING(KEY_SPECIAL, "key_special", SDL_SCANCODE_C) \
|
|
|
|
CONFIGDEF_KEYBINDING(KEY_SKIP, "key_skip", SDL_SCANCODE_LCTRL) \
|
2018-01-12 19:26:07 +01:00
|
|
|
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) \
|
2018-05-08 15:02:08 +02:00
|
|
|
CONFIGDEF_KEYBINDING(KEY_HITAREAS, "key_hitareas", SDL_SCANCODE_H) \
|
2018-09-15 17:48:03 +02:00
|
|
|
CONFIGDEF_KEYBINDING(KEY_TOGGLE_AUDIO, "key_toggle_audio", SDL_SCANCODE_M) \
|
2017-02-17 17:03:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
#define GPKEYDEFS \
|
2018-01-12 19:26:07 +01:00
|
|
|
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) \
|
2019-02-22 00:56:03 +01:00
|
|
|
CONFIGDEF_GPKEYBINDING(KEY_SPECIAL, "gamepad_key_special", GAMEPAD_BUTTON_SHOULDER_RIGHT) \
|
2018-01-12 19:26:07 +01:00
|
|
|
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 \
|
2017-09-26 23:55:28 +02:00
|
|
|
/* @version must be on top. don't change its default value here, it does nothing. */ \
|
2018-01-12 19:26:07 +01:00
|
|
|
CONFIGDEF_INT (VERSION, "@version", 0) \
|
2017-09-26 23:55:28 +02:00
|
|
|
\
|
2018-01-12 19:26:07 +01:00
|
|
|
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) \
|
2019-04-18 21:56:16 +02:00
|
|
|
CONFIGDEF_INT (VID_DISPLAY, "vid_display", 0) \
|
2018-01-12 19:26:07 +01:00
|
|
|
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) \
|
2018-01-12 19:26:07 +01:00
|
|
|
CONFIGDEF_INT (MIXER_CHUNKSIZE, "mixer_chunksize", 1024) \
|
2019-03-06 13:23:50 +01:00
|
|
|
CONFIGDEF_FLOAT (SFX_VOLUME, "sfx_volume", 0.5) \
|
2018-01-12 19:26:07 +01:00
|
|
|
CONFIGDEF_FLOAT (BGM_VOLUME, "bgm_volume", 1.0) \
|
2018-09-15 17:48:03 +02:00
|
|
|
CONFIGDEF_INT (MUTE_AUDIO, "mute_audio", 0) \
|
2018-01-12 19:26:07 +01:00
|
|
|
CONFIGDEF_INT (NO_STAGEBG, "disable_stagebg", 0) \
|
|
|
|
CONFIGDEF_INT (SAVE_RPY, "save_rpy", 2) \
|
|
|
|
CONFIGDEF_INT (SPELLSTAGE_AUTORESTART, "spellpractice_restart_on_fail", 0) \
|
2018-01-20 16:54:45 +01:00
|
|
|
CONFIGDEF_INT (PRACTICE_POWER, "practice_power", 200) \
|
2018-01-12 19:26:07 +01:00
|
|
|
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) \
|
2019-01-04 23:59:39 +01:00
|
|
|
CONFIGDEF_INT (POSTPROCESS, "postprocess", 2) \
|
|
|
|
CONFIGDEF_INT (HEALTHBAR_STYLE, "healthbar_style", 1) \
|
2019-01-09 04:25:10 +01:00
|
|
|
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) \
|
2019-04-19 13:28:32 +02:00
|
|
|
CONFIGDEF_STRING (GAMEPAD_DEVICE, "gamepad_device", "any") \
|
2018-01-12 19:26:07 +01:00
|
|
|
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,
|
2017-07-15 05:22:56 +02:00
|
|
|
CONFIG_TYPE_GPKEYBINDING,
|
2017-02-17 17:03:49 +01:00
|
|
|
CONFIG_TYPE_FLOAT
|
|
|
|
} ConfigEntryType;
|
2012-08-03 07:06:19 +02:00
|
|
|
|
2017-02-17 19:23:22 +01:00
|
|
|
typedef union ConfigValue {
|
|
|
|
int i;
|
|
|
|
double f;
|
|
|
|
char *s;
|
|
|
|
} ConfigValue;
|
|
|
|
|
2012-08-03 07:06:19 +02:00
|
|
|
typedef struct ConfigEntry {
|
2017-02-17 17:03:49 +01:00
|
|
|
ConfigEntryType type;
|
2012-08-03 07:06:19 +02:00
|
|
|
char *name;
|
2017-02-17 19:23:22 +01:00
|
|
|
ConfigValue val;
|
2012-08-03 07:06:19 +02:00
|
|
|
} ConfigEntry;
|
|
|
|
|
|
|
|
#define CONFIG_LOAD_BUFSIZE 256
|
2012-07-30 16:26:04 +02:00
|
|
|
|
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);
|
2017-11-04 15:15:35 +01:00
|
|
|
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)
|
|
|
|
|
2017-02-17 19:23:22 +01:00
|
|
|
int config_set_int(ConfigIndex idx, int val);
|
|
|
|
double config_set_float(ConfigIndex idx, double val);
|
2018-04-12 16:08:48 +02:00
|
|
|
char* config_set_str(ConfigIndex idx, const char *val) attr_nonnull(2) attr_returns_nonnull;
|
2019-01-23 21:10:43 +01:00
|
|
|
|
|
|
|
#endif // IGUARD_config_h
|