a simple solution to this is to create a menu before the play game, and give the user a list to select its controllers.
for example before start game
list appears with keyboard+mouse | mobile | controller.
user selects the prefered input and only that controlling code should be active during gameplay.
if he wants to change controls can go to settings for example (u have to code that), and select other input method.
this way u avoid saving inputs into variables. u just save a global variable call it controls, and give it value 1 for mouse+keyboard | value 2 for mobile| value 3 for controllers, then on start of game layout if value is 1 then activate group for events used to use the inputs for mouse+keyboard if its 3 then use controllers group input.