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 16, 2024
1 parent 40b00c9 commit 6ba8e18
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 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
3 changes: 2 additions & 1 deletion src/core/frontend/framebuffer_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ FramebufferLayout SingleFrameLayout(u32 width, u32 height, bool swapped, bool up
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)) {
Settings::LayoutOption::SeparateWindows &&
swapped)) {
top_screen = top_screen.TranslateX(
(screen_window_area.GetWidth() / 2 - top_screen.GetWidth()) / 2);
bot_screen = bot_screen.TranslateX(
Expand Down
6 changes: 3 additions & 3 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 @@ -811,7 +811,7 @@ 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);
bottom_screen_width, bottom_screen_height, orientation);
if (Settings::values.layout_option.GetValue() != Settings::LayoutOption::SeparateWindows) {
glUniform1i(uniform_layer, 1);
DrawSingleScreen(
Expand Down
2 changes: 1 addition & 1 deletion src/video_core/renderer_vulkan/renderer_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ 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);
bottom_screen_height, orientation);
if (Settings::values.layout_option.GetValue() != Settings::LayoutOption::SeparateWindows) {
draw_info.layer = 1;
DrawSingleScreen(2, static_cast<float>(bottom_screen_left + (layout.width / 2)),
Expand Down

0 comments on commit 6ba8e18

Please sign in to comment.