diff options
Diffstat (limited to 'src/citra')
| -rw-r--r-- | src/citra/citra.cpp | 36 | ||||
| -rw-r--r-- | src/citra/config.cpp | 7 |
2 files changed, 30 insertions, 13 deletions
diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index 40e40f192..d6ad13f69 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include <string> | 5 | #include <string> |
| 6 | #include <thread> | 6 | #include <thread> |
| 7 | #include <iostream> | 7 | #include <iostream> |
| 8 | #include <memory> | ||
| 8 | 9 | ||
| 9 | // This needs to be included before getopt.h because the latter #defines symbols used by it | 10 | // This needs to be included before getopt.h because the latter #defines symbols used by it |
| 10 | #include "common/microprofile.h" | 11 | #include "common/microprofile.h" |
| @@ -19,7 +20,6 @@ | |||
| 19 | #include "common/logging/log.h" | 20 | #include "common/logging/log.h" |
| 20 | #include "common/logging/backend.h" | 21 | #include "common/logging/backend.h" |
| 21 | #include "common/logging/filter.h" | 22 | #include "common/logging/filter.h" |
| 22 | #include "common/make_unique.h" | ||
| 23 | #include "common/scope_exit.h" | 23 | #include "common/scope_exit.h" |
| 24 | 24 | ||
| 25 | #include "core/settings.h" | 25 | #include "core/settings.h" |
| @@ -36,25 +36,43 @@ | |||
| 36 | 36 | ||
| 37 | static void PrintHelp() | 37 | static void PrintHelp() |
| 38 | { | 38 | { |
| 39 | std::cout << "Usage: citra <filename>" << std::endl; | 39 | std::cout << "Usage: citra [options] <filename>" << std::endl; |
| 40 | std::cout << "--help, -h Display this information" << std::endl; | ||
| 41 | std::cout << "--gdbport, -g number Enable gdb stub on port number" << std::endl; | ||
| 40 | } | 42 | } |
| 41 | 43 | ||
| 42 | /// Application entry point | 44 | /// Application entry point |
| 43 | int main(int argc, char **argv) { | 45 | int main(int argc, char **argv) { |
| 46 | Config config; | ||
| 44 | int option_index = 0; | 47 | int option_index = 0; |
| 48 | bool use_gdbstub = Settings::values.use_gdbstub; | ||
| 49 | u32 gdb_port = static_cast<u32>(Settings::values.gdbstub_port); | ||
| 50 | char *endarg; | ||
| 45 | std::string boot_filename; | 51 | std::string boot_filename; |
| 52 | |||
| 46 | static struct option long_options[] = { | 53 | static struct option long_options[] = { |
| 47 | { "help", no_argument, 0, 'h' }, | 54 | { "help", no_argument, 0, 'h' }, |
| 55 | { "gdbport", required_argument, 0, 'g' }, | ||
| 48 | { 0, 0, 0, 0 } | 56 | { 0, 0, 0, 0 } |
| 49 | }; | 57 | }; |
| 50 | 58 | ||
| 51 | while (optind < argc) { | 59 | while (optind < argc) { |
| 52 | char arg = getopt_long(argc, argv, ":h", long_options, &option_index); | 60 | char arg = getopt_long(argc, argv, ":hg:", long_options, &option_index); |
| 53 | if (arg != -1) { | 61 | if (arg != -1) { |
| 54 | switch (arg) { | 62 | switch (arg) { |
| 55 | case 'h': | 63 | case 'h': |
| 56 | PrintHelp(); | 64 | PrintHelp(); |
| 57 | return 0; | 65 | return 0; |
| 66 | case 'g': | ||
| 67 | errno = 0; | ||
| 68 | gdb_port = strtoul(optarg, &endarg, 0); | ||
| 69 | use_gdbstub = true; | ||
| 70 | if (endarg == optarg) errno = EINVAL; | ||
| 71 | if (errno != 0) { | ||
| 72 | perror("--gdbport"); | ||
| 73 | exit(1); | ||
| 74 | } | ||
| 75 | break; | ||
| 58 | } | 76 | } |
| 59 | } else { | 77 | } else { |
| 60 | boot_filename = argv[optind]; | 78 | boot_filename = argv[optind]; |
| @@ -73,16 +91,14 @@ int main(int argc, char **argv) { | |||
| 73 | return -1; | 91 | return -1; |
| 74 | } | 92 | } |
| 75 | 93 | ||
| 76 | Config config; | ||
| 77 | log_filter.ParseFilterString(Settings::values.log_filter); | 94 | log_filter.ParseFilterString(Settings::values.log_filter); |
| 78 | 95 | ||
| 79 | GDBStub::ToggleServer(Settings::values.use_gdbstub); | 96 | // Apply the command line arguments |
| 80 | GDBStub::SetServerPort(static_cast<u32>(Settings::values.gdbstub_port)); | 97 | Settings::values.gdbstub_port = gdb_port; |
| 81 | 98 | Settings::values.use_gdbstub = use_gdbstub; | |
| 82 | std::unique_ptr<EmuWindow_SDL2> emu_window = Common::make_unique<EmuWindow_SDL2>(); | 99 | Settings::Apply(); |
| 83 | 100 | ||
| 84 | VideoCore::g_hw_renderer_enabled = Settings::values.use_hw_renderer; | 101 | std::unique_ptr<EmuWindow_SDL2> emu_window = std::make_unique<EmuWindow_SDL2>(); |
| 85 | VideoCore::g_shader_jit_enabled = Settings::values.use_shader_jit; | ||
| 86 | 102 | ||
| 87 | System::Init(emu_window.get()); | 103 | System::Init(emu_window.get()); |
| 88 | SCOPE_EXIT({ System::Shutdown(); }); | 104 | SCOPE_EXIT({ System::Shutdown(); }); |
diff --git a/src/citra/config.cpp b/src/citra/config.cpp index 9034b188e..6b6617352 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <memory> | ||
| 6 | |||
| 5 | #include <inih/cpp/INIReader.h> | 7 | #include <inih/cpp/INIReader.h> |
| 6 | 8 | ||
| 7 | #include <SDL.h> | 9 | #include <SDL.h> |
| @@ -10,7 +12,6 @@ | |||
| 10 | 12 | ||
| 11 | #include "common/file_util.h" | 13 | #include "common/file_util.h" |
| 12 | #include "common/logging/log.h" | 14 | #include "common/logging/log.h" |
| 13 | #include "common/make_unique.h" | ||
| 14 | 15 | ||
| 15 | #include "core/settings.h" | 16 | #include "core/settings.h" |
| 16 | 17 | ||
| @@ -19,7 +20,7 @@ | |||
| 19 | Config::Config() { | 20 | Config::Config() { |
| 20 | // TODO: Don't hardcode the path; let the frontend decide where to put the config files. | 21 | // TODO: Don't hardcode the path; let the frontend decide where to put the config files. |
| 21 | sdl2_config_loc = FileUtil::GetUserPath(D_CONFIG_IDX) + "sdl2-config.ini"; | 22 | sdl2_config_loc = FileUtil::GetUserPath(D_CONFIG_IDX) + "sdl2-config.ini"; |
| 22 | sdl2_config = Common::make_unique<INIReader>(sdl2_config_loc); | 23 | sdl2_config = std::make_unique<INIReader>(sdl2_config_loc); |
| 23 | 24 | ||
| 24 | Reload(); | 25 | Reload(); |
| 25 | } | 26 | } |
| @@ -31,7 +32,7 @@ bool Config::LoadINI(const std::string& default_contents, bool retry) { | |||
| 31 | LOG_WARNING(Config, "Failed to load %s. Creating file from defaults...", location); | 32 | LOG_WARNING(Config, "Failed to load %s. Creating file from defaults...", location); |
| 32 | FileUtil::CreateFullPath(location); | 33 | FileUtil::CreateFullPath(location); |
| 33 | FileUtil::WriteStringToFile(true, default_contents, location); | 34 | FileUtil::WriteStringToFile(true, default_contents, location); |
| 34 | sdl2_config = Common::make_unique<INIReader>(location); // Reopen file | 35 | sdl2_config = std::make_unique<INIReader>(location); // Reopen file |
| 35 | 36 | ||
| 36 | return LoadINI(default_contents, false); | 37 | return LoadINI(default_contents, false); |
| 37 | } | 38 | } |