View Single Post
  Spotlight this post!  
Unread 25-02-2010, 12:39
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,077
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Xbox 360 controllers

Read the link in my reply.

Quote:
Axis indexes:
1 - LeftX
2 - LeftY
3 - Triggers (Each trigger = 0 to 1, axis value = right - left)
4 - RightX
5 - RightY
6 - DPad Left/Right

Button mapping matches Windows Control Panel>Game Pads display
So you define the Joystick like:

Code:
Joystick mXboxController = new Joystick(1); // Where "1" is the index of the joystick (you can set this in the Driver Station software).
To read an axis (like the left stick Y axis), simply do:

Code:
double axisValue = mXboxController.getRawAxis(2); // Where "2" is the index of the Y axis on the left stick (see above)
To read a button, simply do:

Code:
boolean buttonPressed = mXboxController.getRawButton(1); // Where "1" is the index of the button reported by the Windows Control Panel "Game Controllers" display
Reply With Quote