5.5.4 - Race condition in FSlateApplication::RegisterNewUser

Whoops, looks like I had actually already caught that the SteamController.cpp OnMotionDetected modification should be using the overload with both UserId and DeviceId and forgot to update the original EPS post with that change, so our builds currently are doing it that way (though we did not have the SonyControllers.h change, so I’m still cherrypicking that one).

That said, that’s definitely on the right track because I manage to reproduce the issue! The repro is simply to plug in an external controller (I used a PS5 controller, but I assume any will work) into a steam deck. Adding some logging reveals that it correctly calls MessageHandler->OnMotionDetected() with UserId = 1 and DeviceId = 1 (as expected since a new controller has been added in addition to the steam deck’s built in one), but by the time it propagates down to FSlateApplication::GetOrCreateUser, UserId is now -1 (and ultimately hits the check outside of shipping/crashes as originally described in shipping).

Essentially, the flow goes:

`FSlateApplication::OnMotionDetected InputDeviceId.GetId() = 1, PlatformUserId.GetInternalId() = 1

FSlateApplication::ProcessMotionDetectedEvent MotionEvent.GetInputDeviceId().GetId() = 1, MotionEvent.GetPlatformUserId().GetInternalId()) = -1

// Uh oh! GetOrCreateUser reads from InputEvent.GetUserIndex() but the InputEvent created in FSlateApplication::OnMotionDetected only specified the InputDeviceId!
FSlateApplication::GetOrCreateUser UserIndex = -1`So with that knowledge, what is the intended behavior here? That the FMotionEvent is also constructed with a UserIndex? That GetOrCreateUser needs to be changed to not directly call GetUserIndex()? Other?