[rcore][drm] `GetTouchPointCount()` returns 1 when screen is not touched
Just did a git pull to get the latest; compiled on a RaspberryPi 3 with make PLATFORM=PLATFORM_DRM
To reproduce just add to the core_input_multitouch.c a statement to print tCount and compile and run it.
When touching the screen first with your index finger when with your thumb and then releasing the index finger and after that the thumb the tCount will still show 1 even though nothing touches the screen anymore.
Hi @larry104 looks like this behaviour is provoked by
PollInputEvents(void)
...
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
And rcore_drm is checking if position is different than 0 instead of keeping the CORE.Input.Touch.pointCount based on events
// Update touch point count
CORE.Input.Touch.pointCount = 0;
for (int i = 0; i < MAX_TOUCH_POINTS; i++)
{
if (CORE.Input.Touch.position[i].x >= 0) CORE.Input.Touch.pointCount++;
}
I do not have how to test it so I cannot try to fix it.
@raysan5 I have made a PR #5279 could you look into it , if there are any changes let me know.
@larry104 @raysan5 can this be closed? the PR was merged
I don't think these issues are related nor does the CORE.Input.Touch.pointCount = 0 fix the reported issue. You can check with the multitouch example core_input_multitouch.c.
-
When you touch the screen with one finger and stop moving the finger around GetTouchPointCount() get's reset to 0 but the moment you start moving your finger again it gets back to 1.
-
If you touch the screen with first one finger then add the second. Now lift of the first and GetTouchPointCount() will be still 2 (of course when moving the finger around)
It looks to me touchpoints do not get tracked properly in general especially when you don't have any movement.
Let me know if you need more explanation or want me to do tests or a take video for print any debug info while touching.
@larry104 I made changes could you check the pr merged and test it?
I only see the master branch which was updated 7 hours ago as of this writing .. are you talking about that? if yes, no changes in there.
@larry104 check this #5279 PR
Yes, I compiled against that which is in the latest master branch. I confirmed by checking rcore_drm.c. But it does not solve the problem I am reporting.
@larry104 can I have more more detials?
@larry104 I have made some changes in my forked repo test branch https://github.com/MULTidll/raylib/tree/test could you also check that once?
When I print tCount = GetTouchPointCount(); I see the following:
The following was tested with the latest commit of the master branch as of this morning: 0: when screen is not touched 0: when touched and keep finger on the screen (that should show 1, and only when I lift the finger off the screen it should go back to 0) 0/1: when touching and constantly moving the finger, but it flickers so it's sometimes 1 and sometime 0.
Your fork shows the following: 0: when screen is not touched 0/1 when touched and keep finger on the screen (flickers randomly between 0 and 1) 1: when touching and constantly moving the finger.
Both versions fail when it comes to touching with lets say 3 fingers (tCount=3) (constantly moving them around) and then removing one of the fingers. tCount=2 but it seems that touchPositions has only one value of the first touchpoint.
Note: all tested with core_input_multitouch.c in from the examples (I just added printing tCount)
@larry104 sorry for the late response, I have updated the rcore_drm.c in test branch of my fork https://github.com/MULTidll/raylib/tree/test could you check if this way works?
It is much much better now. Number of touch points are correctly detected and no more flickering of the number of touchpoints. But there are still some issue. If I touch the screen with 5 fingers. An lift off all 5 again sometimes there is still one touchpoint active without anything touched. It happens in about 8 out of 10 cases. The second problem is if touch with 5 fingers and move them around, then lift one finger off and start moving the remaining 4 fingers one of the touchpoints does not move anymore if that makes sense.
@larry104 added cleanup now try testing it https://github.com/MULTidll/raylib/tree/test
That made it some how worse. Now if I touch and keep touching without moving touchpoints disappear after ~2 seconds. If I keep my fingers moving they don't disappear.
@larry104 could you try now https://github.com/MULTidll/raylib/tree/test
the problem with disappearing touchpoints is solved but now the following: lets say I touch the screen with 3 fingers and remove 1 finger but 2 disappear. Dependent on which of the one finger I remove strange things happen e,g the yellow circle under the finger pops up somewhere else. It would be easier to attach a short video ;-)
try latest commit https://github.com/MULTidll/raylib/tree/test , also a short video would help could you attach some link?
See if that works for you https://youtu.be/RxKrflh3CDc
Sorry, I just noticed the first video I made was without your last updates. This https://youtu.be/eqMmuhYIF-s is after your latest checkin.