raylib icon indicating copy to clipboard operation
raylib copied to clipboard

[rcore][drm] `GetTouchPointCount()` returns 1 when screen is not touched

Open larry104 opened this issue 1 year ago • 35 comments

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.

larry104 avatar Mar 15 '25 20:03 larry104

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.

maiconpintoabreu avatar Jul 21 '25 12:07 maiconpintoabreu

@raysan5 I have made a PR #5279 could you look into it , if there are any changes let me know.

MUL7ii avatar Oct 16 '25 20:10 MUL7ii

@larry104 @raysan5 can this be closed? the PR was merged

CrackedPixel avatar Oct 22 '25 20:10 CrackedPixel

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.

  1. 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.

  2. 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 avatar Oct 22 '25 22:10 larry104

@larry104 I made changes could you check the pr merged and test it?

MUL7ii avatar Oct 23 '25 13:10 MUL7ii

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 avatar Oct 23 '25 23:10 larry104

@larry104 check this #5279 PR

MUL7ii avatar Oct 26 '25 11:10 MUL7ii

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 avatar Oct 26 '25 20:10 larry104

@larry104 can I have more more detials?

MUL7ii avatar Oct 27 '25 12:10 MUL7ii

@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?

MUL7ii avatar Oct 27 '25 12:10 MUL7ii

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 avatar Oct 27 '25 17:10 larry104

@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?

MUL7ii avatar Nov 17 '25 16:11 MUL7ii

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 avatar Nov 17 '25 18:11 larry104

@larry104 added cleanup now try testing it https://github.com/MULTidll/raylib/tree/test

MUL7ii avatar Nov 18 '25 06:11 MUL7ii

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 avatar Nov 21 '25 22:11 larry104

@larry104 could you try now https://github.com/MULTidll/raylib/tree/test

MUL7ii avatar Nov 22 '25 06:11 MUL7ii

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 ;-)

larry104 avatar Nov 22 '25 18:11 larry104

try latest commit https://github.com/MULTidll/raylib/tree/test , also a short video would help could you attach some link?

MUL7ii avatar Nov 23 '25 07:11 MUL7ii

See if that works for you https://youtu.be/RxKrflh3CDc

larry104 avatar Nov 23 '25 19:11 larry104

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.

larry104 avatar Nov 24 '25 19:11 larry104