mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2025-01-09 16:29:25 +01:00
Refactored layout code in preparation for Android custom layout GUI
This commit is contained in:
parent
c5ac6e84da
commit
7e5b83f126
@ -158,8 +158,9 @@ object NativeLibrary {
|
||||
/**
|
||||
* Notifies the core emulation that the orientation has changed.
|
||||
*/
|
||||
external fun notifyOrientationChange(layoutOption: Int, rotation: Int)
|
||||
external fun notifyOrientationChange(layoutOption: Int, rotation: Int, isPortrait: Boolean)
|
||||
|
||||
external fun notifyPortraitLayoutChange(layoutOption: Int, rotation: Int, isPortrait: Boolean)
|
||||
/**
|
||||
* Swaps the top and bottom screens.
|
||||
*/
|
||||
@ -266,6 +267,10 @@ object NativeLibrary {
|
||||
@JvmStatic
|
||||
fun landscapeScreenLayout(): Int = EmulationMenuSettings.landscapeScreenLayout
|
||||
|
||||
@Keep
|
||||
@JvmStatic
|
||||
fun portraitScreenLayout(): Int = EmulationMenuSettings.portraitScreenLayout
|
||||
|
||||
@Keep
|
||||
@JvmStatic
|
||||
fun displayAlertMsg(title: String, message: String, yesNo: Boolean): Boolean {
|
||||
|
@ -0,0 +1,17 @@
|
||||
// Copyright 2023 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
package io.github.lime3ds.android.display
|
||||
|
||||
enum class PortraitScreenLayout(val int: Int) {
|
||||
// These must match what is defined in src/common/settings.h
|
||||
TOP_FULL_WIDTH(0),
|
||||
CUSTOM_PORTRAIT_LAYOUT(1);
|
||||
|
||||
companion object {
|
||||
fun from(int: Int): PortraitScreenLayout {
|
||||
return entries.firstOrNull { it.int == int } ?: TOP_FULL_WIDTH;
|
||||
}
|
||||
}
|
||||
}
|
@ -12,8 +12,10 @@ import io.github.lime3ds.android.features.settings.model.Settings
|
||||
import io.github.lime3ds.android.features.settings.utils.SettingsFile
|
||||
import io.github.lime3ds.android.utils.EmulationMenuSettings
|
||||
|
||||
class ScreenAdjustmentUtil(private val windowManager: WindowManager,
|
||||
private val settings: Settings) {
|
||||
class ScreenAdjustmentUtil(
|
||||
private val windowManager: WindowManager,
|
||||
private val settings: Settings
|
||||
) {
|
||||
fun swapScreen() {
|
||||
val isEnabled = !EmulationMenuSettings.swapScreens
|
||||
EmulationMenuSettings.swapScreens = isEnabled
|
||||
@ -25,18 +27,39 @@ class ScreenAdjustmentUtil(private val windowManager: WindowManager,
|
||||
settings.saveSetting(BooleanSetting.SWAP_SCREEN, SettingsFile.FILE_NAME_CONFIG)
|
||||
}
|
||||
|
||||
// TODO: Consider how cycling should handle custom layout
|
||||
// right now it simply skips it
|
||||
fun cycleLayouts() {
|
||||
val nextLayout = (EmulationMenuSettings.landscapeScreenLayout + 1) % ScreenLayout.entries.size
|
||||
changeScreenOrientation(ScreenLayout.from(nextLayout))
|
||||
val nextLayout = if (NativeLibrary.isPortraitMode) {
|
||||
(EmulationMenuSettings.portraitScreenLayout + 1) % (PortraitScreenLayout.entries.size - 1)
|
||||
} else {
|
||||
(EmulationMenuSettings.landscapeScreenLayout + 1) % (ScreenLayout.entries.size - 1)
|
||||
}
|
||||
settings.loadSettings()
|
||||
|
||||
changeScreenOrientation(nextLayout)
|
||||
}
|
||||
|
||||
fun changeScreenOrientation(layoutOption: ScreenLayout) {
|
||||
EmulationMenuSettings.landscapeScreenLayout = layoutOption.int
|
||||
fun changePortraitOrientation(layoutOption: Int) {
|
||||
EmulationMenuSettings.portraitScreenLayout = layoutOption
|
||||
NativeLibrary.notifyPortraitLayoutChange(
|
||||
EmulationMenuSettings.portraitScreenLayout,
|
||||
windowManager.defaultDisplay.rotation,
|
||||
NativeLibrary::isPortraitMode.get()
|
||||
)
|
||||
IntSetting.PORTRAIT_SCREEN_LAYOUT.int = layoutOption
|
||||
settings.saveSetting(IntSetting.PORTRAIT_SCREEN_LAYOUT, SettingsFile.FILE_NAME_CONFIG)
|
||||
}
|
||||
|
||||
fun changeScreenOrientation(layoutOption: Int) {
|
||||
EmulationMenuSettings.landscapeScreenLayout = layoutOption
|
||||
NativeLibrary.notifyOrientationChange(
|
||||
EmulationMenuSettings.landscapeScreenLayout,
|
||||
windowManager.defaultDisplay.rotation
|
||||
windowManager.defaultDisplay.rotation,
|
||||
NativeLibrary::isPortraitMode.get()
|
||||
)
|
||||
IntSetting.SCREEN_LAYOUT.int = layoutOption.int
|
||||
IntSetting.SCREEN_LAYOUT.int = layoutOption
|
||||
settings.saveSetting(IntSetting.SCREEN_LAYOUT, SettingsFile.FILE_NAME_CONFIG)
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -6,17 +6,18 @@ package io.github.lime3ds.android.display
|
||||
|
||||
enum class ScreenLayout(val int: Int) {
|
||||
// These must match what is defined in src/common/settings.h
|
||||
DEFAULT(0),
|
||||
TOP_BOTTOM(0),
|
||||
SINGLE_SCREEN(1),
|
||||
LARGE_SCREEN(2),
|
||||
SIDE_SCREEN(3),
|
||||
HYBRID_SCREEN(4),
|
||||
MOBILE_PORTRAIT(5),
|
||||
CUSTOM_LAYOUT(5),
|
||||
MOBILE_LANDSCAPE(6);
|
||||
|
||||
|
||||
companion object {
|
||||
fun from(int: Int): ScreenLayout {
|
||||
return entries.firstOrNull { it.int == int } ?: DEFAULT
|
||||
return entries.firstOrNull { it.int == int } ?: MOBILE_LANDSCAPE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ enum class BooleanSetting(
|
||||
PLUGIN_LOADER("plugin_loader", Settings.SECTION_SYSTEM, false),
|
||||
ALLOW_PLUGIN_LOADER("allow_plugin_loader", Settings.SECTION_SYSTEM, true),
|
||||
SWAP_SCREEN("swap_screen", Settings.SECTION_LAYOUT, false),
|
||||
CUSTOM_LAYOUT("custom_layout",Settings.SECTION_LAYOUT,false),
|
||||
ADRENO_GPU_BOOST("adreno_gpu_boost", Settings.SECTION_RENDERER, false);
|
||||
|
||||
override var boolean: Boolean = defaultValue
|
||||
|
@ -23,6 +23,7 @@ enum class IntSetting(
|
||||
CARDBOARD_X_SHIFT("cardboard_x_shift", Settings.SECTION_LAYOUT, 0),
|
||||
CARDBOARD_Y_SHIFT("cardboard_y_shift", Settings.SECTION_LAYOUT, 0),
|
||||
SCREEN_LAYOUT("layout_option", Settings.SECTION_LAYOUT, 0),
|
||||
PORTRAIT_SCREEN_LAYOUT("portrait_layout_option",Settings.SECTION_LAYOUT,0),
|
||||
AUDIO_INPUT_TYPE("output_type", Settings.SECTION_AUDIO, 0),
|
||||
NEW_3DS("is_new_3ds", Settings.SECTION_SYSTEM, 1),
|
||||
LLE_APPLETS("lle_applets", Settings.SECTION_SYSTEM, 0),
|
||||
|
@ -131,7 +131,6 @@ class Settings {
|
||||
const val KEY_CSTICK_AXIS_HORIZONTAL = "cstick_axis_horizontal"
|
||||
const val KEY_DPAD_AXIS_VERTICAL = "dpad_axis_vertical"
|
||||
const val KEY_DPAD_AXIS_HORIZONTAL = "dpad_axis_horizontal"
|
||||
|
||||
const val HOTKEY_SCREEN_SWAP = "hotkey_screen_swap"
|
||||
const val HOTKEY_CYCLE_LAYOUT = "hotkey_toggle_layout"
|
||||
const val HOTKEY_CLOSE_GAME = "hotkey_close_game"
|
||||
|
@ -51,6 +51,7 @@ import io.github.lime3ds.android.activities.EmulationActivity
|
||||
import io.github.lime3ds.android.databinding.DialogCheckboxBinding
|
||||
import io.github.lime3ds.android.databinding.DialogSliderBinding
|
||||
import io.github.lime3ds.android.databinding.FragmentEmulationBinding
|
||||
import io.github.lime3ds.android.display.PortraitScreenLayout
|
||||
import io.github.lime3ds.android.display.ScreenAdjustmentUtil
|
||||
import io.github.lime3ds.android.display.ScreenLayout
|
||||
import io.github.lime3ds.android.features.settings.model.SettingsViewModel
|
||||
@ -142,7 +143,8 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram
|
||||
retainInstance = true
|
||||
emulationState = EmulationState(game.path)
|
||||
emulationActivity = requireActivity() as EmulationActivity
|
||||
screenAdjustmentUtil = ScreenAdjustmentUtil(emulationActivity.windowManager, settingsViewModel.settings)
|
||||
screenAdjustmentUtil =
|
||||
ScreenAdjustmentUtil(emulationActivity.windowManager, settingsViewModel.settings)
|
||||
EmulationLifecycleUtil.addShutdownHook(hook = { emulationState.stop() })
|
||||
EmulationLifecycleUtil.addPauseResumeHook(hook = { togglePause() })
|
||||
}
|
||||
@ -207,12 +209,14 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram
|
||||
}
|
||||
})
|
||||
binding.inGameMenu.menu.findItem(R.id.menu_lock_drawer).apply {
|
||||
val titleId = if (EmulationMenuSettings.drawerLockMode == DrawerLayout.LOCK_MODE_LOCKED_CLOSED) {
|
||||
val titleId =
|
||||
if (EmulationMenuSettings.drawerLockMode == DrawerLayout.LOCK_MODE_LOCKED_CLOSED) {
|
||||
R.string.unlock_drawer
|
||||
} else {
|
||||
R.string.lock_drawer
|
||||
}
|
||||
val iconId = if (EmulationMenuSettings.drawerLockMode == DrawerLayout.LOCK_MODE_UNLOCKED) {
|
||||
val iconId =
|
||||
if (EmulationMenuSettings.drawerLockMode == DrawerLayout.LOCK_MODE_UNLOCKED) {
|
||||
R.drawable.ic_unlocked
|
||||
} else {
|
||||
R.drawable.ic_lock
|
||||
@ -267,7 +271,12 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram
|
||||
}
|
||||
|
||||
R.id.menu_landscape_screen_layout -> {
|
||||
showScreenLayoutMenu()
|
||||
showLandscapeScreenLayoutMenu()
|
||||
true
|
||||
}
|
||||
|
||||
R.id.menu_portrait_screen_layout -> {
|
||||
showPortraitScreenLayoutMenu()
|
||||
true
|
||||
}
|
||||
|
||||
@ -769,7 +778,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram
|
||||
popupMenu.show()
|
||||
}
|
||||
|
||||
private fun showScreenLayoutMenu() {
|
||||
private fun showLandscapeScreenLayoutMenu() {
|
||||
val popupMenu = PopupMenu(
|
||||
requireContext(),
|
||||
binding.inGameMenu.findViewById(R.id.menu_landscape_screen_layout)
|
||||
@ -784,12 +793,12 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram
|
||||
ScreenLayout.SIDE_SCREEN.int ->
|
||||
R.id.menu_screen_layout_sidebyside
|
||||
|
||||
ScreenLayout.MOBILE_PORTRAIT.int ->
|
||||
R.id.menu_screen_layout_portrait
|
||||
|
||||
ScreenLayout.HYBRID_SCREEN.int ->
|
||||
R.id.menu_screen_layout_hybrid
|
||||
|
||||
ScreenLayout.CUSTOM_LAYOUT.int ->
|
||||
R.id.menu_screen_layout_custom
|
||||
|
||||
else -> R.id.menu_screen_layout_landscape
|
||||
}
|
||||
popupMenu.menu.findItem(layoutOptionMenuItem).setChecked(true)
|
||||
@ -797,27 +806,68 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram
|
||||
popupMenu.setOnMenuItemClickListener {
|
||||
when (it.itemId) {
|
||||
R.id.menu_screen_layout_landscape -> {
|
||||
screenAdjustmentUtil.changeScreenOrientation(ScreenLayout.MOBILE_LANDSCAPE)
|
||||
true
|
||||
}
|
||||
|
||||
R.id.menu_screen_layout_portrait -> {
|
||||
screenAdjustmentUtil.changeScreenOrientation(ScreenLayout.MOBILE_PORTRAIT)
|
||||
screenAdjustmentUtil.changeScreenOrientation(ScreenLayout.MOBILE_LANDSCAPE.int)
|
||||
true
|
||||
}
|
||||
|
||||
R.id.menu_screen_layout_single -> {
|
||||
screenAdjustmentUtil.changeScreenOrientation(ScreenLayout.SINGLE_SCREEN)
|
||||
screenAdjustmentUtil.changeScreenOrientation(ScreenLayout.SINGLE_SCREEN.int)
|
||||
true
|
||||
}
|
||||
|
||||
R.id.menu_screen_layout_sidebyside -> {
|
||||
screenAdjustmentUtil.changeScreenOrientation(ScreenLayout.SIDE_SCREEN)
|
||||
screenAdjustmentUtil.changeScreenOrientation(ScreenLayout.SIDE_SCREEN.int)
|
||||
true
|
||||
}
|
||||
|
||||
R.id.menu_screen_layout_hybrid -> {
|
||||
screenAdjustmentUtil.changeScreenOrientation(ScreenLayout.HYBRID_SCREEN)
|
||||
screenAdjustmentUtil.changeScreenOrientation(ScreenLayout.HYBRID_SCREEN.int)
|
||||
true
|
||||
}
|
||||
|
||||
R.id.menu_screen_layout_custom -> {
|
||||
screenAdjustmentUtil.changeScreenOrientation(ScreenLayout.CUSTOM_LAYOUT.int)
|
||||
true
|
||||
}
|
||||
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
|
||||
popupMenu.show()
|
||||
}
|
||||
|
||||
private fun showPortraitScreenLayoutMenu() {
|
||||
val popupMenu = PopupMenu(
|
||||
requireContext(),
|
||||
binding.inGameMenu.findViewById(R.id.menu_portrait_screen_layout)
|
||||
)
|
||||
|
||||
popupMenu.menuInflater.inflate(R.menu.menu_portrait_screen_layout, popupMenu.menu)
|
||||
|
||||
val layoutOptionMenuItem = when (EmulationMenuSettings.portraitScreenLayout) {
|
||||
PortraitScreenLayout.TOP_FULL_WIDTH.int ->
|
||||
R.id.menu_portrait_layout_top_full
|
||||
|
||||
PortraitScreenLayout.CUSTOM_PORTRAIT_LAYOUT.int ->
|
||||
R.id.menu_portrait_layout_custom
|
||||
|
||||
else ->
|
||||
R.id.menu_portrait_layout_top_full
|
||||
|
||||
}
|
||||
|
||||
popupMenu.menu.findItem(layoutOptionMenuItem).setChecked(true)
|
||||
|
||||
popupMenu.setOnMenuItemClickListener {
|
||||
when (it.itemId) {
|
||||
R.id.menu_portrait_layout_top_full -> {
|
||||
screenAdjustmentUtil.changePortraitOrientation(PortraitScreenLayout.TOP_FULL_WIDTH.int)
|
||||
true
|
||||
}
|
||||
|
||||
R.id.menu_portrait_layout_custom -> {
|
||||
screenAdjustmentUtil.changePortraitOrientation(PortraitScreenLayout.CUSTOM_PORTRAIT_LAYOUT.int)
|
||||
true
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ package io.github.lime3ds.android.utils
|
||||
import androidx.drawerlayout.widget.DrawerLayout
|
||||
import androidx.preference.PreferenceManager
|
||||
import io.github.lime3ds.android.LimeApplication
|
||||
import io.github.lime3ds.android.display.PortraitScreenLayout
|
||||
import io.github.lime3ds.android.display.ScreenLayout
|
||||
|
||||
object EmulationMenuSettings {
|
||||
@ -30,13 +31,23 @@ object EmulationMenuSettings {
|
||||
var landscapeScreenLayout: Int
|
||||
get() = preferences.getInt(
|
||||
"EmulationMenuSettings_LandscapeScreenLayout",
|
||||
ScreenLayout.MOBILE_LANDSCAPE.int
|
||||
ScreenLayout.LARGE_SCREEN.int
|
||||
)
|
||||
set(value) {
|
||||
preferences.edit()
|
||||
.putInt("EmulationMenuSettings_LandscapeScreenLayout", value)
|
||||
.apply()
|
||||
}
|
||||
var portraitScreenLayout: Int
|
||||
get() = preferences.getInt(
|
||||
"EmulationMenuSettings_PortraitScreenLayout",
|
||||
PortraitScreenLayout.TOP_FULL_WIDTH.int
|
||||
)
|
||||
set(value) {
|
||||
preferences.edit()
|
||||
.putInt("EmulationMenuSettings_PortraitScreenLayout", value)
|
||||
.apply()
|
||||
}
|
||||
var showFps: Boolean
|
||||
get() = preferences.getBoolean("EmulationMenuSettings_ShowFps", false)
|
||||
set(value) {
|
||||
|
@ -174,7 +174,7 @@ void Config::ReadValues() {
|
||||
|
||||
// Layout
|
||||
Settings::values.layout_option = static_cast<Settings::LayoutOption>(sdl2_config->GetInteger(
|
||||
"Layout", "layout_option", static_cast<int>(Settings::LayoutOption::MobileLandscape)));
|
||||
"Layout", "layout_option", static_cast<int>(Settings::LayoutOption::LargeScreen)));
|
||||
ReadSetting("Layout", Settings::values.custom_layout);
|
||||
ReadSetting("Layout", Settings::values.custom_top_x);
|
||||
ReadSetting("Layout", Settings::values.custom_top_y);
|
||||
@ -188,7 +188,10 @@ void Config::ReadValues() {
|
||||
ReadSetting("Layout", Settings::values.cardboard_x_shift);
|
||||
ReadSetting("Layout", Settings::values.cardboard_y_shift);
|
||||
|
||||
ReadSetting("Layout", Settings::values.custom_portrait_layout);
|
||||
Settings::values.portrait_layout_option =
|
||||
static_cast<Settings::PortraitLayoutOption>(sdl2_config->GetInteger(
|
||||
"Layout", "portrait_layout_option",
|
||||
static_cast<int>(Settings::PortraitLayoutOption::PortraitTopFullWidth)));
|
||||
ReadSetting("Layout", Settings::values.custom_portrait_top_x);
|
||||
ReadSetting("Layout", Settings::values.custom_portrait_top_y);
|
||||
ReadSetting("Layout", Settings::values.custom_portrait_top_width);
|
||||
|
@ -179,15 +179,15 @@ anaglyph_shader_name =
|
||||
filter_mode =
|
||||
|
||||
[Layout]
|
||||
# Layout for the screen inside the render window.
|
||||
# 0 (default): Default Top Bottom Screen, 1: Single Screen Only, 2: Large Screen Small Screen, 3: Side by Side
|
||||
# Layout for the screen inside the render window, landscape mode
|
||||
# 0 (default): Default Top Bottom Screen,
|
||||
# 1: Single Screen Only,
|
||||
# 2: Large Screen Small Screen
|
||||
# 3: Side by Side
|
||||
# 4: Hybrid
|
||||
# 5: Custom Layout
|
||||
layout_option =
|
||||
|
||||
# Toggle custom layout (using the settings below) on or off.
|
||||
# Only applies to landscape on Android
|
||||
# 0 (default): Off, 1: On
|
||||
custom_layout =
|
||||
|
||||
# Screen placement when using Custom layout option
|
||||
# 0x, 0y is the top left corner of the render window.
|
||||
custom_top_x =
|
||||
@ -199,12 +199,12 @@ custom_bottom_y =
|
||||
custom_bottom_width =
|
||||
custom_bottom_height =
|
||||
|
||||
# Custom Layout Options for Android Portrait Mode
|
||||
# Toggle custom layout (using the settings below) on or off.
|
||||
# 0 (default): Off, 1: On
|
||||
custom_portrait_layout =
|
||||
# Layout for the portrait mode
|
||||
# 0 (default): Top and bottom screens at top, full width
|
||||
# 1: Custom Layout
|
||||
portrait_layout_option =
|
||||
|
||||
# Screen placement when using Custom layout option
|
||||
# Screen placement when using Portrait Custom layout option
|
||||
# 0x, 0y is the top left corner of the render window.
|
||||
custom_portrait_top_x =
|
||||
custom_portrait_top_y =
|
||||
|
@ -27,6 +27,12 @@ static void UpdateLandscapeScreenLayout() {
|
||||
IDCache::GetNativeLibraryClass(), IDCache::GetLandscapeScreenLayout()));
|
||||
}
|
||||
|
||||
static void UpdatePortraitScreenLayout() {
|
||||
Settings::values.portrait_layout_option =
|
||||
static_cast<Settings::PortraitLayoutOption>(IDCache::GetEnvForThread()->CallStaticIntMethod(
|
||||
IDCache::GetNativeLibraryClass(), IDCache::GetPortraitScreenLayout()));
|
||||
}
|
||||
|
||||
bool EmuWindow_Android::OnSurfaceChanged(ANativeWindow* surface) {
|
||||
if (render_window == surface) {
|
||||
return false;
|
||||
@ -58,6 +64,7 @@ void EmuWindow_Android::OnTouchMoved(int x, int y) {
|
||||
|
||||
void EmuWindow_Android::OnFramebufferSizeChanged() {
|
||||
UpdateLandscapeScreenLayout();
|
||||
UpdatePortraitScreenLayout();
|
||||
const bool is_portrait_mode{IsPortraitMode()};
|
||||
|
||||
const int bigger{window_width > window_height ? window_width : window_height};
|
||||
|
@ -27,6 +27,7 @@ static jclass s_native_library_class;
|
||||
static jmethodID s_on_core_error;
|
||||
static jmethodID s_is_portrait_mode;
|
||||
static jmethodID s_landscape_screen_layout;
|
||||
static jmethodID s_portrait_screen_layout;
|
||||
static jmethodID s_exit_emulation_activity;
|
||||
static jmethodID s_request_camera_permission;
|
||||
static jmethodID s_request_mic_permission;
|
||||
@ -90,6 +91,10 @@ jmethodID GetLandscapeScreenLayout() {
|
||||
return s_landscape_screen_layout;
|
||||
}
|
||||
|
||||
jmethodID GetPortraitScreenLayout() {
|
||||
return s_portrait_screen_layout;
|
||||
}
|
||||
|
||||
jmethodID GetExitEmulationActivity() {
|
||||
return s_exit_emulation_activity;
|
||||
}
|
||||
@ -174,6 +179,8 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
s_is_portrait_mode = env->GetStaticMethodID(s_native_library_class, "isPortraitMode", "()Z");
|
||||
s_landscape_screen_layout =
|
||||
env->GetStaticMethodID(s_native_library_class, "landscapeScreenLayout", "()I");
|
||||
s_portrait_screen_layout =
|
||||
env->GetStaticMethodID(s_native_library_class, "portraitScreenLayout", "()I");
|
||||
s_exit_emulation_activity =
|
||||
env->GetStaticMethodID(s_native_library_class, "exitEmulationActivity", "(I)V");
|
||||
s_request_camera_permission =
|
||||
|
@ -27,6 +27,7 @@ jmethodID GetDisplayAlertPrompt();
|
||||
jmethodID GetAlertPromptButton();
|
||||
jmethodID GetIsPortraitMode();
|
||||
jmethodID GetLandscapeScreenLayout();
|
||||
jmethodID GetPortraitScreenLayout();
|
||||
jmethodID GetExitEmulationActivity();
|
||||
jmethodID GetRequestCameraPermission();
|
||||
jmethodID GetRequestMicPermission();
|
||||
|
@ -347,9 +347,23 @@ void JNICALL Java_io_github_lime3ds_android_NativeLibrary_enableAdrenoTurboMode(
|
||||
}
|
||||
|
||||
void Java_io_github_lime3ds_android_NativeLibrary_notifyOrientationChange(
|
||||
[[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj, jint layout_option, jint rotation) {
|
||||
[[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj, jint layout_option, jint rotation,
|
||||
jboolean portrait) {
|
||||
Settings::values.layout_option = static_cast<Settings::LayoutOption>(layout_option);
|
||||
auto& system = Core::System::GetInstance();
|
||||
if (system.IsPoweredOn()) {
|
||||
|
||||
system.GPU().Renderer().UpdateCurrentFramebufferLayout(portrait);
|
||||
}
|
||||
InputManager::screen_rotation = rotation;
|
||||
Camera::NDK::g_rotation = rotation;
|
||||
}
|
||||
|
||||
void Java_io_github_lime3ds_android_NativeLibrary_notifyPortraitLayoutChange(
|
||||
[[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj, jint layout_option, jint rotation) {
|
||||
Settings::values.portrait_layout_option =
|
||||
static_cast<Settings::PortraitLayoutOption>(layout_option);
|
||||
auto& system = Core::System::GetInstance();
|
||||
if (system.IsPoweredOn()) {
|
||||
system.GPU().Renderer().UpdateCurrentFramebufferLayout(!(rotation % 2));
|
||||
}
|
||||
|
@ -69,7 +69,7 @@
|
||||
<menu>
|
||||
<group android:checkableBehavior="single">
|
||||
<item
|
||||
android:id="@+id/menu_screen_layout_landscape"
|
||||
android:id="@+id/menu_portrait_layout_top_full"
|
||||
android:title="@string/emulation_screen_layout_landscape" />
|
||||
|
||||
<item
|
||||
|
@ -27,6 +27,11 @@
|
||||
android:icon="@drawable/ic_fit_screen"
|
||||
android:title="@string/emulation_switch_screen_layout" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_portrait_screen_layout"
|
||||
android:icon="@drawable/ic_fit_screen"
|
||||
android:title="@string/emulation_switch_portrait_layout" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_swap_screens"
|
||||
android:icon="@drawable/ic_splitscreen"
|
||||
|
@ -7,10 +7,6 @@
|
||||
android:id="@+id/menu_screen_layout_landscape"
|
||||
android:title="@string/emulation_screen_layout_landscape" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_screen_layout_portrait"
|
||||
android:title="@string/emulation_screen_layout_portrait" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_screen_layout_single"
|
||||
android:title="@string/emulation_screen_layout_single" />
|
||||
@ -23,6 +19,9 @@
|
||||
android:id="@+id/menu_screen_layout_hybrid"
|
||||
android:title="@string/emulation_screen_layout_hybrid" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_screen_layout_custom"
|
||||
android:title="@string/emulation_screen_layout_custom" />
|
||||
</group>
|
||||
|
||||
</menu>
|
||||
|
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<group android:checkableBehavior="single">
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_portrait_layout_top_full"
|
||||
android:title="@string/emulation_portrait_layout_top_full" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_portrait_layout_custom"
|
||||
android:title="@string/emulation_screen_layout_custom" />
|
||||
</group>
|
||||
|
||||
</menu>
|
@ -359,12 +359,15 @@
|
||||
<string name="emulation_open_settings">Open Settings</string>
|
||||
<string name="emulation_open_cheats">Open Cheats</string>
|
||||
<string name="emulation_switch_screen_layout">Landscape Screen Layout</string>
|
||||
<string name="emulation_switch_portrait_layout">Portrait Screen Layout</string>
|
||||
<string name="emulation_screen_layout_landscape">Default</string>
|
||||
<string name="emulation_screen_layout_portrait">Portrait</string>
|
||||
<string name="emulation_screen_layout_single">Single Screen</string>
|
||||
<string name="emulation_screen_layout_sidebyside">Side by Side Screens</string>
|
||||
<string name="emulation_screen_layout_hybrid">Hybrid Screens</string>
|
||||
<string name="emulation_cycle_landscape_layouts">Cycle Landscape Layouts</string>
|
||||
<string name="emulation_portrait_layout_top_full">Default</string>
|
||||
<string name="emulation_screen_layout_custom">Custom Layout</string>
|
||||
<string name="emulation_cycle_landscape_layouts">Cycle Layouts</string>
|
||||
<string name="emulation_swap_screens">Swap Screens</string>
|
||||
<string name="emulation_touch_overlay_reset">Reset Overlay</string>
|
||||
<string name="emulation_show_overlay">Show Overlay</string>
|
||||
|
@ -108,6 +108,7 @@ void LogSettings() {
|
||||
log_setting("Renderer_AnaglyphShader", values.anaglyph_shader_name.GetValue());
|
||||
}
|
||||
log_setting("Layout_LayoutOption", values.layout_option.GetValue());
|
||||
log_setting("Layout_PortraitLayoutOption", values.portrait_layout_option.GetValue());
|
||||
log_setting("Layout_SwapScreen", values.swap_screen.GetValue());
|
||||
log_setting("Layout_UprightScreen", values.upright_screen.GetValue());
|
||||
log_setting("Layout_LargeScreenProportion", values.large_screen_proportion.GetValue());
|
||||
@ -196,6 +197,7 @@ void RestoreGlobalState(bool is_powered_on) {
|
||||
values.texture_filter.SetGlobal(true);
|
||||
values.texture_sampling.SetGlobal(true);
|
||||
values.layout_option.SetGlobal(true);
|
||||
values.portrait_layout_option.SetGlobal(true);
|
||||
values.swap_screen.SetGlobal(true);
|
||||
values.upright_screen.SetGlobal(true);
|
||||
values.large_screen_proportion.SetGlobal(true);
|
||||
|
@ -33,6 +33,7 @@ enum class InitTicks : u32 {
|
||||
Fixed = 1,
|
||||
};
|
||||
|
||||
/** Defines the layout option for desktop and mobile landscape */
|
||||
enum class LayoutOption : u32 {
|
||||
Default,
|
||||
SingleScreen,
|
||||
@ -42,18 +43,20 @@ enum class LayoutOption : u32 {
|
||||
SeparateWindows,
|
||||
#endif
|
||||
HybridScreen,
|
||||
#ifndef ANDROID // TODO: Implement custom layouts on Android
|
||||
CustomLayout,
|
||||
#endif
|
||||
// Similiar to default, but better for mobile devices in portrait mode. Top screen in clamped to
|
||||
// the top of the frame, and the bottom screen is enlarged to match the top screen.
|
||||
MobilePortrait,
|
||||
|
||||
// Similiar to LargeScreen, but better for mobile devices in landscape mode. The screens are
|
||||
// clamped to the top of the frame, and the bottom screen is a bit bigger.
|
||||
MobileLandscape,
|
||||
};
|
||||
|
||||
/** Defines the layout option for mobile portrait */
|
||||
enum class PortraitLayoutOption : u32 {
|
||||
// formerly mobile portrait
|
||||
PortraitTopFullWidth,
|
||||
PortraitCustomLayout,
|
||||
};
|
||||
|
||||
enum class StereoRenderOption : u32 {
|
||||
Off = 0,
|
||||
SideBySide = 1,
|
||||
@ -482,21 +485,22 @@ struct Values {
|
||||
SwitchableSetting<TextureFilter> texture_filter{TextureFilter::None, "texture_filter"};
|
||||
SwitchableSetting<TextureSampling> texture_sampling{TextureSampling::GameControlled,
|
||||
"texture_sampling"};
|
||||
|
||||
SwitchableSetting<LayoutOption> layout_option{LayoutOption::Default, "layout_option"};
|
||||
SwitchableSetting<bool> swap_screen{false, "swap_screen"};
|
||||
SwitchableSetting<bool> upright_screen{false, "upright_screen"};
|
||||
SwitchableSetting<float, true> large_screen_proportion{4.f, 1.f, 16.f,
|
||||
"large_screen_proportion"};
|
||||
// I think the custom_layout setting below is no longer needed
|
||||
// since custom layout is now just part of the layout option above?
|
||||
Setting<bool> custom_layout{false, "custom_layout"};
|
||||
Setting<u16> custom_top_x{0, "custom_top_x"};
|
||||
Setting<u16> custom_top_y{0, "custom_top_y"};
|
||||
Setting<u16> custom_top_width{400, "custom_top_width"};
|
||||
Setting<u16> custom_top_height{240, "custom_top_height"};
|
||||
Setting<u16> custom_bottom_x{40, "custom_bottom_x"};
|
||||
Setting<u16> custom_bottom_y{240, "custom_bottom_y"};
|
||||
Setting<u16> custom_bottom_width{320, "custom_bottom_width"};
|
||||
Setting<u16> custom_bottom_height{240, "custom_bottom_height"};
|
||||
Setting<u16> custom_top_width{800, "custom_top_width"};
|
||||
Setting<u16> custom_top_height{480, "custom_top_height"};
|
||||
Setting<u16> custom_bottom_x{80, "custom_bottom_x"};
|
||||
Setting<u16> custom_bottom_y{500, "custom_bottom_y"};
|
||||
Setting<u16> custom_bottom_width{640, "custom_bottom_width"};
|
||||
Setting<u16> custom_bottom_height{480, "custom_bottom_height"};
|
||||
Setting<u16> custom_second_layer_opacity{100, "custom_second_layer_opacity"};
|
||||
|
||||
SwitchableSetting<bool> screen_top_stretch{false, "screen_top_stretch"};
|
||||
@ -506,14 +510,15 @@ struct Values {
|
||||
Setting<u16> screen_bottom_leftright_padding{0, "screen_bottom_leftright_padding"};
|
||||
Setting<u16> screen_bottom_topbottom_padding{0, "screen_bottom_topbottom_padding"};
|
||||
|
||||
Setting<bool> custom_portrait_layout{false, "custom_portrait_layout"};
|
||||
SwitchableSetting<PortraitLayoutOption> portrait_layout_option{
|
||||
PortraitLayoutOption::PortraitTopFullWidth, "portrait_layout_option"};
|
||||
Setting<u16> custom_portrait_top_x{0, "custom_portrait_top_x"};
|
||||
Setting<u16> custom_portrait_top_y{0, "custom_portrait_top_y"};
|
||||
Setting<u16> custom_portrait_top_width{400, "custom_portrait_top_width"};
|
||||
Setting<u16> custom_portrait_top_height{240, "custom_portrait_top_height"};
|
||||
Setting<u16> custom_portrait_bottom_x{40, "custom_portrait_bottom_x"};
|
||||
Setting<u16> custom_portrait_bottom_y{240, "custom_portrait_bottom_y"};
|
||||
Setting<u16> custom_portrait_bottom_width{360, "custom_portrait_bottom_width"};
|
||||
Setting<u16> custom_portrait_top_width{800, "custom_portrait_top_width"};
|
||||
Setting<u16> custom_portrait_top_height{480, "custom_portrait_top_height"};
|
||||
Setting<u16> custom_portrait_bottom_x{80, "custom_portrait_bottom_x"};
|
||||
Setting<u16> custom_portrait_bottom_y{500, "custom_portrait_bottom_y"};
|
||||
Setting<u16> custom_portrait_bottom_width{640, "custom_portrait_bottom_width"};
|
||||
Setting<u16> custom_portrait_bottom_height{480, "custom_portrait_bottom_height"};
|
||||
|
||||
SwitchableSetting<float> bg_red{0.f, "bg_red"};
|
||||
|
@ -176,22 +176,33 @@ void EmuWindow::TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y) {
|
||||
void EmuWindow::UpdateCurrentFramebufferLayout(u32 width, u32 height, bool is_portrait_mode) {
|
||||
Layout::FramebufferLayout layout;
|
||||
|
||||
// If in portrait mode, only the MobilePortrait option really makes sense
|
||||
const Settings::LayoutOption layout_option = is_portrait_mode
|
||||
? Settings::LayoutOption::MobilePortrait
|
||||
: Settings::values.layout_option.GetValue();
|
||||
const auto min_size =
|
||||
Layout::GetMinimumSizeFromLayout(layout_option, Settings::values.upright_screen.GetValue());
|
||||
const Settings::LayoutOption layout_option = Settings::values.layout_option.GetValue();
|
||||
const Settings::PortraitLayoutOption portrait_layout_option =
|
||||
Settings::values.portrait_layout_option.GetValue();
|
||||
const auto min_size = is_portrait_mode
|
||||
? Layout::GetMinimumSizeFromPortraitLayout()
|
||||
: Layout::GetMinimumSizeFromLayout(
|
||||
layout_option, Settings::values.upright_screen.GetValue());
|
||||
|
||||
if ((Settings::values.custom_layout.GetValue() == true && !is_portrait_mode) ||
|
||||
(Settings::values.custom_portrait_layout.GetValue() == true && is_portrait_mode)) {
|
||||
layout = Layout::CustomFrameLayout(width, height, Settings::values.swap_screen.GetValue(),
|
||||
is_portrait_mode);
|
||||
} else {
|
||||
width = std::max(width, min_size.first);
|
||||
height = std::max(height, min_size.second);
|
||||
|
||||
if (is_portrait_mode) {
|
||||
switch (portrait_layout_option) {
|
||||
case Settings::PortraitLayoutOption::PortraitTopFullWidth:
|
||||
layout = Layout::PortraitTopFullFrameLayout(width, height,
|
||||
Settings::values.swap_screen.GetValue());
|
||||
break;
|
||||
case Settings::PortraitLayoutOption::PortraitCustomLayout:
|
||||
layout = Layout::CustomFrameLayout(
|
||||
width, height, Settings::values.swap_screen.GetValue(), is_portrait_mode);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (layout_option) {
|
||||
case Settings::LayoutOption::CustomLayout:
|
||||
layout = Layout::CustomFrameLayout(
|
||||
width, height, Settings::values.swap_screen.GetValue(), is_portrait_mode);
|
||||
break;
|
||||
case Settings::LayoutOption::SingleScreen:
|
||||
layout =
|
||||
Layout::SingleFrameLayout(width, height, Settings::values.swap_screen.GetValue(),
|
||||
@ -221,21 +232,12 @@ void EmuWindow::UpdateCurrentFramebufferLayout(u32 width, u32 height, bool is_po
|
||||
Settings::values.upright_screen.GetValue());
|
||||
break;
|
||||
#endif
|
||||
case Settings::LayoutOption::MobilePortrait:
|
||||
layout = Layout::MobilePortraitFrameLayout(width, height,
|
||||
Settings::values.swap_screen.GetValue());
|
||||
break;
|
||||
case Settings::LayoutOption::MobileLandscape:
|
||||
layout =
|
||||
Layout::LargeFrameLayout(width, height, Settings::values.swap_screen.GetValue(),
|
||||
false, 2.25f, Layout::VerticalAlignment::Top);
|
||||
break;
|
||||
#ifndef ANDROID // TODO: Implement custom layouts on Android
|
||||
case Settings::LayoutOption::CustomLayout:
|
||||
layout =
|
||||
Layout::CustomFrameLayout(width, height, Settings::values.swap_screen.GetValue());
|
||||
break;
|
||||
#endif
|
||||
|
||||
case Settings::LayoutOption::Default:
|
||||
default:
|
||||
layout =
|
||||
@ -243,8 +245,9 @@ void EmuWindow::UpdateCurrentFramebufferLayout(u32 width, u32 height, bool is_po
|
||||
Settings::values.upright_screen.GetValue());
|
||||
break;
|
||||
}
|
||||
UpdateMinimumWindowSize(min_size);
|
||||
}
|
||||
UpdateMinimumWindowSize(min_size);
|
||||
|
||||
if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::CardboardVR) {
|
||||
layout = Layout::GetCardboardSettings(layout);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height, bool swapped, bool u
|
||||
return res;
|
||||
}
|
||||
|
||||
FramebufferLayout MobilePortraitFrameLayout(u32 width, u32 height, bool swapped) {
|
||||
FramebufferLayout PortraitTopFullFrameLayout(u32 width, u32 height, bool swapped) {
|
||||
ASSERT(width > 0);
|
||||
ASSERT(height > 0);
|
||||
|
||||
@ -419,20 +419,13 @@ FramebufferLayout CustomFrameLayout(u32 width, u32 height, bool is_swapped, bool
|
||||
return res;
|
||||
}
|
||||
|
||||
FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale, bool is_secondary) {
|
||||
bool is_portrait_mode =
|
||||
Settings::values.layout_option.GetValue() == Settings::LayoutOption::MobilePortrait;
|
||||
if (Settings::values.custom_layout.GetValue() == true && !is_portrait_mode) {
|
||||
return CustomFrameLayout(std::max(Settings::values.custom_top_x.GetValue() +
|
||||
Settings::values.custom_top_width.GetValue(),
|
||||
Settings::values.custom_bottom_x.GetValue() +
|
||||
Settings::values.custom_bottom_width.GetValue()),
|
||||
std::max(Settings::values.custom_top_y.GetValue() +
|
||||
Settings::values.custom_top_height.GetValue(),
|
||||
Settings::values.custom_bottom_y.GetValue() +
|
||||
Settings::values.custom_bottom_height.GetValue()),
|
||||
Settings::values.swap_screen.GetValue(), is_portrait_mode);
|
||||
} else if (Settings::values.custom_portrait_layout.GetValue() == true && is_portrait_mode) {
|
||||
FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale, bool is_secondary,
|
||||
bool is_portrait) {
|
||||
int width, height;
|
||||
if (is_portrait) {
|
||||
auto layout_option = Settings::values.portrait_layout_option.GetValue();
|
||||
switch (layout_option) {
|
||||
case Settings::PortraitLayoutOption::PortraitCustomLayout:
|
||||
return CustomFrameLayout(
|
||||
std::max(Settings::values.custom_portrait_top_x.GetValue() +
|
||||
Settings::values.custom_portrait_top_width.GetValue(),
|
||||
@ -442,11 +435,27 @@ FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale, bool is_secondar
|
||||
Settings::values.custom_portrait_top_height.GetValue(),
|
||||
Settings::values.custom_portrait_bottom_y.GetValue() +
|
||||
Settings::values.custom_portrait_bottom_height.GetValue()),
|
||||
Settings::values.swap_screen.GetValue(), is_portrait_mode);
|
||||
Settings::values.swap_screen.GetValue(), is_portrait);
|
||||
case Settings::PortraitLayoutOption::PortraitTopFullWidth:
|
||||
width = Core::kScreenTopWidth * res_scale;
|
||||
height = (Core::kScreenTopHeight + Core::kScreenBottomHeight) * res_scale;
|
||||
return PortraitTopFullFrameLayout(width, height,
|
||||
Settings::values.swap_screen.GetValue());
|
||||
}
|
||||
} else {
|
||||
auto layout_option = Settings::values.layout_option.GetValue();
|
||||
switch (layout_option) {
|
||||
case Settings::LayoutOption::CustomLayout:
|
||||
return CustomFrameLayout(std::max(Settings::values.custom_top_x.GetValue() +
|
||||
Settings::values.custom_top_width.GetValue(),
|
||||
Settings::values.custom_bottom_x.GetValue() +
|
||||
Settings::values.custom_bottom_width.GetValue()),
|
||||
std::max(Settings::values.custom_top_y.GetValue() +
|
||||
Settings::values.custom_top_height.GetValue(),
|
||||
Settings::values.custom_bottom_y.GetValue() +
|
||||
Settings::values.custom_bottom_height.GetValue()),
|
||||
Settings::values.swap_screen.GetValue(), is_portrait);
|
||||
|
||||
int width, height;
|
||||
switch (Settings::values.layout_option.GetValue()) {
|
||||
case Settings::LayoutOption::SingleScreen:
|
||||
#ifndef ANDROID
|
||||
case Settings::LayoutOption::SeparateWindows:
|
||||
@ -469,13 +478,15 @@ FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale, bool is_secondar
|
||||
|
||||
case Settings::LayoutOption::LargeScreen:
|
||||
if (Settings::values.swap_screen.GetValue()) {
|
||||
width = (Core::kScreenBottomWidth +
|
||||
width =
|
||||
(Core::kScreenBottomWidth +
|
||||
Core::kScreenTopWidth /
|
||||
static_cast<int>(Settings::values.large_screen_proportion.GetValue())) *
|
||||
res_scale;
|
||||
height = Core::kScreenBottomHeight * res_scale;
|
||||
} else {
|
||||
width = (Core::kScreenTopWidth +
|
||||
width =
|
||||
(Core::kScreenTopWidth +
|
||||
Core::kScreenBottomWidth /
|
||||
static_cast<int>(Settings::values.large_screen_proportion.GetValue())) *
|
||||
res_scale;
|
||||
@ -500,11 +511,6 @@ FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale, bool is_secondar
|
||||
Settings::values.upright_screen.GetValue(), 1,
|
||||
VerticalAlignment::Middle);
|
||||
|
||||
case Settings::LayoutOption::MobilePortrait:
|
||||
width = Core::kScreenTopWidth * res_scale;
|
||||
height = (Core::kScreenTopHeight + Core::kScreenBottomHeight) * res_scale;
|
||||
return MobilePortraitFrameLayout(width, height, Settings::values.swap_screen.GetValue());
|
||||
|
||||
case Settings::LayoutOption::MobileLandscape: {
|
||||
constexpr float large_screen_proportion = 2.25f;
|
||||
if (Settings::values.swap_screen.GetValue()) {
|
||||
@ -533,6 +539,7 @@ FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale, bool is_secondar
|
||||
return DefaultFrameLayout(width, height, Settings::values.swap_screen.GetValue(),
|
||||
Settings::values.upright_screen.GetValue());
|
||||
}
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
@ -554,32 +561,9 @@ FramebufferLayout GetCardboardSettings(const FramebufferLayout& layout) {
|
||||
|
||||
u32 cardboard_screen_width;
|
||||
u32 cardboard_screen_height;
|
||||
switch (Settings::values.layout_option.GetValue()) {
|
||||
case Settings::LayoutOption::MobileLandscape:
|
||||
case Settings::LayoutOption::SideScreen:
|
||||
// If orientation is portrait, only use MobilePortrait
|
||||
if (!is_portrait) {
|
||||
cardboard_screen_width = top_screen_width + bottom_screen_width;
|
||||
cardboard_screen_height = is_swapped ? bottom_screen_height : top_screen_height;
|
||||
if (is_swapped)
|
||||
top_screen_left += bottom_screen_width;
|
||||
else
|
||||
bottom_screen_left += top_screen_width;
|
||||
break;
|
||||
} else {
|
||||
[[fallthrough]];
|
||||
}
|
||||
case Settings::LayoutOption::SingleScreen:
|
||||
default:
|
||||
if (!is_portrait) {
|
||||
// Default values when using LayoutOption::SingleScreen
|
||||
cardboard_screen_width = is_swapped ? bottom_screen_width : top_screen_width;
|
||||
cardboard_screen_height = is_swapped ? bottom_screen_height : top_screen_height;
|
||||
break;
|
||||
} else {
|
||||
[[fallthrough]];
|
||||
}
|
||||
case Settings::LayoutOption::MobilePortrait:
|
||||
if (is_portrait) {
|
||||
switch (Settings::values.portrait_layout_option.GetValue()) {
|
||||
case Settings::PortraitLayoutOption::PortraitTopFullWidth:
|
||||
cardboard_screen_width = top_screen_width;
|
||||
cardboard_screen_height = top_screen_height + bottom_screen_height;
|
||||
bottom_screen_left += (top_screen_width - bottom_screen_width) / 2;
|
||||
@ -588,6 +572,31 @@ FramebufferLayout GetCardboardSettings(const FramebufferLayout& layout) {
|
||||
else
|
||||
bottom_screen_top += top_screen_height;
|
||||
break;
|
||||
default:
|
||||
cardboard_screen_width = is_swapped ? bottom_screen_width : top_screen_width;
|
||||
cardboard_screen_height = is_swapped ? bottom_screen_height : top_screen_height;
|
||||
}
|
||||
} else {
|
||||
switch (Settings::values.layout_option.GetValue()) {
|
||||
case Settings::LayoutOption::MobileLandscape:
|
||||
case Settings::LayoutOption::SideScreen:
|
||||
// If orientation is portrait, only use MobilePortrait
|
||||
|
||||
cardboard_screen_width = top_screen_width + bottom_screen_width;
|
||||
cardboard_screen_height = is_swapped ? bottom_screen_height : top_screen_height;
|
||||
if (is_swapped)
|
||||
top_screen_left += bottom_screen_width;
|
||||
else
|
||||
bottom_screen_left += top_screen_width;
|
||||
break;
|
||||
|
||||
case Settings::LayoutOption::SingleScreen:
|
||||
default:
|
||||
|
||||
cardboard_screen_width = is_swapped ? bottom_screen_width : top_screen_width;
|
||||
cardboard_screen_height = is_swapped ? bottom_screen_height : top_screen_height;
|
||||
break;
|
||||
}
|
||||
}
|
||||
s32 cardboard_max_x_shift = (layout.width / 2 - cardboard_screen_width) / 2;
|
||||
s32 cardboard_user_x_shift =
|
||||
@ -620,6 +629,15 @@ FramebufferLayout GetCardboardSettings(const FramebufferLayout& layout) {
|
||||
|
||||
return new_layout;
|
||||
}
|
||||
/*f
|
||||
* TODO: remove this?
|
||||
*/
|
||||
std::pair<unsigned, unsigned> GetMinimumSizeFromPortraitLayout() {
|
||||
u32 min_width, min_height;
|
||||
min_width = Core::kScreenTopWidth;
|
||||
min_height = Core::kScreenTopHeight + Core::kScreenBottomHeight;
|
||||
return std::make_pair(min_width, min_height);
|
||||
}
|
||||
|
||||
std::pair<unsigned, unsigned> GetMinimumSizeFromLayout(Settings::LayoutOption layout,
|
||||
bool upright_screen) {
|
||||
|
@ -85,13 +85,14 @@ struct FramebufferLayout {
|
||||
FramebufferLayout DefaultFrameLayout(u32 width, u32 height, bool is_swapped, bool upright);
|
||||
|
||||
/**
|
||||
* Factory method for constructing a mobile portrait FramebufferLayout
|
||||
* Factory method for constructing the mobile Full Width Top layout
|
||||
* Two screens at top, full width, no gap between them
|
||||
* @param width Window framebuffer width in pixels
|
||||
* @param height Window framebuffer height in pixels
|
||||
* @param is_swapped if true, the bottom screen will be displayed above the top screen
|
||||
* @return Newly created FramebufferLayout object with mobile portrait screen regions initialized
|
||||
*/
|
||||
FramebufferLayout MobilePortraitFrameLayout(u32 width, u32 height, bool is_swapped);
|
||||
FramebufferLayout PortraitTopFullFrameLayout(u32 width, u32 height, bool is_swapped);
|
||||
|
||||
/**
|
||||
* Factory method for constructing a FramebufferLayout with only the top or bottom screen
|
||||
@ -152,8 +153,10 @@ FramebufferLayout CustomFrameLayout(u32 width, u32 height, bool is_swapped,
|
||||
* Convenience method to get frame layout by resolution scale
|
||||
* Read from the current settings to determine which layout to use.
|
||||
* @param res_scale resolution scale factor
|
||||
* @param is_portrait_mode defaults to false
|
||||
*/
|
||||
FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale, bool is_secondary = false);
|
||||
FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale, bool is_secondary = false,
|
||||
bool is_portrait_mode = false);
|
||||
|
||||
/**
|
||||
* Convenience method for transforming a frame layout when using Cardboard VR
|
||||
@ -165,4 +168,6 @@ FramebufferLayout GetCardboardSettings(const FramebufferLayout& layout);
|
||||
std::pair<unsigned, unsigned> GetMinimumSizeFromLayout(Settings::LayoutOption layout,
|
||||
bool upright_screen);
|
||||
|
||||
std::pair<unsigned, unsigned> GetMinimumSizeFromPortraitLayout();
|
||||
|
||||
} // namespace Layout
|
||||
|
@ -183,7 +183,7 @@ void Config::ReadValues() {
|
||||
ReadSetting("Layout", Settings::values.screen_bottom_leftright_padding);
|
||||
ReadSetting("Layout", Settings::values.screen_bottom_topbottom_padding);
|
||||
|
||||
ReadSetting("Layout", Settings::values.custom_portrait_layout);
|
||||
ReadSetting("Layout", Settings::values.portrait_layout_option);
|
||||
ReadSetting("Layout", Settings::values.custom_portrait_top_x);
|
||||
ReadSetting("Layout", Settings::values.custom_portrait_top_y);
|
||||
ReadSetting("Layout", Settings::values.custom_portrait_top_width);
|
||||
|
@ -538,7 +538,7 @@ void Config::ReadLayoutValues() {
|
||||
ReadBasicSetting(Settings::values.screen_bottom_stretch);
|
||||
ReadBasicSetting(Settings::values.screen_bottom_leftright_padding);
|
||||
ReadBasicSetting(Settings::values.screen_bottom_topbottom_padding);
|
||||
ReadBasicSetting(Settings::values.custom_portrait_layout);
|
||||
ReadBasicSetting(Settings::values.portrait_layout_option);
|
||||
ReadBasicSetting(Settings::values.custom_portrait_top_x);
|
||||
ReadBasicSetting(Settings::values.custom_portrait_top_y);
|
||||
ReadBasicSetting(Settings::values.custom_portrait_top_width);
|
||||
@ -1099,7 +1099,6 @@ void Config::SaveLayoutValues() {
|
||||
WriteBasicSetting(Settings::values.screen_bottom_stretch);
|
||||
WriteBasicSetting(Settings::values.screen_bottom_leftright_padding);
|
||||
WriteBasicSetting(Settings::values.screen_bottom_topbottom_padding);
|
||||
WriteBasicSetting(Settings::values.custom_portrait_layout);
|
||||
WriteBasicSetting(Settings::values.custom_portrait_top_x);
|
||||
WriteBasicSetting(Settings::values.custom_portrait_top_y);
|
||||
WriteBasicSetting(Settings::values.custom_portrait_top_width);
|
||||
|
@ -634,6 +634,10 @@ void RendererOpenGL::DrawSingleScreenStereo(const ScreenInfo& screen_info_l,
|
||||
* Draws the emulated screens to the emulator window.
|
||||
*/
|
||||
void RendererOpenGL::DrawScreens(const Layout::FramebufferLayout& layout, bool flipped) {
|
||||
bool isPortrait = false;
|
||||
#ifdef ANDROID
|
||||
isPortrait = layout.height > layout.width;
|
||||
#endif
|
||||
if (settings.bg_color_update_requested.exchange(false)) {
|
||||
// Update background color before drawing
|
||||
glClearColor(Settings::values.bg_red.GetValue(), Settings::values.bg_green.GetValue(),
|
||||
@ -675,12 +679,12 @@ void RendererOpenGL::DrawScreens(const Layout::FramebufferLayout& layout, bool f
|
||||
if (!Settings::values.swap_screen.GetValue()) {
|
||||
DrawTopScreen(layout, top_screen);
|
||||
glUniform1i(uniform_layer, 0);
|
||||
ApplySecondLayerOpacity();
|
||||
ApplySecondLayerOpacity(isPortrait);
|
||||
DrawBottomScreen(layout, bottom_screen);
|
||||
} else {
|
||||
DrawBottomScreen(layout, bottom_screen);
|
||||
glUniform1i(uniform_layer, 0);
|
||||
ApplySecondLayerOpacity();
|
||||
ApplySecondLayerOpacity(isPortrait);
|
||||
DrawTopScreen(layout, top_screen);
|
||||
}
|
||||
|
||||
@ -692,11 +696,17 @@ void RendererOpenGL::DrawScreens(const Layout::FramebufferLayout& layout, bool f
|
||||
DrawBottomScreen(layout, additional_screen);
|
||||
}
|
||||
}
|
||||
ResetSecondLayerOpacity();
|
||||
ResetSecondLayerOpacity(isPortrait);
|
||||
}
|
||||
|
||||
void RendererOpenGL::ApplySecondLayerOpacity() {
|
||||
#ifndef ANDROID // TODO: Implement custom layouts on Android
|
||||
void RendererOpenGL::ApplySecondLayerOpacity(bool isPortrait) {
|
||||
#ifdef ANDROID
|
||||
// TODO: Allow for second layer opacity in portrait mode android
|
||||
if (isPortrait) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((Settings::values.layout_option.GetValue() == Settings::LayoutOption::CustomLayout ||
|
||||
Settings::values.custom_layout) &&
|
||||
Settings::values.custom_second_layer_opacity.GetValue() < 100) {
|
||||
@ -706,11 +716,16 @@ void RendererOpenGL::ApplySecondLayerOpacity() {
|
||||
state.blend.dst_rgb_func = GL_ONE_MINUS_CONSTANT_ALPHA;
|
||||
state.blend.color.alpha = Settings::values.custom_second_layer_opacity.GetValue() / 100.0f;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void RendererOpenGL::ResetSecondLayerOpacity() {
|
||||
#ifndef ANDROID // TODO: Implement custom layouts on Android
|
||||
void RendererOpenGL::ResetSecondLayerOpacity(bool isPortrait) {
|
||||
#ifdef ANDROID
|
||||
// TODO: Allow for second layer opacity in portrait mode android
|
||||
if (isPortrait) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((Settings::values.layout_option.GetValue() == Settings::LayoutOption::CustomLayout ||
|
||||
Settings::values.custom_layout) &&
|
||||
Settings::values.custom_second_layer_opacity.GetValue() < 100) {
|
||||
@ -720,7 +735,6 @@ void RendererOpenGL::ResetSecondLayerOpacity() {
|
||||
state.blend.dst_a_func = GL_ZERO;
|
||||
state.blend.color.alpha = 0.0f;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void RendererOpenGL::DrawTopScreen(const Layout::FramebufferLayout& layout,
|
||||
|
@ -65,8 +65,8 @@ private:
|
||||
void ConfigureFramebufferTexture(TextureInfo& texture,
|
||||
const Pica::FramebufferConfig& framebuffer);
|
||||
void DrawScreens(const Layout::FramebufferLayout& layout, bool flipped);
|
||||
void ApplySecondLayerOpacity();
|
||||
void ResetSecondLayerOpacity();
|
||||
void ApplySecondLayerOpacity(bool isPortrait = false);
|
||||
void ResetSecondLayerOpacity(bool isPortrait = false);
|
||||
void DrawBottomScreen(const Layout::FramebufferLayout& layout,
|
||||
const Common::Rectangle<u32>& bottom_screen);
|
||||
void DrawTopScreen(const Layout::FramebufferLayout& layout,
|
||||
|
Loading…
x
Reference in New Issue
Block a user