Show/Hide cursor based on whether a gamepad is being used

I’m modifying the Twin Stick Shooter sample so that you can fire by holding the left mouse button down instead of using the arrow keys. I want to add a crosshair for when you’re using the mouse to fire but hide it if you’re using a gamepad instead.

I tried overriding the InputKey function mentioned at https://answers.unrealengine.com/questions/63515/detect-connected-controller.html but that only ever seems to be called when a keyboard/mouse event is called. So I added an action mapping for every button on the controller as described at https://answers.unrealengine.com/questions/142358/question-is-there-a-way-to-detect-a-gamepad.html

Now, this all more or less works but it’s really messy and I have a feeling there’s a better way of doing all this. Any suggestions?

Since the “Any Key” binding was added in 4.11 you can just bind to that event and pass the supplied key into the “Key Is Gamepad Key” BP node.