Fixed swapping screens on landscape displays forcing portrait layout

This commit is contained in:
OpenSauce04 2024-08-23 12:39:30 +01:00 committed by OpenSauce
parent 3188aa489f
commit 8af024bddb
5 changed files with 23 additions and 6 deletions

View File

@ -29,6 +29,8 @@ add_library(lime-android SHARED
ndk_motion.h ndk_motion.h
system_save_game.cpp system_save_game.cpp
native_log.cpp native_log.cpp
util.cpp
util.h
) )
target_link_libraries(lime-android PRIVATE audio_core lime_common lime_core input_common network) target_link_libraries(lime-android PRIVATE audio_core lime_common lime_core input_common network)

View File

@ -13,14 +13,10 @@
#include "jni/emu_window/emu_window.h" #include "jni/emu_window/emu_window.h"
#include "jni/id_cache.h" #include "jni/id_cache.h"
#include "jni/input_manager.h" #include "jni/input_manager.h"
#include "jni/util.h"
#include "network/network.h" #include "network/network.h"
#include "video_core/renderer_base.h" #include "video_core/renderer_base.h"
static bool IsPortraitMode() {
return JNI_FALSE != IDCache::GetEnvForThread()->CallStaticBooleanMethod(
IDCache::GetNativeLibraryClass(), IDCache::GetIsPortraitMode());
}
bool EmuWindow_Android::OnSurfaceChanged(ANativeWindow* surface) { bool EmuWindow_Android::OnSurfaceChanged(ANativeWindow* surface) {
if (render_window == surface) { if (render_window == surface) {
return false; return false;

View File

@ -54,6 +54,7 @@
#include "jni/id_cache.h" #include "jni/id_cache.h"
#include "jni/input_manager.h" #include "jni/input_manager.h"
#include "jni/ndk_motion.h" #include "jni/ndk_motion.h"
#include "jni/util.h"
#include "video_core/debug_utils/debug_utils.h" #include "video_core/debug_utils/debug_utils.h"
#include "video_core/gpu.h" #include "video_core/gpu.h"
#include "video_core/renderer_base.h" #include "video_core/renderer_base.h"
@ -364,7 +365,7 @@ void Java_io_github_lime3ds_android_NativeLibrary_swapScreens([[maybe_unused]] J
Settings::values.swap_screen = swap_screens; Settings::values.swap_screen = swap_screens;
auto& system = Core::System::GetInstance(); auto& system = Core::System::GetInstance();
if (system.IsPoweredOn()) { if (system.IsPoweredOn()) {
system.GPU().Renderer().UpdateCurrentFramebufferLayout(!(rotation % 2)); system.GPU().Renderer().UpdateCurrentFramebufferLayout(IsPortraitMode());
} }
InputManager::screen_rotation = rotation; InputManager::screen_rotation = rotation;
Camera::NDK::g_rotation = rotation; Camera::NDK::g_rotation = rotation;

View File

@ -0,0 +1,10 @@
// Copyright Citra Emulator Project / Lime3DS Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "jni/id_cache.h"
bool IsPortraitMode() {
return JNI_FALSE != IDCache::GetEnvForThread()->CallStaticBooleanMethod(
IDCache::GetNativeLibraryClass(), IDCache::GetIsPortraitMode());
}

View File

@ -0,0 +1,8 @@
// Copyright Citra Emulator Project / Lime3DS Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
/// Calls and returns the value of NativeLibrary.isPortraitMode
bool IsPortraitMode();