Assign controller button to EventSystem Pressed function

I am trying to use a usb Gamepad (NES controller clone) with Unity’s Event System menu navigation. So far everything works with navigating the menu but I cannot actually click on any buttons. On any standard controller, buttonSouth will perform whatever action is on the button, but due to the NES controller’s A and B buttons being mapped to “Button 2” and “Trigger”, it doesn’t press the button by default. I am wondering how to implement support for “Button 2 [usb gamepad]” to execute a button. I am using Unity’s new Input System, and have an Input System UI Input Module attached to my Event System Object.

Thanks in advance!

1 Like

I added a button in input Action that called this function:

void NSubmit() {
     EventSystem.current.currentSelectedGameObject.GetComponent<Button>().onClick.Invoke();
    }

This threw null errors so i added a check

void NSubmit() {
if (EventSystem.current.currentSelectedGameObject != null && EventSystem.current.currentSelectedGameObject.GetComponent<Button>() != null)
     EventSystem.current.currentSelectedGameObject.GetComponent<Button>().onClick.Invoke();
    }

But then realized the reason I got a null error is because I had a dropdown menu in my menu, and call GetComponent is not universal with the dropdown menu’s script.

I’m not sure that I would want to hard code the functionality for the dropdown menu. I am looking for something better integrated into the EventSystem, as on
Xbox Controller it works perfect with every GUI element