Page 1 of 1

Angle of gamepad stick

Posted: Sun May 13, 2012 8:50 am
by Arthes
Hi.
How to get the angle of gamepad stick?
Thanks for replies.

Re: Angle of gamepad stick

Posted: Sun May 13, 2012 11:01 am
by McPandaBurger
is this a ps3 pad by any chance? I'm having the same issue if it is, see here incase anything so far helps you, I'm totally stumped but you might crack it.

viewtopic.php?f=4&t=9192

Re: Angle of gamepad stick

Posted: Sun May 13, 2012 11:13 am
by bartbes
It doesn't have an angle, it has two axes (per stick), an x and a y axis.

Re: Angle of gamepad stick

Posted: Sun May 13, 2012 12:05 pm
by Arthes
No, I have a Xbox 360 controller.

Re: Angle of gamepad stick

Posted: Sun May 13, 2012 2:38 pm
by 10$man
Arthes wrote:Hi.
How to get the angle of gamepad stick?
Thanks for replies.
You wouldn't read the analogs as an angle, unless your talking about which direction your pushing the analog stick in.
If that's the case you could do something like this:

Code: Select all

math.atan2((deadzone.y - current_position.y), (deadzone.x - current_position.x))
deadzone is the neutral point that the analog rests at.
current_position is the read you get from the analog. If it's in the deadzone then deadzone and current_position will cancel out.
Hope I helped :)

Re: Angle of gamepad stick

Posted: Sun May 13, 2012 6:36 pm
by bartbes
Arthes wrote:No, I have a Xbox 360 controller.
bartbes wrote:It doesn't have an angle, it has two axes (per stick), an x and a y axis.
I'm not quite sure how you think they work, but they work like I said it. If you want an angle, you'd better calculate it yourself.