It's probably too late to do it at this point, but the Unity Input System package makes controller input so much easier. However, it takes a little bit to figure out how it works as you define controls in a configuration file, then connect them to a PlayerInput component on a game object and link the input to the method to call within that game object's script.
Viewing post in DEVLOG// Burnerknight Studios
I'll definitely need to look into it in the future. What caught me was that I was trying to use a conditional to switch how a variable was used depending on if you had a gamepad connected or not. I tried using the Input.GetJoystickNames but lost time trying to get that to work reliably. So my next step was to use a different solution. I started cutting out code until I got to a functional minimum.
This is what I ended up with:
if(Input.GetAxis("Mouse X") != 0 || Input.GetAxis("Mouse Y") != 0) { tiltAroundY += Input.GetAxis("Mouse Y") + Input.GetAxis("Mouse X"); } else { tiltAroundY += Input.GetAxis("Mouse Y2") + Input.GetAxis("Mouse X2"); }
So if you're using a gamepad, Mouse X and Mouse Y will correspond to the Right Analog stick on the gamepad and allow you to rotate the camera. If you don't have a gamepad, Mouse X and Mouse Y will always be 0, and so therefore the else conditional will run, using the next axis which will work with your mouse.