Java-Gaming.org Hi !
 Featured games (84) games approved by the League of Dukes Games in Showcase (565) Games in Android Showcase (152) games submitted by our members Games in WIP (607) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 2 Axises 1 Degree?  (Read 915 times) 0 Members and 1 Guest are viewing this topic.
CyanPrime
 « Posted 2010-04-30 22:42:37 »

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?
Nate

« JGO Bitwise Duke »

Medals: 164
Projects: 4
Exp: 14 years

Esoteric Software

 « Reply #1 - Posted 2010-05-01 00:12:02 »

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:
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.

CyanPrime
 « Reply #2 - Posted 2010-05-01 02:46:01 »

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

JGO Wizard

Medals: 16
Projects: 19

Mojang Specifications

 « Reply #3 - Posted 2010-05-01 07:43:55 »

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

is the same as

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

Play Minecraft!
JuddMan

Senior Devvie

Medals: 1

 « Reply #4 - Posted 2010-05-01 10:07:15 »

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...
Pages: [1]
 ignore  |  Print

You cannot reply to this message, because it is very, very old.

 Riven (10 views) 2015-04-01 18:27:05 ags1 (27 views) 2015-03-31 10:55:12 theagentd (13 views) 2015-03-27 23:08:20 wxwsk8er (54 views) 2015-03-20 15:39:46 Fairy Tailz (48 views) 2015-03-15 21:52:20 Olo (29 views) 2015-03-13 17:51:59 Olo (33 views) 2015-03-13 17:50:51 Olo (40 views) 2015-03-13 17:50:16 Olo (44 views) 2015-03-13 17:47:07 ClaasJG (61 views) 2015-03-10 11:36:42
 BurntPizza 21x LiquidNitrogen 21x KevinWorkman 18x EgonOlsen 17x theagentd 16x basil_ 16x Roquen 15x Varkas 12x wessles 11x 65K 11x Riven 9x Rayvolution 9x phu004 8x SHC 8x princec 8x Ashedragon 8x
 How to: JGO Wikiby Mac702015-02-17 20:56:162D Dynamic Lighting2015-01-01 20:25:42How do I start Java Game Development?by gouessej2014-12-27 19:41:21Resources for WIP gamesby kpars2014-12-18 10:26:14Understanding relations between setOrigin, setScale and setPosition in libGdx2014-10-09 22:35:00Definite guide to supporting multiple device resolutions on Android (2014)2014-10-02 22:36:02List of Learning Resources2014-08-16 10:40:00List of Learning Resources2014-08-05 19:33:27
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org