diff options
Diffstat (limited to 'src/citra/config.cpp')
| -rw-r--r-- | src/citra/config.cpp | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/src/citra/config.cpp b/src/citra/config.cpp index fac1c9a0e..ef1229912 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp | |||
| @@ -8,8 +8,10 @@ | |||
| 8 | #include "citra/default_ini.h" | 8 | #include "citra/default_ini.h" |
| 9 | #include "common/file_util.h" | 9 | #include "common/file_util.h" |
| 10 | #include "common/logging/log.h" | 10 | #include "common/logging/log.h" |
| 11 | #include "common/param_package.h" | ||
| 11 | #include "config.h" | 12 | #include "config.h" |
| 12 | #include "core/settings.h" | 13 | #include "core/settings.h" |
| 14 | #include "input_common/main.h" | ||
| 13 | 15 | ||
| 14 | Config::Config() { | 16 | Config::Config() { |
| 15 | // TODO: Don't hardcode the path; let the frontend decide where to put the config files. | 17 | // TODO: Don't hardcode the path; let the frontend decide where to put the config files. |
| @@ -37,25 +39,40 @@ bool Config::LoadINI(const std::string& default_contents, bool retry) { | |||
| 37 | return true; | 39 | return true; |
| 38 | } | 40 | } |
| 39 | 41 | ||
| 40 | static const std::array<int, Settings::NativeInput::NUM_INPUTS> defaults = { | 42 | static const std::array<int, Settings::NativeButton::NumButtons> default_buttons = { |
| 41 | // directly mapped keys | 43 | SDL_SCANCODE_A, SDL_SCANCODE_S, SDL_SCANCODE_Z, SDL_SCANCODE_X, SDL_SCANCODE_T, |
| 42 | SDL_SCANCODE_A, SDL_SCANCODE_S, SDL_SCANCODE_Z, SDL_SCANCODE_X, SDL_SCANCODE_Q, SDL_SCANCODE_W, | 44 | SDL_SCANCODE_G, SDL_SCANCODE_F, SDL_SCANCODE_H, SDL_SCANCODE_Q, SDL_SCANCODE_W, |
| 43 | SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_M, SDL_SCANCODE_N, SDL_SCANCODE_B, SDL_SCANCODE_T, | 45 | SDL_SCANCODE_M, SDL_SCANCODE_N, SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_B, |
| 44 | SDL_SCANCODE_G, SDL_SCANCODE_F, SDL_SCANCODE_H, SDL_SCANCODE_I, SDL_SCANCODE_K, SDL_SCANCODE_J, | ||
| 45 | SDL_SCANCODE_L, | ||
| 46 | |||
| 47 | // indirectly mapped keys | ||
| 48 | SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, SDL_SCANCODE_D, | ||
| 49 | }; | 46 | }; |
| 50 | 47 | ||
| 48 | static const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> default_analogs{{ | ||
| 49 | { | ||
| 50 | SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, SDL_SCANCODE_D, | ||
| 51 | }, | ||
| 52 | { | ||
| 53 | SDL_SCANCODE_I, SDL_SCANCODE_K, SDL_SCANCODE_J, SDL_SCANCODE_L, SDL_SCANCODE_D, | ||
| 54 | }, | ||
| 55 | }}; | ||
| 56 | |||
| 51 | void Config::ReadValues() { | 57 | void Config::ReadValues() { |
| 52 | // Controls | 58 | // Controls |
| 53 | for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) { | 59 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { |
| 54 | Settings::values.input_mappings[Settings::NativeInput::All[i]] = | 60 | std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); |
| 55 | sdl2_config->GetInteger("Controls", Settings::NativeInput::Mapping[i], defaults[i]); | 61 | Settings::values.buttons[i] = |
| 62 | sdl2_config->Get("Controls", Settings::NativeButton::mapping[i], default_param); | ||
| 63 | if (Settings::values.buttons[i].empty()) | ||
| 64 | Settings::values.buttons[i] = default_param; | ||
| 65 | } | ||
| 66 | |||
| 67 | for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { | ||
| 68 | std::string default_param = InputCommon::GenerateAnalogParamFromKeys( | ||
| 69 | default_analogs[i][0], default_analogs[i][1], default_analogs[i][2], | ||
| 70 | default_analogs[i][3], default_analogs[i][4], 0.5f); | ||
| 71 | Settings::values.analogs[i] = | ||
| 72 | sdl2_config->Get("Controls", Settings::NativeAnalog::mapping[i], default_param); | ||
| 73 | if (Settings::values.analogs[i].empty()) | ||
| 74 | Settings::values.analogs[i] = default_param; | ||
| 56 | } | 75 | } |
| 57 | Settings::values.pad_circle_modifier_scale = | ||
| 58 | (float)sdl2_config->GetReal("Controls", "pad_circle_modifier_scale", 0.5); | ||
| 59 | 76 | ||
| 60 | // Core | 77 | // Core |
| 61 | Settings::values.use_cpu_jit = sdl2_config->GetBoolean("Core", "use_cpu_jit", true); | 78 | Settings::values.use_cpu_jit = sdl2_config->GetBoolean("Core", "use_cpu_jit", true); |