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

View File

@ -21,8 +21,8 @@ void EmuWindow::ButtonReleased(Service::HID::PadState pad) {
void EmuWindow::CirclePadUpdated(float x, float y) {
constexpr int MAX_CIRCLEPAD_POS = 0x9C; // Max value for a circle pad position
// Make sure the coordinates are in the unit circle,
// otherwise normalize it.
// Make sure the coordinates are in the unit circle,
// otherwise normalize it.
float r = x * x + y * y;
if (r > 1) {
r = std::sqrt(r);
@ -35,26 +35,26 @@ void EmuWindow::CirclePadUpdated(float x, float y) {
}
/**
* 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 framebuffer_x Framebuffer x-coordinate to check
* @param framebuffer_y Framebuffer y-coordinate to check
* @return True if the coordinates are within the touchpad, otherwise false
*/
* 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 framebuffer_x Framebuffer x-coordinate to check
* @param framebuffer_y Framebuffer y-coordinate to check
* @return True if the coordinates are within the touchpad, otherwise false
*/
static bool IsWithinTouchscreen(const EmuWindow::FramebufferLayout& layout, unsigned framebuffer_x,
unsigned framebuffer_y) {
unsigned framebuffer_y) {
return (framebuffer_y >= layout.bottom_screen.top &&
framebuffer_y < layout.bottom_screen.bottom &&
framebuffer_x >= layout.bottom_screen.left &&
framebuffer_x < layout.bottom_screen.right);
framebuffer_y < layout.bottom_screen.bottom &&
framebuffer_x >= layout.bottom_screen.left &&
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::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::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);
}
@ -94,7 +94,7 @@ EmuWindow::FramebufferLayout EmuWindow::FramebufferLayout::DefaultScreenLayout(u
if (width == 0) width = 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 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.top = res.top_screen.bottom;
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.
int viewport_width = static_cast<int>(std::round(height / emulation_aspect_ratio));