FCoreDelegates::OnControllerConnectionChange does not work

Hello,

while trying to implement some splitscreen-related functionality I came across this delegate which, if I understand things correctly, can be used to receive a notification when a controller is connected/disconnected. Unfortunately, it didn’t work, and after searching in the source code, it seems this is due to the fact that it isn’t fired anywhere! An online search lead me to the UE 4.5 changelog:

Xbox now fires FCoreDelegates::OnControllerConnectionChange when a controller connection changes.

As I don’t think the delegate is only meant to work on XBox One, are there plans to implement it on other platforms as well?

Thanks!

Indeed, there no broadcast called in source code for this delegate (other then code behind console NDA which i don’t see). Post feature request in feedback forum. I’m not sure if you can implement this delegate in reliable at least in Windows, as desktop OSes usually see controller as just another device without assigning any player IDs in to them, but with Xinput which is made for xbox controllers, there might be the way,

Thanks for your reply! I took a look at XInputInterface, HIDInputInterface and similar files, and it seems controllers are handled in a similar way across most platforms.

There is an array of controllers and each controller is polled each tick to see if it is connected and if there has been any input. From what I can see, controller #0 is considered to be bound to user #0, controller #1 to user #1 and so on. So I guess something like this might work:

void XInputInterface::SendControllerEvents()
{

 .....

const bool bWasConnected = ControllerState.bIsConnected;
ControllerState.bIsConnected = (XInputGetState(ControllerIndex, &XInputState) == ERROR_SUCCESS) ? true : false;

if (ControllerState.bIsConnected != bWasConnected)
{
    FCoreDelegates::OnControllerConnectionChange.Broadcast(ControllerState.bIsConnected, -1, ControllerIndex);
}

Thing is, I’m trying to stay away from modifying the engine code as much as possible as it would greatly complicate my workflow (and I’m not that confident with my C++ skills, too :slight_smile: ). That’s why I asked here if Epic already has plans to fix/implement this feature, which, it seems, is in fact already implemented on XBox One.

If you got ready implementation on your own, why don’t you submit pull request on github? :slight_smile: Polish it up and… just do it! :stuck_out_tongue: