How does Supermodel 3 determine mouse assignments?

I'm sure we're all aware of supermodel 3 reassigning mouses (light guns) after each reboot (not emulator start!). This of course requires the user to figure out what their light guns are set to every boot and reconfigure the bindings every time. I also understand that windows doesn't uphold any ordering either.
What I'm hoping for is that someone can help me determine HOW supermodel 3 determines its mouse assignments. I'd like to know this so that I can replicate it, and then programmatically update my config accordingly at startup.
This is important because friends and family who pick up my guns often find that the sm3 light gun games aren't working and it feels "bad", and it's unfeasible for me to be around and spend 5 minutes changing the config each time.
What I'm hoping for is that someone can help me determine HOW supermodel 3 determines its mouse assignments. I'd like to know this so that I can replicate it, and then programmatically update my config accordingly at startup.
This is important because friends and family who pick up my guns often find that the sm3 light gun games aren't working and it feels "bad", and it's unfeasible for me to be around and spend 5 minutes changing the config each time.