I found a few existing options in Phaser. The first is the beautiful and well-designed Virtual Joystick Plugin, but it costs $16. The next is an implementation of a Virtual Gamecontroller that creates a d-pad using buttons, which is useful, but lacks the analog nature of a true joystick. Finally, I found Eugenio Fage’s Touch Control Plugin.
To use the joystick, press down with your finger/thumb/mouse over the joystick area, and the “pad” should follow your pointer (out to a certain distance from the joystick’s center). The direction, rectangular, and polar properties should update accordingly. The button on the right should be fairly self-explanatory. A game using the Virtual Gamepad plugin just needs to poll the joystick and button’s properties on every update.
The most recent source code for the Virtual Gamepad plugin can be found on GitHub: https://github.com/ShawnHymel/phaser-plugin-virtual-gamepad/
A playable demo of the Virtual Gamepad in action can also be found on GitHub: http://shawnhymel.github.io/phaser-plugin-virtual-gamepad/