2 Axises 1 Degree?

I’m using Jinput and I’m trying to learn how to use my controllers joysticks. Now each one seems to give me two axises but I don’t know how to turn the axis numbers uinto a degree. Can anyone please help me?

I believe Component#getPollData gives you a float between -1 and 1. Joysticks don’t know about degrees, just percentage of maximum deflection.

FWIW, here is a class I use for an Xbox 360 controller:
http://code.google.com/p/pg3b/source/browse/trunk/Java/src/com/esotericsoftware/controller/input/JInputXboxController.java
Maybe you can make some use of it or borrow some code. Other classes in that project can access the Xbox controller through the XInput Windows API.

Alright, Thanks :slight_smile: I think I got it: (Math.toDegrees(Math.atan2(-axisa2, axisa1)) + 180)

is the same as

Math.toDegrees(Math.atan2(axisa2, -axisa1))

Also

C2 = A2 + B2

Gives you how far the stick is tilted in its current direction.

dist = sqrt(axisx * axisx) + (axisy * axisy)

See, high school math is useful in the real world…