[IOS] MidiKeyboard Multitouch ISSUE (Regression)

I noticed while updating juce that the midi keyboard does not support multi touch anymore. (confirmed with the juce demo app).
While few fingers are down and dragging, the wrong position is sent to updateNoteUderMouse leading to an unexpected behavior

void MidiKeyboardComponent::timerCallback()
{
    if (shouldCheckState)
    {
        shouldCheckState = false;

        for (int i = rangeStart; i <= rangeEnd; ++i)
        {
            bool isOn = state.isNoteOnForChannels (midiInChannelMask, i);

            if (keysCurrentlyDrawnDown[i] != isOn)
            {
                keysCurrentlyDrawnDown.setBit (i, isOn);
                repaintNote (i);
            }
        }
    }

    if (shouldCheckMousePos)
    {
        for (auto& ms : Desktop::getInstance().getMouseSources())
            if (ms.getComponentUnderMouse() == this || isParentOf (ms.getComponentUnderMouse()))
                updateNoteUnderMouse (getLocalPoint (nullptr, ms.getScreenPosition()), ms.isDragging(), ms.getIndex());
    }
}

I did not have the time to look on how to fix it but it seems that this code is not returning what it should, the mouse position should not call MouseInputSource::getCurrentRawMousePosition(); on iOS, because position changes according to the touch ID.

Point<float> MouseInputSourceInternal::getRawScreenPosition() const noexcept
{
    return unboundedMouseOffset + MouseInputSource::getCurrentRawMousePosition();
}

Before the code was using a local position calculated for each touch :

Point<float> getRawScreenPosition() const noexcept
{
    return unboundedMouseOffset + (inputType != MouseInputSource::InputSourceType::touch ? MouseInputSource::getCurrentRawMousePosition()
                                                                                         : lastScreenPos);
}

Thanks for reporting, this should be fixed here:

1 Like