How to get the correct binding index depending on the device you are using?

I’m trying to get the correct binding index to be able to rebind it. The problem is that I also want controller support. How can I get the correct binding index if I’m using a controller or a keyboard to later be able to rebind it? I’m using the C# generated class.

I decided to go with a different approach and its working. I’m now using the player input component.