summaryrefslogtreecommitdiff
path: root/src/core/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/frontend')
-rw-r--r--src/core/frontend/emu_window.cpp8
-rw-r--r--src/core/frontend/framebuffer_layout.cpp18
-rw-r--r--src/core/frontend/framebuffer_layout.h11
3 files changed, 24 insertions, 13 deletions
diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp
index 5fdb3a7e8..4f7d54a33 100644
--- a/src/core/frontend/emu_window.cpp
+++ b/src/core/frontend/emu_window.cpp
@@ -5,10 +5,10 @@
5#include <algorithm> 5#include <algorithm>
6#include <cmath> 6#include <cmath>
7#include "common/assert.h" 7#include "common/assert.h"
8#include "core/3ds.h"
8#include "core/core.h" 9#include "core/core.h"
9#include "core/frontend/emu_window.h" 10#include "core/frontend/emu_window.h"
10#include "core/settings.h" 11#include "core/settings.h"
11#include "video_core/video_core.h"
12 12
13/** 13/**
14 * Check if the given x/y coordinates are within the touchpad specified by the framebuffer layout 14 * Check if the given x/y coordinates are within the touchpad specified by the framebuffer layout
@@ -38,11 +38,9 @@ void EmuWindow::TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y) {
38 if (!IsWithinTouchscreen(framebuffer_layout, framebuffer_x, framebuffer_y)) 38 if (!IsWithinTouchscreen(framebuffer_layout, framebuffer_x, framebuffer_y))
39 return; 39 return;
40 40
41 touch_x = VideoCore::kScreenBottomWidth * 41 touch_x = Core::kScreenBottomWidth * (framebuffer_x - framebuffer_layout.bottom_screen.left) /
42 (framebuffer_x - framebuffer_layout.bottom_screen.left) /
43 (framebuffer_layout.bottom_screen.right - framebuffer_layout.bottom_screen.left); 42 (framebuffer_layout.bottom_screen.right - framebuffer_layout.bottom_screen.left);
44 touch_y = VideoCore::kScreenBottomHeight * 43 touch_y = Core::kScreenBottomHeight * (framebuffer_y - framebuffer_layout.bottom_screen.top) /
45 (framebuffer_y - framebuffer_layout.bottom_screen.top) /
46 (framebuffer_layout.bottom_screen.bottom - framebuffer_layout.bottom_screen.top); 44 (framebuffer_layout.bottom_screen.bottom - framebuffer_layout.bottom_screen.top);
47 45
48 touch_pressed = true; 46 touch_pressed = true;
diff --git a/src/core/frontend/framebuffer_layout.cpp b/src/core/frontend/framebuffer_layout.cpp
index f3815170d..d2d02f9ff 100644
--- a/src/core/frontend/framebuffer_layout.cpp
+++ b/src/core/frontend/framebuffer_layout.cpp
@@ -5,16 +5,20 @@
5#include <cmath> 5#include <cmath>
6 6
7#include "common/assert.h" 7#include "common/assert.h"
8#include "core/3ds.h"
8#include "core/frontend/framebuffer_layout.h" 9#include "core/frontend/framebuffer_layout.h"
9#include "core/settings.h" 10#include "core/settings.h"
10#include "video_core/video_core.h"
11 11
12namespace Layout { 12namespace Layout {
13 13
14static const float TOP_SCREEN_ASPECT_RATIO = 14static const float TOP_SCREEN_ASPECT_RATIO =
15 static_cast<float>(VideoCore::kScreenTopHeight) / VideoCore::kScreenTopWidth; 15 static_cast<float>(Core::kScreenTopHeight) / Core::kScreenTopWidth;
16static const float BOT_SCREEN_ASPECT_RATIO = 16static const float BOT_SCREEN_ASPECT_RATIO =
17 static_cast<float>(VideoCore::kScreenBottomHeight) / VideoCore::kScreenBottomWidth; 17 static_cast<float>(Core::kScreenBottomHeight) / Core::kScreenBottomWidth;
18
19float FramebufferLayout::GetScalingRatio() const {
20 return static_cast<float>(top_screen.GetWidth()) / Core::kScreenTopWidth;
21}
18 22
19// Finds the largest size subrectangle contained in window area that is confined to the aspect ratio 23// Finds the largest size subrectangle contained in window area that is confined to the aspect ratio
20template <class T> 24template <class T>
@@ -106,10 +110,10 @@ FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool swapped
106 float window_aspect_ratio = static_cast<float>(height) / width; 110 float window_aspect_ratio = static_cast<float>(height) / width;
107 float emulation_aspect_ratio = 111 float emulation_aspect_ratio =
108 swapped 112 swapped
109 ? VideoCore::kScreenBottomHeight * 4 / 113 ? Core::kScreenBottomHeight * 4 /
110 (VideoCore::kScreenBottomWidth * 4.0f + VideoCore::kScreenTopWidth) 114 (Core::kScreenBottomWidth * 4.0f + Core::kScreenTopWidth)
111 : VideoCore::kScreenTopHeight * 4 / 115 : Core::kScreenTopHeight * 4 /
112 (VideoCore::kScreenTopWidth * 4.0f + VideoCore::kScreenBottomWidth); 116 (Core::kScreenTopWidth * 4.0f + Core::kScreenBottomWidth);
113 float large_screen_aspect_ratio = swapped ? BOT_SCREEN_ASPECT_RATIO : TOP_SCREEN_ASPECT_RATIO; 117 float large_screen_aspect_ratio = swapped ? BOT_SCREEN_ASPECT_RATIO : TOP_SCREEN_ASPECT_RATIO;
114 float small_screen_aspect_ratio = swapped ? TOP_SCREEN_ASPECT_RATIO : BOT_SCREEN_ASPECT_RATIO; 118 float small_screen_aspect_ratio = swapped ? TOP_SCREEN_ASPECT_RATIO : BOT_SCREEN_ASPECT_RATIO;
115 119
diff --git a/src/core/frontend/framebuffer_layout.h b/src/core/frontend/framebuffer_layout.h
index f1df5c55a..9a7738969 100644
--- a/src/core/frontend/framebuffer_layout.h
+++ b/src/core/frontend/framebuffer_layout.h
@@ -5,7 +5,9 @@
5#pragma once 5#pragma once
6 6
7#include "common/math_util.h" 7#include "common/math_util.h"
8
8namespace Layout { 9namespace Layout {
10
9/// Describes the layout of the window framebuffer (size and top/bottom screen positions) 11/// Describes the layout of the window framebuffer (size and top/bottom screen positions)
10struct FramebufferLayout { 12struct FramebufferLayout {
11 unsigned width; 13 unsigned width;
@@ -14,6 +16,12 @@ struct FramebufferLayout {
14 bool bottom_screen_enabled; 16 bool bottom_screen_enabled;
15 MathUtil::Rectangle<unsigned> top_screen; 17 MathUtil::Rectangle<unsigned> top_screen;
16 MathUtil::Rectangle<unsigned> bottom_screen; 18 MathUtil::Rectangle<unsigned> bottom_screen;
19
20 /**
21 * Returns the ration of pixel size of the top screen, compared to the native size of the 3DS
22 * screen.
23 */
24 float GetScalingRatio() const;
17}; 25};
18 26
19/** 27/**
@@ -52,4 +60,5 @@ FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool is_swap
52 * @return Newly created FramebufferLayout object with default screen regions initialized 60 * @return Newly created FramebufferLayout object with default screen regions initialized
53 */ 61 */
54FramebufferLayout CustomFrameLayout(unsigned width, unsigned height); 62FramebufferLayout CustomFrameLayout(unsigned width, unsigned height);
55} 63
64} // namespace Layout