See repro steps
Steps to Reproduce
Tick ‘Skip Assigning Gamepad to Player 1’ in project settings.
Define a user widget and override ‘On Key Down’ to print out the value of GetUserIndex from the Key Event that is passed in
Run the game, ensuring the widget is displayed and has input focus.
Press a button on the controller
Expected:
The User Index will be 1, since the controller is assigned to player 1
Actual:
The User Index is 0
Hello [mention removed],
Thanks for the report, I’ve reproduced the behavior you’re describing in UE 5.4. After reviewing the engine source code, I found that the ‘Skip assigning gamepad to player 1’ setting (internally bOffsetPlayerGamepadIds) is only applied during UGameViewportClient::RemapControllerInput.
This logic updates the InOutEventArgs.InputDevice during OnKeyUp (release), which means the FKeyEvent::GetUserIndex() value you access during OnKeyDown doesn’t reflect the remapped index.
As a workaround, if you’re trying to check whether the gamepad input should be routed to Player 1, you can use the same condition that RemapControllerInput uses internally:
if (NumLocalPlayers > 1 && InOutEventArgs.Key.IsGamepadKey() && GetDefault<UGameMapsSettings>()->bOffsetPlayerGamepadIds) { }
This gives you a reliable way to infer the intended target of the input.
Please let me know if this information helps.
Best,
Francisco
Hi,
Thanks for the info. It seems like at least from blueprint I get the wrong user id from both key down and key up - in both cases I see the remap code get hit only after the blueprint has returned unhandled. Is there an unreal bug number for this or some ETA for a fix? I will try your workaround in the meantime.
Thanks, James
Hello [mention removed],
After digging into the engine, this appears to be expected since the UGameViewportClient::RemapControllerInput method modifies FInputKeyEventArgs.ControllerId and InputDevice. These values are not propagated to FKeyEvent and do not affect the UserIndex property.
[Image Removed]The GameViewportClient class can actually broadcast the updated EventArgs through the OnInputKeyEvent delegate. However, this only occurs if the bIgnoreInput flag is set to false.
`RemapControllerInput(EventArgs);
…
if (IgnoreInput())
{
return ViewportConsole ? ViewportConsole->InputKey(EventArgs.InputDevice, EventArgs.Key, EventArgs.Event, EventArgs.AmountDepressed, EventArgs.IsGamepad()) : false;
}
OnInputKeyEvent.Broadcast(EventArgs);`Based on the engine source, UserIndex is set during construction and not expected to be changed at runtime.
`/**
- Constructor. Events are immutable once constructed.
- @param InKeyName Character name
- @param InModifierKeys Modifier key state for this event
- @param bInIsRepeat True if this key is an auto-repeated keystroke
*/
SLATECORE_API FKeyEvent(const FKey InKey,
const FModifierKeysState& InModifierKeys,
const uint32 InUserIndex,
const bool bInIsRepeat,
const uint32 InCharacterCode,
const uint32 InKeyCode
);`I coudn’t find any existing bug report tracking this issue and it may be considered “by design”. Unfortunately, at this moment I also cannot provide any ETA on whether this will be changed or addressed in a future release.
Please let me know if this helps.
Best,
Francisco