I suggest FreePIE, or other free alternatives
there is also Gopher which already supports xinput and toggle on/off, by /u/Tizaki
I made a mouse control script for FreePIE and GlovePIE, and can modify it to support xinput and for switching on and off using a button combo
more alternatives I have not tried but may be easier to use: J2K and antimicro
~~I feel like checking our J2K now to see if it can toggle configurations using the controller~~ edit: it only controls keyboard.
edit: antimicro is easy to use