Skip to content

Commit 2a2f2b2

Browse files
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.
1 parent aed131a commit 2a2f2b2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

examples/core/core_input_multitouch.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@ int main(void)
3939
{
4040
// Update
4141
//----------------------------------------------------------------------------------
42-
// Get multiple touchpoints
43-
for (int i = 0; i < MAX_TOUCH_POINTS; ++i) touchPositions[i] = GetTouchPosition(i);
42+
// Get the touch point count ( how many fingers are touching the screen )
43+
int tCount = GetTouchPointCount();
44+
// Clamp touch points available ( set the maximum touch points allowed )
45+
if(tCount > MAX_TOUCH_POINTS) tCount = MAX_TOUCH_POINTS;
46+
// Get touch points positions
47+
for (int i = 0; i < tCount; ++i) touchPositions[i] = GetTouchPosition(i);
4448
//----------------------------------------------------------------------------------
4549

4650
// Draw
@@ -49,7 +53,7 @@ int main(void)
4953

5054
ClearBackground(RAYWHITE);
5155

52-
for (int i = 0; i < MAX_TOUCH_POINTS; ++i)
56+
for (int i = 0; i < tCount; ++i)
5357
{
5458
// Make sure point is not (0, 0) as this means there is no touch for it
5559
if ((touchPositions[i].x > 0) && (touchPositions[i].y > 0))
@@ -72,4 +76,4 @@ int main(void)
7276
//--------------------------------------------------------------------------------------
7377

7478
return 0;
75-
}
79+
}

0 commit comments

Comments
 (0)