diff options
Diffstat (limited to 'src')
4 files changed, 5 insertions, 95 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt index f4db61cb3..20a0394f5 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt | |||
| @@ -6,15 +6,12 @@ package org.yuzu.yuzu_emu.activities | |||
| 6 | import android.app.Activity | 6 | import android.app.Activity |
| 7 | import android.content.Context | 7 | import android.content.Context |
| 8 | import android.content.Intent | 8 | import android.content.Intent |
| 9 | import android.content.res.Configuration | ||
| 10 | import android.graphics.Rect | 9 | import android.graphics.Rect |
| 11 | import android.hardware.Sensor | 10 | import android.hardware.Sensor |
| 12 | import android.hardware.SensorEvent | 11 | import android.hardware.SensorEvent |
| 13 | import android.hardware.SensorEventListener | 12 | import android.hardware.SensorEventListener |
| 14 | import android.hardware.SensorManager | 13 | import android.hardware.SensorManager |
| 15 | import android.hardware.display.DisplayManager | ||
| 16 | import android.os.Bundle | 14 | import android.os.Bundle |
| 17 | import android.view.Display | ||
| 18 | import android.view.InputDevice | 15 | import android.view.InputDevice |
| 19 | import android.view.KeyEvent | 16 | import android.view.KeyEvent |
| 20 | import android.view.MotionEvent | 17 | import android.view.MotionEvent |
| @@ -23,7 +20,6 @@ import android.view.View | |||
| 23 | import android.view.inputmethod.InputMethodManager | 20 | import android.view.inputmethod.InputMethodManager |
| 24 | import androidx.activity.viewModels | 21 | import androidx.activity.viewModels |
| 25 | import androidx.appcompat.app.AppCompatActivity | 22 | import androidx.appcompat.app.AppCompatActivity |
| 26 | import androidx.core.content.getSystemService | ||
| 27 | import androidx.core.view.WindowCompat | 23 | import androidx.core.view.WindowCompat |
| 28 | import androidx.core.view.WindowInsetsCompat | 24 | import androidx.core.view.WindowInsetsCompat |
| 29 | import androidx.core.view.WindowInsetsControllerCompat | 25 | import androidx.core.view.WindowInsetsControllerCompat |
| @@ -39,7 +35,6 @@ import org.yuzu.yuzu_emu.features.settings.model.SettingsViewModel | |||
| 39 | import org.yuzu.yuzu_emu.fragments.EmulationFragment | 35 | import org.yuzu.yuzu_emu.fragments.EmulationFragment |
| 40 | import org.yuzu.yuzu_emu.model.Game | 36 | import org.yuzu.yuzu_emu.model.Game |
| 41 | import org.yuzu.yuzu_emu.utils.ControllerMappingHelper | 37 | import org.yuzu.yuzu_emu.utils.ControllerMappingHelper |
| 42 | import org.yuzu.yuzu_emu.utils.EmulationMenuSettings | ||
| 43 | import org.yuzu.yuzu_emu.utils.ForegroundService | 38 | import org.yuzu.yuzu_emu.utils.ForegroundService |
| 44 | import org.yuzu.yuzu_emu.utils.InputHandler | 39 | import org.yuzu.yuzu_emu.utils.InputHandler |
| 45 | import org.yuzu.yuzu_emu.utils.NfcReader | 40 | import org.yuzu.yuzu_emu.utils.NfcReader |
| @@ -148,11 +143,6 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { | |||
| 148 | super.onResume() | 143 | super.onResume() |
| 149 | nfcReader.startScanning() | 144 | nfcReader.startScanning() |
| 150 | startMotionSensorListener() | 145 | startMotionSensorListener() |
| 151 | |||
| 152 | NativeLibrary.notifyOrientationChange( | ||
| 153 | EmulationMenuSettings.landscapeScreenLayout, | ||
| 154 | getAdjustedRotation() | ||
| 155 | ) | ||
| 156 | } | 146 | } |
| 157 | 147 | ||
| 158 | override fun onPause() { | 148 | override fun onPause() { |
| @@ -258,24 +248,6 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { | |||
| 258 | 248 | ||
| 259 | override fun onAccuracyChanged(sensor: Sensor, i: Int) {} | 249 | override fun onAccuracyChanged(sensor: Sensor, i: Int) {} |
| 260 | 250 | ||
| 261 | private fun getAdjustedRotation():Int { | ||
| 262 | val rotation = getSystemService<DisplayManager>()!!.getDisplay(Display.DEFAULT_DISPLAY).rotation | ||
| 263 | val config: Configuration = resources.configuration | ||
| 264 | |||
| 265 | if ((config.screenLayout and Configuration.SCREENLAYOUT_LONG_YES) != 0 || | ||
| 266 | (config.screenLayout and Configuration.SCREENLAYOUT_LONG_NO) == 0 || | ||
| 267 | (config.screenLayout and Configuration.SCREENLAYOUT_SIZE_SMALL) != 0) { | ||
| 268 | return rotation | ||
| 269 | } | ||
| 270 | when (rotation) { | ||
| 271 | Surface.ROTATION_0 -> return Surface.ROTATION_90 | ||
| 272 | Surface.ROTATION_90 -> return Surface.ROTATION_0 | ||
| 273 | Surface.ROTATION_180 -> return Surface.ROTATION_270 | ||
| 274 | Surface.ROTATION_270 -> return Surface.ROTATION_180 | ||
| 275 | } | ||
| 276 | return rotation | ||
| 277 | } | ||
| 278 | |||
| 279 | private fun restoreState(savedInstanceState: Bundle) { | 251 | private fun restoreState(savedInstanceState: Bundle) { |
| 280 | game = savedInstanceState.parcelable(EXTRA_SELECTED_GAME)!! | 252 | game = savedInstanceState.parcelable(EXTRA_SELECTED_GAME)!! |
| 281 | } | 253 | } |
diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 03cb0b74b..7ebed5e6a 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp | |||
| @@ -94,14 +94,6 @@ public: | |||
| 94 | m_native_window = native_window; | 94 | m_native_window = native_window; |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | u32 ScreenRotation() const { | ||
| 98 | return m_screen_rotation; | ||
| 99 | } | ||
| 100 | |||
| 101 | void SetScreenRotation(u32 screen_rotation) { | ||
| 102 | m_screen_rotation = screen_rotation; | ||
| 103 | } | ||
| 104 | |||
| 105 | void InitializeGpuDriver(const std::string& hook_lib_dir, const std::string& custom_driver_dir, | 97 | void InitializeGpuDriver(const std::string& hook_lib_dir, const std::string& custom_driver_dir, |
| 106 | const std::string& custom_driver_name, | 98 | const std::string& custom_driver_name, |
| 107 | const std::string& file_redirect_dir) { | 99 | const std::string& file_redirect_dir) { |
| @@ -400,7 +392,6 @@ private: | |||
| 400 | // Window management | 392 | // Window management |
| 401 | std::unique_ptr<EmuWindow_Android> m_window; | 393 | std::unique_ptr<EmuWindow_Android> m_window; |
| 402 | ANativeWindow* m_native_window{}; | 394 | ANativeWindow* m_native_window{}; |
| 403 | u32 m_screen_rotation{}; | ||
| 404 | 395 | ||
| 405 | // Core emulation | 396 | // Core emulation |
| 406 | Core::System m_system; | 397 | Core::System m_system; |
| @@ -426,10 +417,6 @@ private: | |||
| 426 | 417 | ||
| 427 | } // Anonymous namespace | 418 | } // Anonymous namespace |
| 428 | 419 | ||
| 429 | u32 GetAndroidScreenRotation() { | ||
| 430 | return EmulationSession::GetInstance().ScreenRotation(); | ||
| 431 | } | ||
| 432 | |||
| 433 | static Core::SystemResultStatus RunEmulation(const std::string& filepath) { | 420 | static Core::SystemResultStatus RunEmulation(const std::string& filepath) { |
| 434 | Common::Log::Initialize(); | 421 | Common::Log::Initialize(); |
| 435 | Common::Log::SetColorConsoleBackendEnabled(true); | 422 | Common::Log::SetColorConsoleBackendEnabled(true); |
| @@ -473,13 +460,6 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_surfaceDestroyed(JNIEnv* env, | |||
| 473 | EmulationSession::GetInstance().SurfaceChanged(); | 460 | EmulationSession::GetInstance().SurfaceChanged(); |
| 474 | } | 461 | } |
| 475 | 462 | ||
| 476 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_notifyOrientationChange(JNIEnv* env, | ||
| 477 | [[maybe_unused]] jclass clazz, | ||
| 478 | jint layout_option, | ||
| 479 | jint rotation) { | ||
| 480 | return EmulationSession::GetInstance().SetScreenRotation(static_cast<u32>(rotation)); | ||
| 481 | } | ||
| 482 | |||
| 483 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_setAppDirectory(JNIEnv* env, | 463 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_setAppDirectory(JNIEnv* env, |
| 484 | [[maybe_unused]] jclass clazz, | 464 | [[maybe_unused]] jclass clazz, |
| 485 | jstring j_directory) { | 465 | jstring j_directory) { |
diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.cpp b/src/video_core/renderer_vulkan/vk_blit_screen.cpp index aa8e54bdc..acb143fc7 100644 --- a/src/video_core/renderer_vulkan/vk_blit_screen.cpp +++ b/src/video_core/renderer_vulkan/vk_blit_screen.cpp | |||
| @@ -37,10 +37,6 @@ | |||
| 37 | #include "video_core/vulkan_common/vulkan_memory_allocator.h" | 37 | #include "video_core/vulkan_common/vulkan_memory_allocator.h" |
| 38 | #include "video_core/vulkan_common/vulkan_wrapper.h" | 38 | #include "video_core/vulkan_common/vulkan_wrapper.h" |
| 39 | 39 | ||
| 40 | #ifdef ANDROID | ||
| 41 | extern u32 GetAndroidScreenRotation(); | ||
| 42 | #endif | ||
| 43 | |||
| 44 | namespace Vulkan { | 40 | namespace Vulkan { |
| 45 | 41 | ||
| 46 | namespace { | 42 | namespace { |
| @@ -78,47 +74,6 @@ struct ScreenRectVertex { | |||
| 78 | } | 74 | } |
| 79 | }; | 75 | }; |
| 80 | 76 | ||
| 81 | #ifdef ANDROID | ||
| 82 | |||
| 83 | std::array<f32, 4 * 4> MakeOrthographicMatrix(f32 width, f32 height) { | ||
| 84 | constexpr u32 ROTATION_0 = 0; | ||
| 85 | constexpr u32 ROTATION_90 = 1; | ||
| 86 | constexpr u32 ROTATION_180 = 2; | ||
| 87 | constexpr u32 ROTATION_270 = 3; | ||
| 88 | |||
| 89 | // clang-format off | ||
| 90 | switch (GetAndroidScreenRotation()) { | ||
| 91 | case ROTATION_0: | ||
| 92 | // Desktop | ||
| 93 | return { 2.f / width, 0.f, 0.f, 0.f, | ||
| 94 | 0.f, 2.f / height, 0.f, 0.f, | ||
| 95 | 0.f, 0.f, 1.f, 0.f, | ||
| 96 | -1.f, -1.f, 0.f, 1.f}; | ||
| 97 | case ROTATION_180: | ||
| 98 | // Reverse desktop | ||
| 99 | return {-2.f / width, 0.f, 0.f, 0.f, | ||
| 100 | 0.f, -2.f / height, 0.f, 0.f, | ||
| 101 | 0.f, 0.f, 1.f, 0.f, | ||
| 102 | 1.f, 1.f, 0.f, 1.f}; | ||
| 103 | case ROTATION_270: | ||
| 104 | // Reverse landscape | ||
| 105 | return { 0.f, -2.f / width, 0.f, 0.f, | ||
| 106 | 2.f / height, 0.f, 0.f, 0.f, | ||
| 107 | 0.f, 0.f, 1.f, 0.f, | ||
| 108 | -1.f, 1.f, 0.f, 1.f}; | ||
| 109 | case ROTATION_90: | ||
| 110 | default: | ||
| 111 | // Landscape | ||
| 112 | return { 0.f, 2.f / width, 0.f, 0.f, | ||
| 113 | -2.f / height, 0.f, 0.f, 0.f, | ||
| 114 | 0.f, 0.f, 1.f, 0.f, | ||
| 115 | 1.f, -1.f, 0.f, 1.f}; | ||
| 116 | } | ||
| 117 | // clang-format on | ||
| 118 | } | ||
| 119 | |||
| 120 | #else | ||
| 121 | |||
| 122 | std::array<f32, 4 * 4> MakeOrthographicMatrix(f32 width, f32 height) { | 77 | std::array<f32, 4 * 4> MakeOrthographicMatrix(f32 width, f32 height) { |
| 123 | // clang-format off | 78 | // clang-format off |
| 124 | return { 2.f / width, 0.f, 0.f, 0.f, | 79 | return { 2.f / width, 0.f, 0.f, 0.f, |
| @@ -128,8 +83,6 @@ std::array<f32, 4 * 4> MakeOrthographicMatrix(f32 width, f32 height) { | |||
| 128 | // clang-format on | 83 | // clang-format on |
| 129 | } | 84 | } |
| 130 | 85 | ||
| 131 | #endif | ||
| 132 | |||
| 133 | u32 GetBytesPerPixel(const Tegra::FramebufferConfig& framebuffer) { | 86 | u32 GetBytesPerPixel(const Tegra::FramebufferConfig& framebuffer) { |
| 134 | using namespace VideoCore::Surface; | 87 | using namespace VideoCore::Surface; |
| 135 | return BytesPerBlock(PixelFormatFromGPUPixelFormat(framebuffer.pixel_format)); | 88 | return BytesPerBlock(PixelFormatFromGPUPixelFormat(framebuffer.pixel_format)); |
diff --git a/src/video_core/renderer_vulkan/vk_swapchain.cpp b/src/video_core/renderer_vulkan/vk_swapchain.cpp index afcf34fba..d3cddac69 100644 --- a/src/video_core/renderer_vulkan/vk_swapchain.cpp +++ b/src/video_core/renderer_vulkan/vk_swapchain.cpp | |||
| @@ -231,7 +231,12 @@ void Swapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities, bo | |||
| 231 | .imageSharingMode = VK_SHARING_MODE_EXCLUSIVE, | 231 | .imageSharingMode = VK_SHARING_MODE_EXCLUSIVE, |
| 232 | .queueFamilyIndexCount = 0, | 232 | .queueFamilyIndexCount = 0, |
| 233 | .pQueueFamilyIndices = nullptr, | 233 | .pQueueFamilyIndices = nullptr, |
| 234 | #ifdef ANDROID | ||
| 235 | // On Android, do not allow surface rotation to deviate from the frontend. | ||
| 236 | .preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR, | ||
| 237 | #else | ||
| 234 | .preTransform = capabilities.currentTransform, | 238 | .preTransform = capabilities.currentTransform, |
| 239 | #endif | ||
| 235 | .compositeAlpha = alpha_flags, | 240 | .compositeAlpha = alpha_flags, |
| 236 | .presentMode = present_mode, | 241 | .presentMode = present_mode, |
| 237 | .clipped = VK_FALSE, | 242 | .clipped = VK_FALSE, |