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.
This commit is contained in:
2jun0 2021-08-25 00:40:35 +09:00 committed by GitHub
parent 0d37a0a5fc
commit 346e8c0b87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;