UE5.3.2 Touch Input Action Bug?

I set up a fairly simple touch input action that triggers on Touch1 Hold for mobile devices, and an equivalent one for a mouse click that triggers on LMB Hold. In C++ I mapped four different functions that fire on Triggered and Completed for touch and mouse clicks respectively, to be sure there were no competing inputs. For the mouse clicks, everything works as expected. If I click rapidly, the “Triggered” never fires because the hold time threshold is never met. The hold timer restarts with every click, and does not “accumulate” with each successive click.

On mobile devices, or with “Use Mouse for Touch” set to true, it’s a different story. The first time I touch, the “Ongoing” state shows the hold time accumulating. When I release my finger, I expect that to register as a “canceled” action, and placing my finger on the screen would restart the hold timer. Instead, “Ongoing” picks up from where the previous touch started, so if I rapidly touch the screen, the timer threshold accumulates between presses until the action triggers. My functions still fire on Triggered and Completed, but the Ongoing status never resets, and further touches are triggered immediately, and completely ignore the hold time.

With “cmd:showdebug enhanced input” active, before the Hold timer is exceeded and the “Triggered” event fires, Touch 1 looks like it’s null (as I would expect since I’m not touching anything):
image
After the Hold Threshold is exceeded, “(true)” shows after Touch 1, even after Completed fires, and the Hold Threshold is no longer respected; every touch, no matter how short, immediately fires the Triggered Event from that moment forward.
image
That “(true)” stays active until I click a UI button. Then “(true)” disappears, and the Hold Threshold is reset.
It’s possible I’m misunderstanding something, and there is some fundamental difference between the way touch input is interpreted vs a mouse click, but in my mind they both only have two states, pressed and released, so I would think their events would fire in the same way.

5 Likes

Currently having the same issue, Hold key duration is not reset after initial trigger.

1 Like

Yeah that’s a shame. Are they any other Possibles to make an hold input on mobile?

The issue is still here in UE 5.4.1

After looking at the code, the problem seems to be, basically, that the action value for keys and buttons is 0 when they are released, while the Touch still keeps the value of the screen location on release, making the “IsActuated” function in the InputTrigger return true in the transition.

I’ve managed to do a workaround creating a child class from EnhancedPlayerInput and overriding the EvaluateKeyMapState function, then setting it in “ProjectSettings->Input->Default Classes->Default Player Input Class”.

The code is simple:

.h

#pragma once

#include "CoreMinimal.h"
#include "EnhancedPlayerInput.h"
#include "MyPlayerInput.generated.h"

/**
 * 
 */
UCLASS()
class MYGAME_API UMyPlayerInput : public UEnhancedPlayerInput
{
	GENERATED_BODY()
	
protected:
	virtual void EvaluateKeyMapState(const float DeltaTime, const bool bGamePaused, OUT TArray<TPair<FKey, FKeyState*>>& KeysWithEvents) override;
};

.cpp

void UMyPlayerInput::EvaluateKeyMapState(const float DeltaTime, const bool bGamePaused, OUT TArray<TPair<FKey, FKeyState*>>& KeysWithEvents)
{
	for (TPair<FKey, FKeyState>& KeyPair : GetKeyStateMap())
	{
		FKeyState& KeyState = KeyPair.Value;
		if (KeyPair.Key.IsTouch() && !KeyState.bDown)
		{
			KeyState.RawValue = FVector::ZeroVector;
		}
	}

	Super::EvaluateKeyMapState(DeltaTime, bGamePaused, KeysWithEvents);
}

I’m pretty sure that there has to be a better place to make the fix (“InputTouch” function is a good candidate but it’s not virtual… ) but with this I got the same behaviour in the triggers with the touches and the buttons/keys.

Have into account, though, that the value with touches is different than with keys, this means that the “Actuation Threshold” works but it has a different “meaning”.

2 Likes

This definitely needs to be fixed ASAP. So annoying that I need to create a workaround for this in touch when it works perfectly fine for KB&M. There at least needs to be a simple equivalent for Touch if this functionality is intended.

3 Likes