Angle of gamepad stick

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Arthes
Prole
Posts: 10
Joined: Fri Dec 30, 2011 10:52 am

Angle of gamepad stick

Post by Arthes »

Hi.
How to get the angle of gamepad stick?
Thanks for replies.
User avatar
McPandaBurger
Prole
Posts: 16
Joined: Sat Apr 28, 2012 3:32 pm

Re: Angle of gamepad stick

Post 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
I have no idea what I'm doing
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Angle of gamepad stick

Post by bartbes »

It doesn't have an angle, it has two axes (per stick), an x and a y axis.
Arthes
Prole
Posts: 10
Joined: Fri Dec 30, 2011 10:52 am

Re: Angle of gamepad stick

Post by Arthes »

No, I have a Xbox 360 controller.
10$man
Citizen
Posts: 77
Joined: Sun Apr 22, 2012 10:40 pm

Re: Angle of gamepad stick

Post 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 :)
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Angle of gamepad stick

Post 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.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 226 guests