Son of a bitch.
Okay, so two PFETs back to back with their drains connected, and the supply line for my 3.3V regulator connected between them.
If ID or uC is LOW, both the gates of both FETs need to be pulled LOW so they're ON and Vin can supply the USB.
(And yes, I am aware that supplying a USB device with less than 5V is bad, this feature will only be used when Vin is supplied with 5V.)
If USB is HIGH, pull Vin FET gate HIGH to turn it OFF, so USB won't backfeed battery.
Except... USB can be HIGH if it's being fed from Vin. So I can't switch the Vin FET on or off based on the USB voltage level alone.
I guess I need to use the state of the USB FET's gate to set the state of the Vin gate?
Hm...
If USB is LOW, pull Vin FET gate LOW to turn it ON?
Hm... I'm not sure if I'll be able to figure out how to make that work, but if that won't work, I could try reversing things, so if Vin is powered, the USB won't power the circuit, and it's only connected if ID or uC pin is LOW, stating that the USB should be powered from Vin. This might be easier. Plus... if the device requires more than 500mA having Vin be the primary supply would allow the device to be powered properly even when being programmed. (Though that's an unlikely circumstance.)
Also I wish the forum would stop timing out on me while I'm in the middle of typing my replies. :/