You may be able to use autohotkey to listen for a specific keypress, and script to cycle through xpadder or joytokey profiles. Never tried this myself, and a possible concern is whether the re-mappers add lag or do not. It is said that using AutoHotkey itselfe to map buttons slows down button response of those buttons, so you would want to use separate buttons for the switching.
If that doesn't work...
You could go with electrical switching to toggle grounds with four separately wired controls, and map 'OR' inputs for mame 2-player games, map all controls normally for 4-player games. Depending on your setup, you can probably use a three position on/on/on switch between each of the controller sets, simply using the position of the switch lever or slide itself as indication of mode. Alternatively, you could use normal arcade pushbuttons and get fancy with a 4017 to cycle enabling of 4066'es for switching grounds (or even input lines if you need to go without softwares.) The enable lines from the 4017 or excess 4066 switch lines could be used to switch on/off led(s) (lighted pushbuttons for example) as indication of mode. (no sure if GGG or ultimarc, etc make some a piece of hardware which can be used as switching circuit with or without combination with a background script, but such may save you a lot of effort and still yield you this fancy, versatile setup.)
I think SSF4AE can have keyboard and gamepad mappings on at the same time? If this is the case:
You may have to still run a script if using only keyboard encoders. If you are using gamepad encoders for all four sets, you can map one of each per player using joytokey or the like so that it matches the keyboard map in the game, switching off grounds as before to avoid having both sets "live." If you use keyboard encoder for one player one-two controller set, and Gamepad for the alternate set then no scripting would be necessary.