Looking at the code, I don't see where the joystick horizontal and vertical values are being used to affect the rotation, but the mouse seems to be affecting rotation currently.
To get it working, I think you just need to add the following under line 29:
ship.rotation = atan2(joystick_vertical, joystick_horizontal)
And then the joystick should be able to rotate the ship. However, it may seem that nothing is working because layer, in line 34, you are setting the rotation based on the mouse position.
Are you trying to have both the mouse and joystick affect rotation? If so, you will almost certainly need some way to tell the code which to use, as the rotation will be overridden by one or the other. For example, if the joystick is moving and the code for rotating to look at the mouse is left as-is, then only one of the two input methods (mouse or joystick) will work and the other will not.