|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Xbox 360 controllers
I am relatively new to java and i was wondering if anyone has gotten a xbox360 controller was using one. If so how do you hook it up? Can you just use the Joystick class in java? and How do you distinguish between axises in java? any answers would be greatly appreciated and I do have a wireless and a wired controller if that makes it easier.
|
|
#2
|
|||||
|
|||||
|
Re: Xbox 360 controllers
We are using a wired Xbox 360 controller in Java with no problems. Just install the drivers on the Classmate, plug it in, and access it using the Joystick class.
For more information, and a mapping of controller axes to Joystick class axes, see: http://www.chiefdelphi.com/forums/sh...threadid=82825 |
|
#3
|
|||
|
|||
|
Re: Xbox 360 controllers
I can get the Xbox360 controller hooked up but actually using it to drive in java with multiple joysticks on the controller and if someone could tell me what buttons are what in java?
But the thing I really don't understand is how you get multiple joysticks on the controller working and pick one to use? |
|
#4
|
|||||
|
|||||
|
Re: Xbox 360 controllers
Read the link in my reply.
Quote:
Code:
Joystick mXboxController = new Joystick(1); // Where "1" is the index of the joystick (you can set this in the Driver Station software). Code:
double axisValue = mXboxController.getRawAxis(2); // Where "2" is the index of the Y axis on the left stick (see above) Code:
boolean buttonPressed = mXboxController.getRawButton(1); // Where "1" is the index of the button reported by the Windows Control Panel "Game Controllers" display |
|
#5
|
|||
|
|||
|
Re: Xbox 360 controllers
Thank you so much this has been a huge help the only thing i need now is the button layout and i can get that
|
|
#6
|
||||
|
||||
|
Re: Xbox 360 controllers
just remember to set a buffer b/c the sticks are waay too sensitive
|
|
#7
|
||||
|
||||
|
Re: Xbox 360 controllers
Specifically, the sticks don't return to the same position when you let go, so you'll want to program in a small (10 in each direction) deadband so that you don't have crawling robots.
|
|
#8
|
|||
|
|||
|
Re: Xbox 360 controllers
and how exactly do you set that in the code
|
|
#9
|
||||
|
||||
|
Re: Xbox 360 controllers
I'm not sure on the FRC specifics, but assuming a range of 0-255 with 127 being the middle (I dunno if that's how Xbox joysticks are defined so adjust accordingly)... just if (xBox < 140 || xBox > 110) { return 127;} or something like that.
|
|
#10
|
|||
|
|||
|
Re: Xbox 360 controllers
How can you use the left stick on the xbox controller to program an arcade drive on Java? Furthermore, how can you take input from the bumpers and the X,Y,B, and A buttons? Any sample code would be appreciated.
|
|
#11
|
||||||
|
||||||
|
Re: Xbox 360 controllers
Do you understand how to program an acrade drive with a joystick? Do you understand how to read a button from a joystick?
|
|
#12
|
||||
|
||||
|
Re: Xbox 360 controllers
Quote:
|
|
#13
|
|||
|
|||
|
Re: Xbox 360 controllers
I am familiar with programming a tank drive, but I am unsure of how to program an arcade drive with a joystick. I know how to read joystick input from the xbox controller, but I am still slightly confused about how to read input from the letter buttons on an xbox controller.
|
|
#14
|
||||
|
||||
|
Re: Xbox 360 controllers
Also, there are some example code posts here on CD. I'll link to one post where there is some example Java code to get you pointed in the right direction on how to program your Arcade drive. Great thread
|
|
#15
|
||||
|
||||
|
Re: Xbox 360 controllers
In Java, you would need some kind of control loop.
Code:
if(Math.abs(xboxControler.getRawAxis(2)) > .1)
{
//do something
}
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Xbox 360 controller | viper110110 | Programming | 7 | 02-18-2010 07:58 PM |
| Logitech or Xbox 360 Controllers? | JohnFogarty | Programming | 11 | 02-08-2010 10:51 PM |
| XBox 360 | Joe Matt | Chit-Chat | 83 | 11-29-2005 03:18 PM |
| Xbox 360 | zdeswarte | General Forum | 1 | 05-11-2005 02:53 PM |