I am using a gamepad to control the movement and direction of my sprite.
My problem is that when I let go of the analog stick, my character turns to a random angle.
This is how I am determining the angle of my sprite:
r = Math.PI / 2 + Math.atan2(gamepad.getYLeft(), gamepad.getXLeft());
So what library are you using for the gamepad ? they have usually functionality for this.
Although I can say, it often happens due to overused controllers... my ps2 controller will do the same in every game, I have to fiddle around