Basically, Gamepad Face Down is treated like a left click, but in some cases this is annoying, for example when you want an InputKeySelector to detect Gamepad Face Down itself and not a left click while rebinding.
Create a custom action router and analog cursor to control when the gamepad Confirm (face button bottom / X) simulates a left mouse click.
1. Create a custom Action Router
Create a child class from UCommonUIActionRouterBase, for example:
UCustomCommonUIActionRouterBase
Add a member variable:
bool bEnableLeftClickBehavior = false;
Expose two Blueprint-callable functions:
UFUNCTION(BlueprintCallable, Category = "UI|Input")
void SetEnableLeftClickBehaviorActive(bool bActive);
UFUNCTION(BlueprintCallable, Category = "UI|Input")
bool IsLeftClickBehaviorActive() const;
Override MakeAnalogCursor() to use your custom cursor:
TSharedRef<FCommonAnalogCursor> UCustomCommonUIActionRouterBase::MakeAnalogCursor() const
{
CustomAnalogCursor = FCommonAnalogCursor::CreateAnalogCursor<FCustomCommonAnalogCursor>(*this);
return CustomAnalogCursor.ToSharedRef();
}
2. Create a custom Analog Cursor
Create a class that inherits from FCommonAnalogCursor:
FCustomCommonAnalogCursor
Override ShouldVirtualAcceptSimulateMouseButton():
bool FCustomCommonAnalogCursor::ShouldVirtualAcceptSimulateMouseButton(
const FKeyEvent& InKeyEvent,
EInputEvent InputEvent) const
{
const UCustomCommonUIActionRouterBase* MyRouter =
Cast<UCustomCommonUIActionRouterBase>(&ActionRouter);
if (MyRouter && !MyRouter->IsLeftClickBehaviorActive())
{
return false;
}
return FCommonAnalogCursor::ShouldVirtualAcceptSimulateMouseButton(InKeyEvent, InputEvent);
}
3. Usage
When you need to bind the gamepad face button bottom (X), for example while using an Input Key Selector, simply call:
SetEnableLeftClickBehaviorActive(false);
Re-enable it afterward if needed.
This prevents CommonUI from treating the Confirm action as a virtual left mouse click during rebinding or other specific UI flows.