summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt28
-rw-r--r--src/android/app/src/main/jni/native.cpp20
-rw-r--r--src/video_core/renderer_vulkan/vk_blit_screen.cpp47
-rw-r--r--src/video_core/renderer_vulkan/vk_swapchain.cpp5
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
6import android.app.Activity 6import android.app.Activity
7import android.content.Context 7import android.content.Context
8import android.content.Intent 8import android.content.Intent
9import android.content.res.Configuration
10import android.graphics.Rect 9import android.graphics.Rect
11import android.hardware.Sensor 10import android.hardware.Sensor
12import android.hardware.SensorEvent 11import android.hardware.SensorEvent
13import android.hardware.SensorEventListener 12import android.hardware.SensorEventListener
14import android.hardware.SensorManager 13import android.hardware.SensorManager
15import android.hardware.display.DisplayManager
16import android.os.Bundle 14import android.os.Bundle
17import android.view.Display
18import android.view.InputDevice 15import android.view.InputDevice
19import android.view.KeyEvent 16import android.view.KeyEvent
20import android.view.MotionEvent 17import android.view.MotionEvent
@@ -23,7 +20,6 @@ import android.view.View
23import android.view.inputmethod.InputMethodManager 20import android.view.inputmethod.InputMethodManager
24import androidx.activity.viewModels 21import androidx.activity.viewModels
25import androidx.appcompat.app.AppCompatActivity 22import androidx.appcompat.app.AppCompatActivity
26import androidx.core.content.getSystemService
27import androidx.core.view.WindowCompat 23import androidx.core.view.WindowCompat
28import androidx.core.view.WindowInsetsCompat 24import androidx.core.view.WindowInsetsCompat
29import androidx.core.view.WindowInsetsControllerCompat 25import androidx.core.view.WindowInsetsControllerCompat
@@ -39,7 +35,6 @@ import org.yuzu.yuzu_emu.features.settings.model.SettingsViewModel
39import org.yuzu.yuzu_emu.fragments.EmulationFragment 35import org.yuzu.yuzu_emu.fragments.EmulationFragment
40import org.yuzu.yuzu_emu.model.Game 36import org.yuzu.yuzu_emu.model.Game
41import org.yuzu.yuzu_emu.utils.ControllerMappingHelper 37import org.yuzu.yuzu_emu.utils.ControllerMappingHelper
42import org.yuzu.yuzu_emu.utils.EmulationMenuSettings
43import org.yuzu.yuzu_emu.utils.ForegroundService 38import org.yuzu.yuzu_emu.utils.ForegroundService
44import org.yuzu.yuzu_emu.utils.InputHandler 39import org.yuzu.yuzu_emu.utils.InputHandler
45import org.yuzu.yuzu_emu.utils.NfcReader 40import 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
429u32 GetAndroidScreenRotation() {
430 return EmulationSession::GetInstance().ScreenRotation();
431}
432
433static Core::SystemResultStatus RunEmulation(const std::string& filepath) { 420static 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
476void 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
483void Java_org_yuzu_yuzu_1emu_NativeLibrary_setAppDirectory(JNIEnv* env, 463void 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
41extern u32 GetAndroidScreenRotation();
42#endif
43
44namespace Vulkan { 40namespace Vulkan {
45 41
46namespace { 42namespace {
@@ -78,47 +74,6 @@ struct ScreenRectVertex {
78 } 74 }
79}; 75};
80 76
81#ifdef ANDROID
82
83std::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
122std::array<f32, 4 * 4> MakeOrthographicMatrix(f32 width, f32 height) { 77std::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
133u32 GetBytesPerPixel(const Tegra::FramebufferConfig& framebuffer) { 86u32 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,