As with many things Apple, this issue is an entitlement, and you can find some documentation of all possible MacOS entitlements here.
Specifically, once your app is signed it's trapped in a sandbox environment, and the only light filters through gaps provided by those entitlements. In the case of a gamepad, we're talking either USB (wired) or Bluetooth (wireless). This means you'll want to add this to your MacOS app's entitlement file:
Do that, rebuild, re-sign, and you should have working controllers in your build.