android: frontend: Add MobileLandscape layout profile for mobile devices.
This commit is contained in:
parent
af61478822
commit
64ba419977
@ -194,6 +194,8 @@ void Java_org_citra_citra_1android_NativeLibrary_CacheClassesAndMethods(JNIEnv*
|
||||
|
||||
void Java_org_citra_citra_1android_NativeLibrary_SwitchScreenLayout(JNIEnv* env, jobject obj) {
|
||||
if (Settings::values.layout_option == Settings::LayoutOption::MobilePortrait) {
|
||||
Settings::values.layout_option = Settings::LayoutOption::MobileLandscape;
|
||||
} else if (Settings::values.layout_option == Settings::LayoutOption::MobileLandscape) {
|
||||
Settings::values.layout_option = Settings::LayoutOption::SingleScreen;
|
||||
} else if (Settings::values.layout_option == Settings::LayoutOption::SingleScreen) {
|
||||
Settings::values.layout_option = Settings::LayoutOption::LargeScreen;
|
||||
|
@ -170,8 +170,11 @@ void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height)
|
||||
Settings::values.upright_screen);
|
||||
break;
|
||||
case Settings::LayoutOption::MobilePortrait:
|
||||
layout =
|
||||
Layout::DefaultFrameLayout(width, height, Settings::values.swap_screen, true, true);
|
||||
layout = Layout::MobilePortraitFrameLayout(width, height, Settings::values.swap_screen);
|
||||
break;
|
||||
case Settings::LayoutOption::MobileLandscape:
|
||||
layout = Layout::MobileLandscapeFrameLayout(width, height, Settings::values.swap_screen,
|
||||
2.25f, false);
|
||||
break;
|
||||
case Settings::LayoutOption::Default:
|
||||
default:
|
||||
|
@ -151,6 +151,48 @@ FramebufferLayout MobilePortraitFrameLayout(u32 width, u32 height, bool swapped)
|
||||
return res;
|
||||
}
|
||||
|
||||
FramebufferLayout MobileLandscapeFrameLayout(u32 width, u32 height, bool swapped,
|
||||
float scale_factor, bool center_vertical) {
|
||||
ASSERT(width > 0);
|
||||
ASSERT(height > 0);
|
||||
|
||||
FramebufferLayout res{width, height, true, true, {}, {}};
|
||||
// Split the window into two parts. Give 4x width to the main screen and 1x width to the small
|
||||
// To do that, find the total emulation box and maximize that based on window size
|
||||
float window_aspect_ratio = static_cast<float>(height) / width;
|
||||
float emulation_aspect_ratio =
|
||||
swapped ? Core::kScreenBottomHeight * scale_factor /
|
||||
(Core::kScreenBottomWidth * scale_factor + Core::kScreenTopWidth)
|
||||
: Core::kScreenTopHeight * scale_factor /
|
||||
(Core::kScreenTopWidth * scale_factor + Core::kScreenBottomWidth);
|
||||
float large_screen_aspect_ratio = swapped ? BOT_SCREEN_ASPECT_RATIO : TOP_SCREEN_ASPECT_RATIO;
|
||||
float small_screen_aspect_ratio = swapped ? TOP_SCREEN_ASPECT_RATIO : BOT_SCREEN_ASPECT_RATIO;
|
||||
|
||||
Common::Rectangle<u32> screen_window_area{0, 0, width, height};
|
||||
Common::Rectangle<u32> total_rect = maxRectangle(screen_window_area, emulation_aspect_ratio);
|
||||
Common::Rectangle<u32> large_screen = maxRectangle(total_rect, large_screen_aspect_ratio);
|
||||
Common::Rectangle<u32> fourth_size_rect = total_rect.Scale(1.f / scale_factor);
|
||||
Common::Rectangle<u32> small_screen = maxRectangle(fourth_size_rect, small_screen_aspect_ratio);
|
||||
|
||||
if (window_aspect_ratio < emulation_aspect_ratio) {
|
||||
large_screen =
|
||||
large_screen.TranslateX((screen_window_area.GetWidth() - total_rect.GetWidth()) / 2);
|
||||
} else if (center_vertical) {
|
||||
large_screen = large_screen.TranslateY((height - total_rect.GetHeight()) / 2);
|
||||
}
|
||||
|
||||
// Shift the small screen to the bottom right corner
|
||||
small_screen = small_screen.TranslateX(large_screen.right);
|
||||
if (center_vertical) {
|
||||
small_screen.TranslateY(large_screen.GetHeight() + large_screen.top -
|
||||
small_screen.GetHeight());
|
||||
}
|
||||
|
||||
res.top_screen = swapped ? small_screen : large_screen;
|
||||
res.bottom_screen = swapped ? large_screen : small_screen;
|
||||
return res;
|
||||
}
|
||||
|
||||
FramebufferLayout SingleFrameLayout(u32 width, u32 height, bool swapped, bool upright) {
|
||||
ASSERT(width > 0);
|
||||
ASSERT(height > 0);
|
||||
@ -385,6 +427,17 @@ FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale) {
|
||||
height = (Core::kScreenTopHeight + Core::kScreenBottomHeight) * res_scale;
|
||||
layout = MobilePortraitFrameLayout(width, height, Settings::values.swap_screen);
|
||||
break;
|
||||
case Settings::LayoutOption::MobileLandscape:
|
||||
if (Settings::values.swap_screen) {
|
||||
width = (Core::kScreenBottomWidth + Core::kScreenTopWidth / 2.25f) * res_scale;
|
||||
height = Core::kScreenBottomHeight * res_scale;
|
||||
} else {
|
||||
width = (Core::kScreenTopWidth + Core::kScreenBottomWidth / 2.25f) * res_scale;
|
||||
height = Core::kScreenTopHeight * res_scale;
|
||||
}
|
||||
layout = MobileLandscapeFrameLayout(width, height, Settings::values.swap_screen, 2.25f,
|
||||
false);
|
||||
break;
|
||||
case Settings::LayoutOption::Default:
|
||||
default:
|
||||
if (Settings::values.upright_screen) {
|
||||
|
@ -44,6 +44,20 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height, bool is_swapped, boo
|
||||
*/
|
||||
FramebufferLayout MobilePortraitFrameLayout(u32 width, u32 height, bool is_swapped);
|
||||
|
||||
/**
|
||||
* Factory method for constructing a Frame with the a 4x size Top screen with a 1x size bottom
|
||||
* screen on the right
|
||||
* This is useful in particular because it matches well with a 1920x1080 resolution monitor
|
||||
* @param width Window framebuffer width in pixels
|
||||
* @param height Window framebuffer height in pixels
|
||||
* @param is_swapped if true, the bottom screen will be the large display
|
||||
* @param scale_factor Scale factor to use for bottom screen with respect to top screen
|
||||
* @param center_vertical When true, centers the top and bottom screens vertically
|
||||
* @return Newly created FramebufferLayout object with default screen regions initialized
|
||||
*/
|
||||
FramebufferLayout MobileLandscapeFrameLayout(u32 width, u32 height, bool is_swapped,
|
||||
float scale_factor, bool center_vertical);
|
||||
|
||||
/**
|
||||
* Factory method for constructing a FramebufferLayout with only the top or bottom screen
|
||||
* @param width Window framebuffer width in pixels
|
||||
|
@ -28,6 +28,10 @@ enum class LayoutOption {
|
||||
// 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,
|
||||
};
|
||||
|
||||
enum class MicInputType {
|
||||
|
Loading…
x
Reference in New Issue
Block a user