summaryrefslogtreecommitdiff
path: root/src/yuzu_cmd/yuzu.cpp
diff options
context:
space:
mode:
authorGravatar Levi2021-01-10 22:09:56 -0700
committerGravatar Levi2021-01-10 22:09:56 -0700
commit7a3c884e39fccfbb498b855080bffabc9ce2e7f1 (patch)
tree5056f9406dec188439cb0deb87603498243a9412 /src/yuzu_cmd/yuzu.cpp
parentMore forgetting... duh (diff)
parentMerge pull request #5229 from Morph1984/fullscreen-opt (diff)
downloadyuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.tar.gz
yuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.tar.xz
yuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.zip
Merge remote-tracking branch 'upstream/master' into int-flags
Diffstat (limited to 'src/yuzu_cmd/yuzu.cpp')
-rw-r--r--src/yuzu_cmd/yuzu.cpp50
1 files changed, 13 insertions, 37 deletions
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp
index 3a76c785f..4faf62ede 100644
--- a/src/yuzu_cmd/yuzu.cpp
+++ b/src/yuzu_cmd/yuzu.cpp
@@ -25,7 +25,6 @@
25#include "core/crypto/key_manager.h" 25#include "core/crypto/key_manager.h"
26#include "core/file_sys/registered_cache.h" 26#include "core/file_sys/registered_cache.h"
27#include "core/file_sys/vfs_real.h" 27#include "core/file_sys/vfs_real.h"
28#include "core/gdbstub/gdbstub.h"
29#include "core/hle/kernel/process.h" 28#include "core/hle/kernel/process.h"
30#include "core/hle/service/filesystem/filesystem.h" 29#include "core/hle/service/filesystem/filesystem.h"
31#include "core/loader/loader.h" 30#include "core/loader/loader.h"
@@ -36,9 +35,7 @@
36#include "yuzu_cmd/config.h" 35#include "yuzu_cmd/config.h"
37#include "yuzu_cmd/emu_window/emu_window_sdl2.h" 36#include "yuzu_cmd/emu_window/emu_window_sdl2.h"
38#include "yuzu_cmd/emu_window/emu_window_sdl2_gl.h" 37#include "yuzu_cmd/emu_window/emu_window_sdl2_gl.h"
39#ifdef HAS_VULKAN
40#include "yuzu_cmd/emu_window/emu_window_sdl2_vk.h" 38#include "yuzu_cmd/emu_window/emu_window_sdl2_vk.h"
41#endif
42 39
43#ifdef _WIN32 40#ifdef _WIN32
44// windows.h needs to be included before shellapi.h 41// windows.h needs to be included before shellapi.h
@@ -65,7 +62,6 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
65static void PrintHelp(const char* argv0) { 62static void PrintHelp(const char* argv0) {
66 std::cout << "Usage: " << argv0 63 std::cout << "Usage: " << argv0
67 << " [options] <filename>\n" 64 << " [options] <filename>\n"
68 "-g, --gdbport=NUMBER Enable gdb stub on port NUMBER\n"
69 "-f, --fullscreen Start in fullscreen mode\n" 65 "-f, --fullscreen Start in fullscreen mode\n"
70 "-h, --help Display this help and exit\n" 66 "-h, --help Display this help and exit\n"
71 "-v, --version Output version information and exit\n" 67 "-v, --version Output version information and exit\n"
@@ -97,12 +93,8 @@ int main(int argc, char** argv) {
97 Config config; 93 Config config;
98 94
99 int option_index = 0; 95 int option_index = 0;
100 bool use_gdbstub = Settings::values.use_gdbstub;
101 u32 gdb_port = static_cast<u32>(Settings::values.gdbstub_port);
102 96
103 InitializeLogging(); 97 InitializeLogging();
104
105 char* endarg;
106#ifdef _WIN32 98#ifdef _WIN32
107 int argc_w; 99 int argc_w;
108 auto argv_w = CommandLineToArgvW(GetCommandLineW(), &argc_w); 100 auto argv_w = CommandLineToArgvW(GetCommandLineW(), &argc_w);
@@ -117,26 +109,17 @@ int main(int argc, char** argv) {
117 bool fullscreen = false; 109 bool fullscreen = false;
118 110
119 static struct option long_options[] = { 111 static struct option long_options[] = {
120 {"gdbport", required_argument, 0, 'g'}, {"fullscreen", no_argument, 0, 'f'}, 112 {"fullscreen", no_argument, 0, 'f'},
121 {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'v'}, 113 {"help", no_argument, 0, 'h'},
122 {"program", optional_argument, 0, 'p'}, {0, 0, 0, 0}, 114 {"version", no_argument, 0, 'v'},
115 {"program", optional_argument, 0, 'p'},
116 {0, 0, 0, 0},
123 }; 117 };
124 118
125 while (optind < argc) { 119 while (optind < argc) {
126 int arg = getopt_long(argc, argv, "g:fhvp::", long_options, &option_index); 120 int arg = getopt_long(argc, argv, "g:fhvp::", long_options, &option_index);
127 if (arg != -1) { 121 if (arg != -1) {
128 switch (static_cast<char>(arg)) { 122 switch (static_cast<char>(arg)) {
129 case 'g':
130 errno = 0;
131 gdb_port = strtoul(optarg, &endarg, 0);
132 use_gdbstub = true;
133 if (endarg == optarg)
134 errno = EINVAL;
135 if (errno != 0) {
136 perror("--gdbport");
137 exit(1);
138 }
139 break;
140 case 'f': 123 case 'f':
141 fullscreen = true; 124 fullscreen = true;
142 LOG_INFO(Frontend, "Starting in fullscreen mode..."); 125 LOG_INFO(Frontend, "Starting in fullscreen mode...");
@@ -174,27 +157,20 @@ int main(int argc, char** argv) {
174 return -1; 157 return -1;
175 } 158 }
176 159
177 // Apply the command line arguments 160 auto& system{Core::System::GetInstance()};
178 Settings::values.gdbstub_port = gdb_port;
179 Settings::values.use_gdbstub = use_gdbstub;
180 Settings::Apply();
181
182 Core::System& system{Core::System::GetInstance()};
183 InputCommon::InputSubsystem input_subsystem; 161 InputCommon::InputSubsystem input_subsystem;
184 162
163 // Apply the command line arguments
164 Settings::Apply(system);
165
185 std::unique_ptr<EmuWindow_SDL2> emu_window; 166 std::unique_ptr<EmuWindow_SDL2> emu_window;
186 switch (Settings::values.renderer_backend.GetValue()) { 167 switch (Settings::values.renderer_backend.GetValue()) {
187 case Settings::RendererBackend::OpenGL: 168 case Settings::RendererBackend::OpenGL:
188 emu_window = std::make_unique<EmuWindow_SDL2_GL>(&input_subsystem, fullscreen); 169 emu_window = std::make_unique<EmuWindow_SDL2_GL>(&input_subsystem, fullscreen);
189 break; 170 break;
190 case Settings::RendererBackend::Vulkan: 171 case Settings::RendererBackend::Vulkan:
191#ifdef HAS_VULKAN
192 emu_window = std::make_unique<EmuWindow_SDL2_VK>(&input_subsystem); 172 emu_window = std::make_unique<EmuWindow_SDL2_VK>(&input_subsystem);
193 break; 173 break;
194#else
195 LOG_CRITICAL(Frontend, "Vulkan backend has not been compiled!");
196 return 1;
197#endif
198 } 174 }
199 175
200 system.SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>()); 176 system.SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>());
@@ -224,7 +200,7 @@ int main(int argc, char** argv) {
224 const u16 loader_id = static_cast<u16>(Core::System::ResultStatus::ErrorLoader); 200 const u16 loader_id = static_cast<u16>(Core::System::ResultStatus::ErrorLoader);
225 const u16 error_id = static_cast<u16>(load_result) - loader_id; 201 const u16 error_id = static_cast<u16>(load_result) - loader_id;
226 LOG_CRITICAL(Frontend, 202 LOG_CRITICAL(Frontend,
227 "While attempting to load the ROM requested, an error occured. Please " 203 "While attempting to load the ROM requested, an error occurred. Please "
228 "refer to the yuzu wiki for more information or the yuzu discord for " 204 "refer to the yuzu wiki for more information or the yuzu discord for "
229 "additional help.\n\nError Code: {:04X}-{:04X}\nError Description: {}", 205 "additional help.\n\nError Code: {:04X}-{:04X}\nError Description: {}",
230 loader_id, error_id, static_cast<Loader::ResultStatus>(error_id)); 206 loader_id, error_id, static_cast<Loader::ResultStatus>(error_id));
@@ -240,11 +216,11 @@ int main(int argc, char** argv) {
240 system.CurrentProcess()->GetTitleID(), false, 216 system.CurrentProcess()->GetTitleID(), false,
241 [](VideoCore::LoadCallbackStage, size_t value, size_t total) {}); 217 [](VideoCore::LoadCallbackStage, size_t value, size_t total) {});
242 218
243 system.Run(); 219 void(system.Run());
244 while (emu_window->IsOpen()) { 220 while (emu_window->IsOpen()) {
245 std::this_thread::sleep_for(std::chrono::milliseconds(1)); 221 emu_window->WaitEvent();
246 } 222 }
247 system.Pause(); 223 void(system.Pause());
248 system.Shutdown(); 224 system.Shutdown();
249 225
250 detached_tasks.WaitForAllTasks(); 226 detached_tasks.WaitForAllTasks();