aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/NDS.cpp2
-rw-r--r--src/frontend/FrontendUtil.h2
-rw-r--r--src/frontend/Util_Video.cpp30
-rw-r--r--src/frontend/qt_sdl/main.cpp8
4 files changed, 21 insertions, 21 deletions
diff --git a/src/NDS.cpp b/src/NDS.cpp
index cd0cb92..55b4fdf 100644
--- a/src/NDS.cpp
+++ b/src/NDS.cpp
@@ -342,7 +342,7 @@ void SetupDirectBoot()
if (ConsoleType == 1)
{
// With the BIOS select in SCFG_BIOS and the initialization od
- // SCFG_BIOS depending on the Header->UnitType, we can now boot
+ // SCFG_BIOS depending on the Header->UnitType, we can now boot
// directly in the roms.
// There are some more SCFG Settings that change depending on
// the unit type, so this is experimental
diff --git a/src/frontend/FrontendUtil.h b/src/frontend/FrontendUtil.h
index b361c2a..f52dced 100644
--- a/src/frontend/FrontendUtil.h
+++ b/src/frontend/FrontendUtil.h
@@ -156,7 +156,7 @@ int GetScreenTransforms(float* out, int* kind);
// de-transform the provided host display coordinates to get coordinates
// on the bottom screen
-bool GetTouchCoords(int& x, int& y);
+bool GetTouchCoords(int& x, int& y, bool clamp);
// initialize the audio utility
diff --git a/src/frontend/Util_Video.cpp b/src/frontend/Util_Video.cpp
index 73f934c..73f1b05 100644
--- a/src/frontend/Util_Video.cpp
+++ b/src/frontend/Util_Video.cpp
@@ -467,31 +467,31 @@ int GetScreenTransforms(float* out, int* kind)
return num;
}
-bool GetTouchCoords(int& x, int& y)
+bool GetTouchCoords(int& x, int& y, bool clamp)
{
+ float vx = x;
+ float vy = y;
+
if (BotEnable)
{
- float vx = x;
- float vy = y;
-
M23_Transform(TouchMtx, vx, vy);
-
- x = (int)vx;
- y = (int)vy;
-
- if (vx >= 0 && vx < 256 && vy >= 0 && vy < 192)
- return true;
}
else if (HybEnable && HybScreen == 1)
{
- float vx = x;
- float vy = y;
-
M23_Transform(HybTouchMtx, vx, vy);
+ }
- x = (int)vx;
- y = (int)vy;
+ x = (int)vx;
+ y = (int)vy;
+ if (clamp)
+ {
+ x = std::clamp(x, 0, 255);
+ y = std::clamp(y, 0, 191);
+ return true;
+ }
+ else
+ {
if (x >= 0 && x < 256 && y >= 0 && y < 192)
return true;
}
diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp
index ce0ff84..a62a100 100644
--- a/src/frontend/qt_sdl/main.cpp
+++ b/src/frontend/qt_sdl/main.cpp
@@ -783,7 +783,7 @@ void ScreenHandler::screenOnMousePress(QMouseEvent* event)
int x = event->pos().x();
int y = event->pos().y();
- if (Frontend::GetTouchCoords(x, y))
+ if (Frontend::GetTouchCoords(x, y, false))
{
touching = true;
NDS::TouchScreen(x, y);
@@ -814,7 +814,7 @@ void ScreenHandler::screenOnMouseMove(QMouseEvent* event)
int x = event->pos().x();
int y = event->pos().y();
- if (Frontend::GetTouchCoords(x, y))
+ if (Frontend::GetTouchCoords(x, y, true))
NDS::TouchScreen(x, y);
}
@@ -830,7 +830,7 @@ void ScreenHandler::screenHandleTablet(QTabletEvent* event)
int x = event->x();
int y = event->y();
- if (Frontend::GetTouchCoords(x, y))
+ if (Frontend::GetTouchCoords(x, y, event->type()==QEvent::TabletMove))
{
touching = true;
NDS::TouchScreen(x, y);
@@ -861,7 +861,7 @@ void ScreenHandler::screenHandleTouch(QTouchEvent* event)
int x = (int)lastPosition.x();
int y = (int)lastPosition.y();
- if (Frontend::GetTouchCoords(x, y))
+ if (Frontend::GetTouchCoords(x, y, event->type()==QEvent::TouchUpdate))
{
touching = true;
NDS::TouchScreen(x, y);