As someone who has actually done some game development, it's determined by whether the developer put in code to read controller input and respond to it.
For example, a game uses SDL will (typically) have a loop that looks for SDL events, which typically include keyboard and mouse input; to include controller support, the game must initialize the joystick API on boot, then open the joystick, then add code to handle each gamepad event, typically by doing the same thing that it would to a corresponding keyboard event.
In Godot, there is a tab in the project settings that allows controller mappings to be set and given names. For example, there's "ui_confirm", which, by default, is mapped to the space bar on the keyboard and to 'A' on an XBox 360 controller. The game just then needs to check for events like 'ui_confirm' rather than checking for the individual key presses, and it will have controller support by default. (Note that this basic controller support doesn't use the analog stick.)
There also exist utilities (I've seen references to something called joy2key if you're on Windows, and I remember using one on Linux whose name I don't remember) that will map game controller input to keyboard input. I've managed to play Guacamelee! that way when the controller wasn't working with the game for whatever reason. (Note that Guacamelee! is an example of a game that needs a controller to play comfortably, due to ow you get many moves that require multiple buttons to be pressed at once, and often have to use multiple such moves in the middle of a jump.)
Edit: I believe the Linux utility I used was called qjoypad.
Post edited August 23, 2022 by dtgreene