CommonUI can translate a gamepad confirm action into a virtual left mouse click. During rebinding, an InputKeySelector may therefore receive a mouse click instead of the original gamepad button.
A custom action router and analog cursor can control this translation. The following fragments show the approach; they assume the surrounding class declarations, module dependencies, and includes are already in place.
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();
}
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);
}
Disable translation during rebinding
Before collecting the original gamepad confirm key, disable the simulated click:
SetEnableLeftClickBehaviorActive(false);
Restore the previous setting when rebinding finishes or is canceled. The physical label of the bottom face button depends on the controller; use the input key rather than assuming it is always labeled X.
This prevents CommonUI from treating the Confirm action as a virtual left mouse click during rebinding or other specific UI flows.
Verify both normal menu confirmation and rebinding in the engine version used by the project. These fragments customize input routing; they are not a complete replacement for CommonUI setup.