aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author2jun0 <soo28819@naver.com>2021-08-25 00:40:35 +0900
committerGitHub <noreply@github.com>2021-08-24 17:40:35 +0200
commit346e8c0b878541d987d3ee2bfe54b555f626f7bf (patch)
treeb95dfd8a4c0e79834b5362e4470e7571388a8c5e
parent0d37a0a5fc2310197c8da92c7d932faf11dcb0c9 (diff)
Fix a touchless issue in hybrid layout (#1182)
In the previous commit, there was a touchless error on the hybrid screen. This commit fix a touchless issue in hybrid layout.
-rw-r--r--src/frontend/Util_Video.cpp86
1 files changed, 68 insertions, 18 deletions
diff --git a/src/frontend/Util_Video.cpp b/src/frontend/Util_Video.cpp
index 73f1b05..33f0183 100644
--- a/src/frontend/Util_Video.cpp
+++ b/src/frontend/Util_Video.cpp
@@ -37,6 +37,7 @@ bool TopEnable;
bool BotEnable;
bool HybEnable;
int HybScreen;
+int HybPrevTouchScreen; // 0:unknown, 1:buttom screen, 2:hybrid screen
void M23_Identity(float* m)
{
@@ -138,6 +139,7 @@ void SetupScreenLayout(int screenWidth, int screenHeight,
HybScreen = swapScreens ? 1 : 0;
swapScreens = false;
topAspect = botAspect = 1;
+ HybPrevTouchScreen = 0;
}
float refpoints[6][2] =
@@ -469,31 +471,79 @@ int GetScreenTransforms(float* out, int* kind)
bool GetTouchCoords(int& x, int& y, bool clamp)
{
- float vx = x;
- float vy = y;
-
- if (BotEnable)
+ if (HybEnable && HybScreen == 1)
{
+ float vx = x;
+ float vy = y;
+ float hvx = x;
+ float hvy = y;
+
M23_Transform(TouchMtx, vx, vy);
- }
- else if (HybEnable && HybScreen == 1)
- {
- M23_Transform(HybTouchMtx, vx, vy);
- }
+ M23_Transform(HybTouchMtx, hvx, hvy);
- x = (int)vx;
- y = (int)vy;
+ if (clamp)
+ {
+ if (HybPrevTouchScreen == 1)
+ {
+ x = std::clamp((int)vx, 0, 255);
+ y = std::clamp((int)vy, 0, 191);
+
+ return true;
+ }
+ if (HybPrevTouchScreen == 2)
+ {
+ x = std::clamp((int)hvx, 0, 255);
+ y = std::clamp((int)hvy, 0, 191);
- if (clamp)
- {
- x = std::clamp(x, 0, 255);
- y = std::clamp(y, 0, 191);
- return true;
+ return true;
+ }
+ }
+ else
+ {
+ if (vx >= 0 && vx < 256 && vy >= 0 && vy < 192)
+ {
+ HybPrevTouchScreen = 1;
+
+ x = (int)vx;
+ y = (int)vy;
+
+ return true;
+ }
+ if (hvx >= 0 && hvx < 256 && hvy >= 0 && hvy < 192)
+ {
+ HybPrevTouchScreen = 2;
+
+ x = (int)hvx;
+ y = (int)hvy;
+
+ return true;
+ }
+ }
}
- else
+ else if (BotEnable)
{
- if (x >= 0 && x < 256 && y >= 0 && y < 192)
+ float vx = x;
+ float vy = y;
+
+ M23_Transform(TouchMtx, vx, vy);
+
+ if (clamp)
+ {
+ x = std::clamp((int)vx, 0, 255);
+ y = std::clamp((int)vy, 0, 191);
+
return true;
+ }
+ else
+ {
+ if (vx >= 0 && vx < 256 && vy >= 0 && vy < 192)
+ {
+ x = (int)vx;
+ y = (int)vy;
+
+ return true;
+ }
+ }
}
return false;