summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGhost <[email protected]>2023-01-14 19:41:42 +0100
committerGitHub <[email protected]>2023-01-14 19:41:42 +0100
commit2a2f2b20b8d918f9597334efad067683ae2328b0 (patch)
tree73dbe31f70a619facf9df0b0080f1378615e7858
parentaed131a8f0746065d97f2ff35f5a90713236efc0 (diff)
downloadraylib-2a2f2b20b8d918f9597334efad067683ae2328b0.tar.gz
raylib-2a2f2b20b8d918f9597334efad067683ae2328b0.zip
Fixed bug : touches become sticky (#2857)
Touches became sticky and didn't disappear after using more than 2 fingers, fixed by getting the touch count of how many fingers are on the screen, and only looping through the available/pressed down touch points instead of looping through the maximum touch points. Tested with more than 10 touch points, and with different MAX points value, working perfectly.
-rw-r--r--examples/core/core_input_multitouch.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/examples/core/core_input_multitouch.c b/examples/core/core_input_multitouch.c
index 980af380..37817e5a 100644
--- a/examples/core/core_input_multitouch.c
+++ b/examples/core/core_input_multitouch.c
@@ -39,8 +39,12 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
- // Get multiple touchpoints
- for (int i = 0; i < MAX_TOUCH_POINTS; ++i) touchPositions[i] = GetTouchPosition(i);
+ // Get the touch point count ( how many fingers are touching the screen )
+ int tCount = GetTouchPointCount();
+ // Clamp touch points available ( set the maximum touch points allowed )
+ if(tCount > MAX_TOUCH_POINTS) tCount = MAX_TOUCH_POINTS;
+ // Get touch points positions
+ for (int i = 0; i < tCount; ++i) touchPositions[i] = GetTouchPosition(i);
//----------------------------------------------------------------------------------
// Draw
@@ -49,7 +53,7 @@ int main(void)
ClearBackground(RAYWHITE);
- for (int i = 0; i < MAX_TOUCH_POINTS; ++i)
+ for (int i = 0; i < tCount; ++i)
{
// Make sure point is not (0, 0) as this means there is no touch for it
if ((touchPositions[i].x > 0) && (touchPositions[i].y > 0))
@@ -72,4 +76,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
-} \ No newline at end of file
+}