make touchscreen code take rotation into account

This commit is contained in:
StapleButter 2017-11-09 00:15:59 +01:00
parent 34513063ab
commit f2a5be6096
1 changed files with 34 additions and 5 deletions

View File

@ -344,11 +344,40 @@ void OnAreaMouseEvent(uiAreaHandler* handler, uiArea* area, uiAreaMouseEvent* ev
x -= BottomScreenRect.X; x -= BottomScreenRect.X;
y -= BottomScreenRect.Y; y -= BottomScreenRect.Y;
if (ScreenRotation == 0 || ScreenRotation == 2)
{
if (BottomScreenRect.Width != 256) if (BottomScreenRect.Width != 256)
x = (x * 256) / BottomScreenRect.Width; x = (x * 256) / BottomScreenRect.Width;
if (BottomScreenRect.Height != 192) if (BottomScreenRect.Height != 192)
y = (y * 192) / BottomScreenRect.Height; y = (y * 192) / BottomScreenRect.Height;
if (ScreenRotation == 2)
{
x = 255 - x;
y = 191 - y;
}
}
else
{
if (BottomScreenRect.Width != 192)
x = (x * 192) / BottomScreenRect.Width;
if (BottomScreenRect.Height != 256)
y = (y * 256) / BottomScreenRect.Height;
if (ScreenRotation == 1)
{
int tmp = x;
x = y;
y = 191 - tmp;
}
else
{
int tmp = x;
x = 255 - y;
y = tmp;
}
}
// clamp // clamp
if (x < 0) x = 0; if (x < 0) x = 0;
else if (x > 255) x = 255; else if (x > 255) x = 255;
@ -396,7 +425,7 @@ void SetupScreenRects(int width, int height)
{ {
bool horizontal = false; bool horizontal = false;
bool sideways = false; bool sideways = false;
ScreenRotation = 3; // TEST 1=90 CW 2=180 3=270 ScreenRotation = 1; // TEST 1=90 CW 2=180 3=270
if (ScreenRotation == 1 || ScreenRotation == 3) if (ScreenRotation == 1 || ScreenRotation == 3)
sideways = true; sideways = true;