This commit is contained in:
Anon 2016-07-30 10:24:27 -05:00
parent 3be6948ca4
commit 6ab731648b

View File

@ -35,12 +35,12 @@ void EmuWindow::CirclePadUpdated(float x, float y) {
} }
/** /**
* Check if the given x/y coordinates are within the touchpad specified by the framebuffer layout * Check if the given x/y coordinates are within the touchpad specified by the framebuffer layout
* @param layout FramebufferLayout object describing the framebuffer size and screen positions * @param layout FramebufferLayout object describing the framebuffer size and screen positions
* @param framebuffer_x Framebuffer x-coordinate to check * @param framebuffer_x Framebuffer x-coordinate to check
* @param framebuffer_y Framebuffer y-coordinate to check * @param framebuffer_y Framebuffer y-coordinate to check
* @return True if the coordinates are within the touchpad, otherwise false * @return True if the coordinates are within the touchpad, otherwise false
*/ */
static bool IsWithinTouchscreen(const EmuWindow::FramebufferLayout& layout, unsigned framebuffer_x, static bool IsWithinTouchscreen(const EmuWindow::FramebufferLayout& layout, unsigned framebuffer_x,
unsigned framebuffer_y) { unsigned framebuffer_y) {
return (framebuffer_y >= layout.bottom_screen.top && return (framebuffer_y >= layout.bottom_screen.top &&
@ -49,12 +49,12 @@ static bool IsWithinTouchscreen(const EmuWindow::FramebufferLayout& layout, unsi
framebuffer_x < layout.bottom_screen.right); framebuffer_x < layout.bottom_screen.right);
} }
std::tuple<unsigned, unsigned> EmuWindow::ClipToTouchScreen(unsigned new_x, unsigned new_y) { std::tuple<unsigned,unsigned> EmuWindow::ClipToTouchScreen(unsigned new_x, unsigned new_y) {
new_x = std::max(new_x, framebuffer_layout.bottom_screen.left); new_x = std::max(new_x, framebuffer_layout.bottom_screen.left);
new_x = std::min(new_x, framebuffer_layout.bottom_screen.right - 1); new_x = std::min(new_x, framebuffer_layout.bottom_screen.right-1);
new_y = std::max(new_y, framebuffer_layout.bottom_screen.top); new_y = std::max(new_y, framebuffer_layout.bottom_screen.top);
new_y = std::min(new_y, framebuffer_layout.bottom_screen.bottom - 1); new_y = std::min(new_y, framebuffer_layout.bottom_screen.bottom-1);
return std::make_tuple(new_x, new_y); return std::make_tuple(new_x, new_y);
} }
@ -94,7 +94,7 @@ EmuWindow::FramebufferLayout EmuWindow::FramebufferLayout::DefaultScreenLayout(u
if (width == 0) width = 1; if (width == 0) width = 1;
if (height == 0) height = 1; if (height == 0) height = 1;
EmuWindow::FramebufferLayout res = { width, height,{},{} }; EmuWindow::FramebufferLayout res = { width, height, {}, {} };
float window_aspect_ratio = static_cast<float>(height) / width; float window_aspect_ratio = static_cast<float>(height) / width;
float emulation_aspect_ratio = static_cast<float>(VideoCore::kScreenTopHeight * 2) / float emulation_aspect_ratio = static_cast<float>(VideoCore::kScreenTopHeight * 2) /
@ -117,8 +117,7 @@ EmuWindow::FramebufferLayout EmuWindow::FramebufferLayout::DefaultScreenLayout(u
res.bottom_screen.right = res.bottom_screen.left + bottom_width; res.bottom_screen.right = res.bottom_screen.left + bottom_width;
res.bottom_screen.top = res.top_screen.bottom; res.bottom_screen.top = res.top_screen.bottom;
res.bottom_screen.bottom = res.bottom_screen.top + viewport_height / 2; res.bottom_screen.bottom = res.bottom_screen.top + viewport_height / 2;
} } else {
else {
// Otherwise, apply borders to the left and right sides of the window. // Otherwise, apply borders to the left and right sides of the window.
int viewport_width = static_cast<int>(std::round(height / emulation_aspect_ratio)); int viewport_width = static_cast<int>(std::round(height / emulation_aspect_ratio));