summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar adityaruplaha2018-04-21 13:22:34 +0530
committerGravatar adityaruplaha2018-04-21 13:24:33 +0530
commitf48d5e4c4c03ffc8c374b2ec5a2d2455050bbf8a (patch)
tree551cdec2d10712ab347dc204ceb0340f8fa29b9f /src
parentMerge pull request #323 from Hexagon12/stub-hid (diff)
downloadyuzu-f48d5e4c4c03ffc8c374b2ec5a2d2455050bbf8a.tar.gz
yuzu-f48d5e4c4c03ffc8c374b2ec5a2d2455050bbf8a.tar.xz
yuzu-f48d5e4c4c03ffc8c374b2ec5a2d2455050bbf8a.zip
SDL2: Implement fullscreen. (Original PR: citra-emu/citra#3607)
Diffstat (limited to 'src')
-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 261312f62..0a4644500 100644
--- a/src/yuzu_cmd/yuzu.cpp
+++ b/src/yuzu_cmd/yuzu.cpp
@@ -41,6 +41,7 @@ static void PrintHelp(const char* argv0) {
41 std::cout << "Usage: " << argv0 41 std::cout << "Usage: " << argv0
42 << " [options] <filename>\n" 42 << " [options] <filename>\n"
43 "-g, --gdbport=NUMBER Enable gdb stub on port NUMBER\n" 43 "-g, --gdbport=NUMBER Enable gdb stub on port NUMBER\n"
44 "-f, --fullscreen Start in fullscreen mode\n"
44 "-h, --help Display this help and exit\n" 45 "-h, --help Display this help and exit\n"
45 "-v, --version Output version information and exit\n"; 46 "-v, --version Output version information and exit\n";
46} 47}
@@ -67,15 +68,18 @@ int main(int argc, char** argv) {
67#endif 68#endif
68 std::string filepath; 69 std::string filepath;
69 70
71 bool fullscreen = false;
72
70 static struct option long_options[] = { 73 static struct option long_options[] = {
71 {"gdbport", required_argument, 0, 'g'}, 74 {"gdbport", required_argument, 0, 'g'},
75 {"fullscreen", no_argument, 0, 'f'},
72 {"help", no_argument, 0, 'h'}, 76 {"help", no_argument, 0, 'h'},
73 {"version", no_argument, 0, 'v'}, 77 {"version", no_argument, 0, 'v'},
74 {0, 0, 0, 0}, 78 {0, 0, 0, 0},
75 }; 79 };
76 80
77 while (optind < argc) { 81 while (optind < argc) {
78 char arg = getopt_long(argc, argv, "g:hv", long_options, &option_index); 82 char arg = getopt_long(argc, argv, "g:fhv", long_options, &option_index);
79 if (arg != -1) { 83 if (arg != -1) {
80 switch (arg) { 84 switch (arg) {
81 case 'g': 85 case 'g':
@@ -89,6 +93,10 @@ int main(int argc, char** argv) {
89 exit(1); 93 exit(1);
90 } 94 }
91 break; 95 break;
96 case 'f':
97 fullscreen = true;
98 NGLOG_INFO(Frontend, "Starting in fullscreen mode...");
99 break;
92 case 'h': 100 case 'h':
93 PrintHelp(argv[0]); 101 PrintHelp(argv[0]);
94 return 0; 102 return 0;
@@ -128,7 +136,7 @@ int main(int argc, char** argv) {
128 Settings::values.use_gdbstub = use_gdbstub; 136 Settings::values.use_gdbstub = use_gdbstub;
129 Settings::Apply(); 137 Settings::Apply();
130 138
131 std::unique_ptr<EmuWindow_SDL2> emu_window{std::make_unique<EmuWindow_SDL2>()}; 139 std::unique_ptr<EmuWindow_SDL2> emu_window{std::make_unique<EmuWindow_SDL2>(fullscreen)};
132 140
133 Core::System& system{Core::System::GetInstance()}; 141 Core::System& system{Core::System::GetInstance()};
134 142