# Android mouse events are missing, touches getting stucked for more than 2 fingers

**URL:** <https://forum.juce.com/t/android-mouse-events-are-missing-touches-getting-stucked-for-more-than-2-fingers/65699>\
**Category:** Android\
**Created:** [March 31, 2025, 7:26pm UTC](https://forum.juce.com/t/android-mouse-events-are-missing-touches-getting-stucked-for-more-than-2-fingers/65699 "2025-03-31T19:26:19Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![yoogle](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/yoogle/32/14955_2.png) [@yoogle](https://forum.juce.com/u/yoogle)\
**Post date:** [March 31, 2025, 7:26pm UTC](https://forum.juce.com/t/android-mouse-events-are-missing-touches-getting-stucked-for-more-than-2-fingers/65699/1 "2025-03-31T19:26:19Z")

</div>

Hi Folks,

I am trying to make a multitouch piano application for android in juce framework. The multitouch is working fine on ios devices, also in android it works till maximum 2 touches.

When i am trying to play a chord with 3 fingers, the touches gets stucked, due to system gestures like screenshot.

Is there any way to

1. prevent system gestures in android ?
2. dealing with multitouch event of more than 2 fingers for android ?
3. I tried using this

```auto
juce::Desktop::getInstance().getNumDraggingMouseSources()

```

but still it does not recognises the actual count after the touches gets stucked. Looks like the cancelled touches did not reached to juce.

---

<div class="post-metadata">

**Author:** ![aamf](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/aamf/32/19941_2.png) [@aamf](https://forum.juce.com/u/aamf)\
**Post date:** [March 31, 2025, 9:54pm UTC](https://forum.juce.com/t/android-mouse-events-are-missing-touches-getting-stucked-for-more-than-2-fingers/65699/2 "2025-03-31T21:54:49Z")

</div>

Hi there. Could you post more information about your system (API level etc.) and if possible some code?

---

<div class="post-metadata">

**Author:** ![yoogle](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/yoogle/32/14955_2.png) [@yoogle](https://forum.juce.com/u/yoogle)\
**Post date:** [April 1, 2025, 4:46am UTC](https://forum.juce.com/t/android-mouse-events-are-missing-touches-getting-stucked-for-more-than-2-fingers/65699/3 "2025-04-01T04:46:42Z")

</div>

Here is the code I am using for drawing circles with multitouch events.

```auto
private:
    juce::HashMap<int, juce::Point<float>> points;

```

```auto
void mouseDown(const juce::MouseEvent& event) override
{
    points.set(event.source.getIndex(), event.position);
    repaint();
}

void mouseDrag(const juce::MouseEvent& event) override
{
    points.set(event.source.getIndex(), event.position);
    repaint();
}

void mouseUp(const juce::MouseEvent& event) override
{
    points.remove(event.source.getIndex());
    repaint();
}

void paint (juce::Graphics& g) override
{
    g.fillAll (juce::Colours::black);
    g.setColour(juce::Colours::white);

    for (juce::HashMap<int, juce::Point<float>>::Iterator it (points); it.next();) {
        auto point = it.getValue();
        auto rect = juce::Rectangle<float> (0, 0, 100, 100);
        rect.setCentre(point);

        g.drawEllipse(rect, 2.f);
        g.drawText(juce::String(it.getKey()), rect, juce::Justification::centredBottom);
    }
}

```

 ![Screenshot_2025-04-01-10-06-18-23_c67b5137e833015b3af2200d42a93bfa](https://us1.discourse-cdn.com/flex026/uploads/juce/original/3X/4/b/4b00e1e64aac957e0dcb9ae2b97c8f2698d3cfa0.jpeg)

From mouse events [0, 1, 2] → [1 and 2] got stucked.

Tried on Android 12, 13, 14, 15 with multiple devices.

---

<div class="post-metadata">

**Author:** ![aamf](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/aamf/32/19941_2.png) [@aamf](https://forum.juce.com/u/aamf)\
**Post date:** [April 1, 2025, 11:52am UTC](https://forum.juce.com/t/android-mouse-events-are-missing-touches-getting-stucked-for-more-than-2-fingers/65699/4 "2025-04-01T11:52:02Z")

</div>

I’ve tested on three devices with Android 8, 13 and 14. Everything worked perfectly, got five input sources on the older device, ten on the newer devices. No stuck events whatsoever.

Could it be that your UI thread is overloaded? Have you attached an OpenGLContext to your main window (this is pretty much a must with Android)? How do you have the system gestures set up?

My app also relies on multitouch and Android can be somewhat… “surprising”, so please post more information!

---

<div class="post-metadata">

**Author:** ![yoogle](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/yoogle/32/14955_2.png) [@yoogle](https://forum.juce.com/u/yoogle)\
**Post date:** [April 1, 2025, 12:37pm UTC](https://forum.juce.com/t/android-mouse-events-are-missing-touches-getting-stucked-for-more-than-2-fingers/65699/5 "2025-04-01T12:37:46Z")

</div>

Yes, I had attached it to opengl context. I had tested without attaching the context also. Both the things are giving same result, touches getting stucked.

Tested on OnePlus 12R.

Adding fingers one by one had no issues, issue arrives when 3 or more fingers touches at the same time, like playing a chord.

---

<div class="post-metadata">

**Author:** ![aamf](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/aamf/32/19941_2.png) [@aamf](https://forum.juce.com/u/aamf)\
**Post date:** [April 1, 2025, 1:14pm UTC](https://forum.juce.com/t/android-mouse-events-are-missing-touches-getting-stucked-for-more-than-2-fingers/65699/6 "2025-04-01T13:14:49Z")

</div>

On my tests there are no problems with three or more fingers touching simultaneously. You say that a screenshot or other system events are triggered? How do you have that set up?

Perhaps another thing to check would be the AndroidManifest.xml or the theme settings.

Which JUCE version are you on?

EDIT:

Investigated a bit further since you mentioned OnePlus and apparently it’s a problem with some Android devices which have system-level three-finger gestures. The problem: Android doesn’t allow apps to disable these gestures. sigh.

I guess the only option is to show a message to the users to disable these gestures manually. Perhaps as soon as “stuck notes” are detected.

I think I will also check on startup if the user is using a device by one the “risky” manufacturers.

```auto
bool checkForThreeFingerGestureRisk()
{
    juce::StringArray riskyManufacturers = { "xiaomi", "oneplus", "realme", "oppo", "vivo" };
    return riskyManufacturers.contains (juce::SystemStats::getDeviceManufacturer().toLowerCase());
}

```

---

<div class="post-metadata">

**Author:** ![yoogle](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/yoogle/32/14955_2.png) [@yoogle](https://forum.juce.com/u/yoogle)\
**Post date:** [April 1, 2025, 3:32pm UTC](https://forum.juce.com/t/android-mouse-events-are-missing-touches-getting-stucked-for-more-than-2-fingers/65699/7 "2025-04-01T15:32:32Z")

</div>

I had removed these following 3 finger gestures and its working fine.

1. 3-finger swipe down for screenshot
2. 3-finger touch and hold for screenshot
3. 3-finger swipe up to enter split screen

The problem is now, how to detect these kind of gestures in juce first time when the user opened the app, and tell user to disable these things. Because if they encounter this touches stucked thing, the notes on the piano will keep ringing and stucked.

---

<div class="post-metadata">

**Author:** ![aamf](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/aamf/32/19941_2.png) [@aamf](https://forum.juce.com/u/aamf)\
**Post date:** [April 5, 2025, 12:04pm UTC](https://forum.juce.com/t/android-mouse-events-are-missing-touches-getting-stucked-for-more-than-2-fingers/65699/8 "2025-04-05T12:04:37Z")

</div>

Hi there, have you figured out a good way to deal with this? I would at least like to have something in place which detects when a gesture has become “stuck”. But I don’t have a device by any of the “problematic” manufacturers. Could you describe exactly what happens? Do you get mouse down events for source numbers 1 and 2 but then not a mouse up event for those sources? Also not mouse drag I suppose? And if these touch events are “stuck”, do they become “unstuck” if you then add fingers one by one? Thanks!

---

<div class="post-metadata">

**Author:** ![yoogle](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/yoogle/32/14955_2.png) [@yoogle](https://forum.juce.com/u/yoogle)\
**Post date:** [April 5, 2025, 7:08pm UTC](https://forum.juce.com/t/android-mouse-events-are-missing-touches-getting-stucked-for-more-than-2-fingers/65699/9 "2025-04-05T19:08:01Z")

</div>

Yes, Exactly the same issue.

When android touches are getting cancelled, only first event is getting triggered, the other cancelled touches are not reported to juce. There is a bug in “ComponentPeerView.java” file for “ACTION\_CANCEL” event. “ACTION\_CANCEL” event has to be iterated for all the pointers.

---

<div class="post-metadata">

**Author:** ![aamf](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/aamf/32/19941_2.png) [@aamf](https://forum.juce.com/u/aamf)\
**Post date:** [April 6, 2025, 12:34pm UTC](https://forum.juce.com/t/android-mouse-events-are-missing-touches-getting-stucked-for-more-than-2-fingers/65699/10 "2025-04-06T12:34:15Z")

</div>

Yes, I also think that’s a bug within “ComponentPeerView.java”. When ACTION\_CANCEL is received mouseUp should be called for all pointers.

Have you tried modifying that file? Perhaps moving the line  
`case MotionEvent.ACTION_CANCEL:`  
immediately before  
`case MotionEvent.ACTION_POINTER_UP:`  
would already work, but I can’t test this myself.

Could you perhaps give it a try? Note that since this is Java you would need to also follow the first three steps in JUCE/modules/juce\_core/native/java/README.txt

---

<div class="post-metadata">

**Author:** ![yoogle](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/yoogle/32/14955_2.png) [@yoogle](https://forum.juce.com/u/yoogle)\
**Post date:** [April 7, 2025, 8:54am UTC](https://forum.juce.com/t/android-mouse-events-are-missing-touches-getting-stucked-for-more-than-2-fingers/65699/11 "2025-04-07T08:54:57Z")

</div>

Yes, I tried it and its started working. I dont know how to contribute it to the juce github repo.

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [April 7, 2025, 11:58am UTC](https://forum.juce.com/t/android-mouse-events-are-missing-touches-getting-stucked-for-more-than-2-fingers/65699/12 "2025-04-07T11:58:28Z")

</div>

Don’t worry about contributing to the repo - I’m planning to look at this issue alongside the Android safe-display-area updates. I still can’t promise a release date for this work, but it’s on my backlog.

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [June 9, 2025, 12:12pm UTC](https://forum.juce.com/t/android-mouse-events-are-missing-touches-getting-stucked-for-more-than-2-fingers/65699/13 "2025-06-09T12:12:21Z")

</div>

Thanks for your patience. We’ve now pushed a change to handle ACTION\_CANCEL correctly:

> <https://github.com/juce-framework/JUCE/commit/1741f6df29c40ae9c5c64b75ee8570380742bf0f>

Please let us know if you’re still seeing problems with this change applied.
