This can be done much simpler using a vector and the built-in vec_to_angle function. Here come the two lines you need:
Code:
vec_to_angle(my.pan, vector(sign(joy_force.x),sign(joy_force.y),0));
my.pan -= 90; // needed because you want (0,1,0) to result in pan = 0