I am currently working on a Raspberry Pi project, and found an amazing feature that I used many times on my LineageOs phone: Usb Gadget.
I figured I could change the function of the Usb port to act as another one, using the RPi Zero as well. However, a project I am undergoing requires it to act as both a usb gadget (Ethernet-over-USB) and a usb host (To mount a usb drive for example).
Now, I do realize that the RPi does only have one usb port (OTG), so I was wondering if by any chance, it was possible, with the means of a usb hub, to make the RPi use both functions. Maybe not all usb hubs support the feature?
I did a bit of research and I thought of an idea. So far, I have managed to make both functions work, but not simultaneously (Couldn't enable the gadget through the usb hub). It would be better if they worked simultaneously, but it's alright if at least, I can connect a usb drive, the RPi as a host, and connect the RPi to my pc right after (without a reboot or an access to the shell).
Maybe, the RPi could: when a device gets connected, before doing anything, check what is the connected device; If it is my pc, load the driver with configFs/GadgetFs, and create a usb gadget. If it is a usb device (such as a Usb drive), then leaves it as it is.
Edit: Ask me if you need to know anything else, too.