summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradityaruplaha <adi24360526@gmail.com>2018-04-21 09:52:34 +0200
committeradityaruplaha <adi24360526@gmail.com>2018-04-21 09:54:33 +0200
commitf48d5e4c4c03ffc8c374b2ec5a2d2455050bbf8a (patch)
tree551cdec2d10712ab347dc204ceb0340f8fa29b9f
parentMerge pull request #323 from Hexagon12/stub-hid (diff)
downloadyuzu-f48d5e4c4c03ffc8c374b2ec5a2d2455050bbf8a.tar
yuzu-f48d5e4c4c03ffc8c374b2ec5a2d2455050bbf8a.tar.gz
yuzu-f48d5e4c4c03ffc8c374b2ec5a2d2455050bbf8a.tar.bz2
yuzu-f48d5e4c4c03ffc8c374b2ec5a2d2455050bbf8a.tar.lz
yuzu-f48d5e4c4c03ffc8c374b2ec5a2d2455050bbf8a.tar.xz
yuzu-f48d5e4c4c03ffc8c374b2ec5a2d2455050bbf8a.tar.zst
yuzu-f48d5e4c4c03ffc8c374b2ec5a2d2455050bbf8a.zip
-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() {
UpdateCurrentFramebufferLayout(width, height);
}
-EmuWindow_SDL2::EmuWindow_SDL2() {
+void EmuWindow_SDL2::Fullscreen() {
+ if (SDL_SetWindowFullscreen(render_window, SDL_WINDOW_FULLSCREEN) == 0) {
+ return;
+ }
+
+ NGLOG_ERROR(Frontend, "Fullscreening failed: {}", SDL_GetError());
+
+ // Try a different fullscreening method
+ NGLOG_INFO(Frontend, "Attempting to use borderless fullscreen...");
+ if (SDL_SetWindowFullscreen(render_window, SDL_WINDOW_FULLSCREEN_DESKTOP) == 0) {
+ return;
+ }
+
+ NGLOG_ERROR(Frontend, "Borderless fullscreening failed: {}", SDL_GetError());
+
+ // Fallback algorithm: Maximise window.
+ // Works on all systems (unless something is seriously wrong), so no fallback for this one.
+ NGLOG_INFO(Frontend, "Falling back on a maximised window...");
+ SDL_MaximizeWindow(render_window);
+}
+
+EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen) {
InputCommon::Init();
SDL_SetMainReady();
@@ -90,6 +111,10 @@ EmuWindow_SDL2::EmuWindow_SDL2() {
exit(1);
}
+ if (fullscreen) {
+ Fullscreen();
+ }
+
gl_context = SDL_GL_CreateContext(render_window);
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;
class EmuWindow_SDL2 : public EmuWindow {
public:
- EmuWindow_SDL2();
+ explicit EmuWindow_SDL2(bool fullscreen);
~EmuWindow_SDL2();
/// Swap buffers to display the next frame
@@ -43,6 +43,9 @@ private:
/// Called by PollEvents when any event that may cause the window to be resized occurs
void OnResize();
+ /// Called when user passes the fullscreen parameter flag
+ void Fullscreen();
+
/// Called when a configuration change affects the minimal size of the window
void OnMinimalClientAreaChangeRequest(
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) {
std::cout << "Usage: " << argv0
<< " [options] <filename>\n"
"-g, --gdbport=NUMBER Enable gdb stub on port NUMBER\n"
+ "-f, --fullscreen Start in fullscreen mode\n"
"-h, --help Display this help and exit\n"
"-v, --version Output version information and exit\n";
}
@@ -67,15 +68,18 @@ int main(int argc, char** argv) {
#endif
std::string filepath;
+ bool fullscreen = false;
+
static struct option long_options[] = {
{"gdbport", required_argument, 0, 'g'},
+ {"fullscreen", no_argument, 0, 'f'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{0, 0, 0, 0},
};
while (optind < argc) {
- char arg = getopt_long(argc, argv, "g:hv", long_options, &option_index);
+ char arg = getopt_long(argc, argv, "g:fhv", long_options, &option_index);
if (arg != -1) {
switch (arg) {
case 'g':
@@ -89,6 +93,10 @@ int main(int argc, char** argv) {
exit(1);
}
break;
+ case 'f':
+ fullscreen = true;
+ NGLOG_INFO(Frontend, "Starting in fullscreen mode...");
+ break;
case 'h':
PrintHelp(argv[0]);
return 0;
@@ -128,7 +136,7 @@ int main(int argc, char** argv) {
Settings::values.use_gdbstub = use_gdbstub;
Settings::Apply();
- std::unique_ptr<EmuWindow_SDL2> emu_window{std::make_unique<EmuWindow_SDL2>()};
+ std::unique_ptr<EmuWindow_SDL2> emu_window{std::make_unique<EmuWindow_SDL2>(fullscreen)};
Core::System& system{Core::System::GetInstance()};