Skip to content

Commit

Permalink
Fix Android Build
Browse files Browse the repository at this point in the history
  • Loading branch information
oneup03 committed Mar 19, 2024
1 parent 40b00c9 commit cb3accf
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 18 deletions.
19 changes: 15 additions & 4 deletions src/core/frontend/emu_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,21 @@ bool EmuWindow::IsWithinTouchscreen(const Layout::FramebufferLayout& layout, uns
}

std::tuple<unsigned, unsigned> EmuWindow::ClipToTouchScreen(unsigned new_x, unsigned new_y) const {
bool separate_win = false;
#ifndef ANDROID
separate_win =
(Settings::values.layout_option.GetValue() == Settings::LayoutOption::SeparateWindows);
#endif
if (new_x >= framebuffer_layout.width / 2) {
if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::SideBySide &&
Settings::values.layout_option.GetValue() != Settings::LayoutOption::SeparateWindows)
!separate_win)
new_x -= framebuffer_layout.width / 2;
else if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::CardboardVR)
new_x -=
(framebuffer_layout.width / 2) - (framebuffer_layout.cardboard.user_x_shift * 2);
}
if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::SideBySide &&
Settings::values.layout_option.GetValue() != Settings::LayoutOption::SeparateWindows) {
!separate_win) {
new_x = std::max(new_x, framebuffer_layout.bottom_screen.left / 2);
new_x = std::min(new_x, framebuffer_layout.bottom_screen.right / 2 - 1);
} else {
Expand Down Expand Up @@ -127,17 +132,23 @@ bool EmuWindow::TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y) {
if (!IsWithinTouchscreen(framebuffer_layout, framebuffer_x, framebuffer_y))
return false;

bool separate_win = false;
#ifndef ANDROID
separate_win =
(Settings::values.layout_option.GetValue() == Settings::LayoutOption::SeparateWindows);
#endif

if (framebuffer_x >= framebuffer_layout.width / 2) {
if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::SideBySide &&
Settings::values.layout_option.GetValue() != Settings::LayoutOption::SeparateWindows)
!separate_win)
framebuffer_x -= framebuffer_layout.width / 2;
else if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::CardboardVR)
framebuffer_x -=
(framebuffer_layout.width / 2) - (framebuffer_layout.cardboard.user_x_shift * 2);
}
std::scoped_lock guard(touch_state->mutex);
if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::SideBySide &&
Settings::values.layout_option.GetValue() != Settings::LayoutOption::SeparateWindows) {
!separate_win) {
touch_state->touch_x =
static_cast<float>(framebuffer_x - framebuffer_layout.bottom_screen.left / 2) /
(framebuffer_layout.bottom_screen.right / 2 -
Expand Down
11 changes: 7 additions & 4 deletions src/core/frontend/framebuffer_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,21 @@ FramebufferLayout SingleFrameLayout(u32 width, u32 height, bool swapped, bool up
bot_screen = MaxRectangle(screen_window_area, BOT_SCREEN_ASPECT_RATIO);
emulation_aspect_ratio = (swapped) ? BOT_SCREEN_ASPECT_RATIO : TOP_SCREEN_ASPECT_RATIO;
}
bool separate_win = false;
#ifndef ANDROID
separate_win =
(Settings::values.layout_option.GetValue() == Settings::LayoutOption::SeparateWindows);
#endif
if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::FullSideBySide &&
!(Settings::values.layout_option.GetValue() == Settings::LayoutOption::SeparateWindows &&
swapped)) {
!(separate_win && swapped)) {
emulation_aspect_ratio /= 2;
}

float window_aspect_ratio = static_cast<float>(height) / width;

if (window_aspect_ratio < emulation_aspect_ratio) {
if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::FullSideBySide &&
!(Settings::values.layout_option.GetValue() ==
Settings::LayoutOption::SeparateWindows && swapped)) {
!(separate_win && swapped)) {
top_screen = top_screen.TranslateX(
(screen_window_area.GetWidth() / 2 - top_screen.GetWidth()) / 2);
bot_screen = bot_screen.TranslateX(
Expand Down
18 changes: 12 additions & 6 deletions src/video_core/renderer_opengl/renderer_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,8 @@ void RendererOpenGL::DrawTopScreen(const Layout::FramebufferLayout& layout,
DrawSingleScreen(screen_infos[0], top_screen_left, top_screen_top, top_screen_width,
top_screen_height, orientation);
glUniform1i(uniform_layer, 1);
DrawSingleScreen(screen_infos[1], static_cast<float>(top_screen_left + (layout.width / 2)),
top_screen_top, top_screen_width, top_screen_height, orientation);
DrawSingleScreen(screen_infos[1], static_cast<float>(top_screen_left + (layout.width / 2)),
top_screen_top, top_screen_width, top_screen_height, orientation);
break;
}
case Settings::StereoRenderOption::CardboardVR: {
Expand Down Expand Up @@ -789,14 +789,20 @@ void RendererOpenGL::DrawBottomScreen(const Layout::FramebufferLayout& layout,
const auto orientation = layout.is_rotated ? Layout::DisplayOrientation::Landscape
: Layout::DisplayOrientation::Portrait;

bool separate_win = false;
#ifndef ANDROID
separate_win =
(Settings::values.layout_option.GetValue() == Settings::LayoutOption::SeparateWindows);
#endif

switch (Settings::values.render_3d.GetValue()) {
case Settings::StereoRenderOption::Off: {
DrawSingleScreen(screen_infos[2], bottom_screen_left, bottom_screen_top,
bottom_screen_width, bottom_screen_height, orientation);
break;
}
case Settings::StereoRenderOption::SideBySide: {
if (Settings::values.layout_option.GetValue() == Settings::LayoutOption::SeparateWindows) {
if (separate_win) {
DrawSingleScreen(screen_infos[2], bottom_screen_left, bottom_screen_top,
bottom_screen_width, bottom_screen_height, orientation);
} else {
Expand All @@ -811,8 +817,8 @@ void RendererOpenGL::DrawBottomScreen(const Layout::FramebufferLayout& layout,
}
case Settings::StereoRenderOption::FullSideBySide: {
DrawSingleScreen(screen_infos[2], bottom_screen_left, bottom_screen_top,
bottom_screen_width, bottom_screen_height, orientation);
if (Settings::values.layout_option.GetValue() != Settings::LayoutOption::SeparateWindows) {
bottom_screen_width, bottom_screen_height, orientation);
if (!separate_win) {
glUniform1i(uniform_layer, 1);
DrawSingleScreen(
screen_infos[2], static_cast<float>(bottom_screen_left + (layout.width / 2)),
Expand All @@ -833,7 +839,7 @@ void RendererOpenGL::DrawBottomScreen(const Layout::FramebufferLayout& layout,
case Settings::StereoRenderOption::Anaglyph:
case Settings::StereoRenderOption::Interlaced:
case Settings::StereoRenderOption::ReverseInterlaced: {
if (Settings::values.layout_option.GetValue() == Settings::LayoutOption::SeparateWindows) {
if (separate_win) {
DrawSingleScreen(screen_infos[2], bottom_screen_left, bottom_screen_top,
bottom_screen_width, bottom_screen_height, orientation);
} else {
Expand Down
14 changes: 10 additions & 4 deletions src/video_core/renderer_vulkan/renderer_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,14 +744,20 @@ void RendererVulkan::DrawBottomScreen(const Layout::FramebufferLayout& layout,
const auto orientation = layout.is_rotated ? Layout::DisplayOrientation::Landscape
: Layout::DisplayOrientation::Portrait;

bool separate_win = false;
#ifndef ANDROID
separate_win =
(Settings::values.layout_option.GetValue() == Settings::LayoutOption::SeparateWindows);
#endif

switch (Settings::values.render_3d.GetValue()) {
case Settings::StereoRenderOption::Off: {
DrawSingleScreen(2, bottom_screen_left, bottom_screen_top, bottom_screen_width,
bottom_screen_height, orientation);
break;
}
case Settings::StereoRenderOption::SideBySide: {
if (Settings::values.layout_option.GetValue() == Settings::LayoutOption::SeparateWindows) {
if (separate_win) {
DrawSingleScreen(2, bottom_screen_left, bottom_screen_top, bottom_screen_width,
bottom_screen_height, orientation);
} else {
Expand All @@ -766,8 +772,8 @@ void RendererVulkan::DrawBottomScreen(const Layout::FramebufferLayout& layout,
}
case Settings::StereoRenderOption::FullSideBySide: {
DrawSingleScreen(2, bottom_screen_left, bottom_screen_top, bottom_screen_width,
bottom_screen_height, orientation);
if (Settings::values.layout_option.GetValue() != Settings::LayoutOption::SeparateWindows) {
bottom_screen_height, orientation);
if (!separate_win) {
draw_info.layer = 1;
DrawSingleScreen(2, static_cast<float>(bottom_screen_left + (layout.width / 2)),
bottom_screen_top, bottom_screen_width, bottom_screen_height,
Expand All @@ -787,7 +793,7 @@ void RendererVulkan::DrawBottomScreen(const Layout::FramebufferLayout& layout,
case Settings::StereoRenderOption::Anaglyph:
case Settings::StereoRenderOption::Interlaced:
case Settings::StereoRenderOption::ReverseInterlaced: {
if (Settings::values.layout_option.GetValue() == Settings::LayoutOption::SeparateWindows) {
if (separate_win) {
DrawSingleScreen(2, bottom_screen_left, bottom_screen_top, bottom_screen_width,
bottom_screen_height, orientation);
} else {
Expand Down

0 comments on commit cb3accf

Please sign in to comment.