When on USB, charge and deliver data, when not on USB, use battery and bluetooth

There are countless guides on using an Arduino to build an arcade joystick (fightstick). I want to take this a step further to operate like a Xbox controller or smart phone:

  • If joystick is plugged in via USB, it should power and communicate via USB. It should also charge the lithium Ion battery.
  • If joystick is not plugged in, it will power over the battery and send data via bluetooth

Are there any guides on completing a circuit like this? I know adafruit has individual components for bluetooth, charging, etc - but I could use some help on how to achieve the desired functionality with these components.