summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2.cpp27
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2.h5
-rw-r--r--src/yuzu_cmd/yuzu.cpp12
3 files changed, 40 insertions, 4 deletions
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
index 3d7cd06a4..36d40a9b5 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
@@ -56,7 +56,28 @@ void EmuWindow_SDL2::OnResize() {
56 UpdateCurrentFramebufferLayout(width, height); 56 UpdateCurrentFramebufferLayout(width, height);
57} 57}
58 58
59EmuWindow_SDL2::EmuWindow_SDL2() { 59void EmuWindow_SDL2::Fullscreen() {
60 if (SDL_SetWindowFullscreen(render_window, SDL_WINDOW_FULLSCREEN) == 0) {
61 return;
62 }
63
64 NGLOG_ERROR(Frontend, "Fullscreening failed: {}", SDL_GetError());
65
66 // Try a different fullscreening method
67 NGLOG_INFO(Frontend, "Attempting to use borderless fullscreen...");
68 if (SDL_SetWindowFullscreen(render_window, SDL_WINDOW_FULLSCREEN_DESKTOP) == 0) {
69 return;
70 }
71
72 NGLOG_ERROR(Frontend, "Borderless fullscreening failed: {}", SDL_GetError());
73
74 // Fallback algorithm: Maximise window.
75 // Works on all systems (unless something is seriously wrong), so no fallback for this one.
76 NGLOG_INFO(Frontend, "Falling back on a maximised window...");
77 SDL_MaximizeWindow(render_window);
78}
79
80EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen) {
60 InputCommon::Init(); 81 InputCommon::Init();
61 82
62 SDL_SetMainReady(); 83 SDL_SetMainReady();
@@ -90,6 +111,10 @@ EmuWindow_SDL2::EmuWindow_SDL2() {
90 exit(1); 111 exit(1);
91 } 112 }
92 113
114 if (fullscreen) {
115 Fullscreen();
116 }
117
93 gl_context = SDL_GL_CreateContext(render_window); 118 gl_context = SDL_GL_CreateContext(render_window);
94 119
95 if (gl_context == nullptr) { 120 if (gl_context == nullptr) {
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.h b/src/yuzu_cmd/emu_window/emu_window_sdl2.h
index 3664d2fbe..7d5cfffb6 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2.h
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.h
@@ -12,7 +12,7 @@ struct SDL_Window;
12 12
13class EmuWindow_SDL2 : public EmuWindow { 13class EmuWindow_SDL2 : public EmuWindow {
14public: 14public:
15 EmuWindow_SDL2(); 15 explicit EmuWindow_SDL2(bool fullscreen);
16 ~EmuWindow_SDL2(); 16 ~EmuWindow_SDL2();
17 17
18 /// Swap buffers to display the next frame 18 /// Swap buffers to display the next frame
@@ -43,6 +43,9 @@ private:
43 /// Called by PollEvents when any event that may cause the window to be resized occurs 43 /// Called by PollEvents when any event that may cause the window to be resized occurs
44 void OnResize(); 44 void OnResize();
45 45
46 /// Called when user passes the fullscreen parameter flag
47 void Fullscreen();
48
46 /// Called when a configuration change affects the minimal size of the window 49 /// Called when a configuration change affects the minimal size of the window
47 void OnMinimalClientAreaChangeRequest( 50 void OnMinimalClientAreaChangeRequest(
48 const std::pair<unsigned, unsigned>& minimal_size) override; 51 const std::pair<unsigned, unsigned>& minimal_size) override;
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp
index a91140447..39603e881 100644
--- a/src/yuzu_cmd/yuzu.cpp
+++ b/src/yuzu_cmd/yuzu.cpp
@@ -50,6 +50,7 @@ static void PrintHelp(const char* argv0) {
50 std::cout << "Usage: " << argv0 50 std::cout << "Usage: " << argv0
51 << " [options] <filename>\n" 51 << " [options] <filename>\n"
52 "-g, --gdbport=NUMBER Enable gdb stub on port NUMBER\n" 52 "-g, --gdbport=NUMBER Enable gdb stub on port NUMBER\n"
53 "-f, --fullscreen Start in fullscreen mode\n"
53 "-h, --help Display this help and exit\n" 54 "-h, --help Display this help and exit\n"
54 "-v, --version Output version information and exit\n"; 55 "-v, --version Output version information and exit\n";
55} 56}
@@ -76,15 +77,18 @@ int main(int argc, char** argv) {
76#endif 77#endif
77 std::string filepath; 78 std::string filepath;
78 79
80 bool fullscreen = false;
81
79 static struct option long_options[] = { 82 static struct option long_options[] = {
80 {"gdbport", required_argument, 0, 'g'}, 83 {"gdbport", required_argument, 0, 'g'},
84 {"fullscreen", no_argument, 0, 'f'},
81 {"help", no_argument, 0, 'h'}, 85 {"help", no_argument, 0, 'h'},
82 {"version", no_argument, 0, 'v'}, 86 {"version", no_argument, 0, 'v'},
83 {0, 0, 0, 0}, 87 {0, 0, 0, 0},
84 }; 88 };
85 89
86 while (optind < argc) { 90 while (optind < argc) {
87 char arg = getopt_long(argc, argv, "g:hv", long_options, &option_index); 91 char arg = getopt_long(argc, argv, "g:fhv", long_options, &option_index);
88 if (arg != -1) { 92 if (arg != -1) {
89 switch (arg) { 93 switch (arg) {
90 case 'g': 94 case 'g':
@@ -98,6 +102,10 @@ int main(int argc, char** argv) {
98 exit(1); 102 exit(1);
99 } 103 }
100 break; 104 break;
105 case 'f':
106 fullscreen = true;
107 NGLOG_INFO(Frontend, "Starting in fullscreen mode...");
108 break;
101 case 'h': 109 case 'h':
102 PrintHelp(argv[0]); 110 PrintHelp(argv[0]);
103 return 0; 111 return 0;
@@ -137,7 +145,7 @@ int main(int argc, char** argv) {
137 Settings::values.use_gdbstub = use_gdbstub; 145 Settings::values.use_gdbstub = use_gdbstub;
138 Settings::Apply(); 146 Settings::Apply();
139 147
140 std::unique_ptr<EmuWindow_SDL2> emu_window{std::make_unique<EmuWindow_SDL2>()}; 148 std::unique_ptr<EmuWindow_SDL2> emu_window{std::make_unique<EmuWindow_SDL2>(fullscreen)};
141 149
142 Core::System& system{Core::System::GetInstance()}; 150 Core::System& system{Core::System::GetInstance()};
143 151