Enhanced input feature not working properly when switching active input contexts

The problem is about a feature of the EnhancedInput system about ignoring pressed keys till release, specifically when changing active contexts and mappings are rebuilt.(FModifyContextOptions::bIgnoreAllPressedKeysUntilRelease).

In our use case, we have an input context always active, containing an input action IA_Test with trigger Pressed (which should therefore trigger only once till is pressed down).

When removing/adding another input context, while the pressed action has already triggered (IA_Test associated input is kept down the whole time and never released), the action gets re-triggered. even if the flag bIgnoreAllPressedKeysUntilRelease is set true.

From internal tests, results is that a flag value is being lost in the process of recreating mappings of active contexts, specifically in IEnhancedInputSubsystemInterface::RebuildControlMappings, when the flag bShouldBeIgnored of mapping may be lost; a fix has been proposed in the attached image, adding the following snippet just under fix labeled “Fix for UE-270589”, to keep flag value consistent.

This should prevent the bug and ensure the feature works properly.

OldMappings[Idx].bShouldBeIgnored = Mapping.bShouldBeIgnored;

immagine.png(44.5 KB)
TP_Blank.zip(24 MB)

Steps to Reproduce

Compile / Open the attached project

Start play

Focus viewport (mouse click)

Keep T pressed for wrong behavior (input action keeps re-triggering)

Keep R pressed for expected behavior (input action trigger only once)

Hey there!

Thank for you for the details bug report and repro project. There is an existing ticket about this (I actually just made it in response to another user last week) here: https://issues.unrealengine.com/issue/UE\-372464

I will add your proposed fix and details to it for consideration.

Your fix does seem like it would work and be safe to use, but if you are interested, [this is the other post where the user also has another work [Content removed]

Thanks again!

Ben

Hi, sorry for the late answer.

We took a look at some of your latest CL about Enhanced Input (52794595, 52691399, 52794904, 52814764, 52871676) and the original bug we had seems to not reproduce anymore.

I’m not sure about the side-cases but i would consider the matter solved with those changes.

Thanks,

Ivan.

Great! I’m glad that worked out. I will mark this issue as closed then.

Thanks again for the bug report!