I *think* this might work Theil:

temp.x = mouse_pos.x;
temp.y = mouse_pos.y;
temp.z = me.z;
vec_for_screen(temp,camera);
vec_sub(temp,me.x);
vec_to_angle(me.pan,temp)

Give it a try and let me know if it works for you