Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Xbox 360 controllers (http://www.chiefdelphi.com/forums/showthread.php?t=83597)

The Engineer 25-02-2010 11:24

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.

Jared Russell 25-02-2010 11:46

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

The Engineer 25-02-2010 12:03

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?

Jared Russell 25-02-2010 12:39

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

The Engineer 25-02-2010 13:08

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

Robototes2412 25-02-2010 23:55

Re: Xbox 360 controllers
 
just remember to set a buffer b/c the sticks are waay too sensitive

Chris is me 26-02-2010 00:04

Re: Xbox 360 controllers
 
Quote:

Originally Posted by Robototes2412 (Post 928800)
just remember to set a buffer b/c the sticks are waay too sensitive

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.

The Engineer 26-02-2010 11:36

Re: Xbox 360 controllers
 
and how exactly do you set that in the code

Chris is me 26-02-2010 11:44

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.

puneeth.meruva 06-01-2014 14:41

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.

Joe Ross 06-01-2014 18:17

Re: Xbox 360 controllers
 
Quote:

Originally Posted by puneeth.meruva (Post 1322498)
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.

Do you understand how to program an acrade drive with a joystick? Do you understand how to read a button from a joystick?

markmcgary 06-01-2014 18:40

Re: Xbox 360 controllers
 
Quote:

Originally Posted by puneeth.meruva (Post 1322498)
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.

This post with code may help.

puneeth.meruva 10-01-2014 12:07

Re: Xbox 360 controllers
 
Quote:

Originally Posted by Joe Ross (Post 1322648)
Do you understand how to program an acrade drive with a joystick? Do you understand how to read a button from a joystick?

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.

Dustin Shadbolt 10-01-2014 21:20

Re: Xbox 360 controllers
 
Quote:

Originally Posted by Dustin Shadbolt (Post 1325284)
This should be useful to you Puneeth.

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

Pratik Kunapuli 10-01-2014 22:32

Re: Xbox 360 controllers
 
Quote:

Originally Posted by The Engineer (Post 928925)
and how exactly do you set that in the code

In Java, you would need some kind of control loop.

Code:

if(Math.abs(xboxControler.getRawAxis(2)) > .1)
{
    //do something
}

In the above example, the loop checks and makes sure that the value of the stick is above the "dead band" whether it is positive or negative.

puneeth.meruva 10-01-2014 22:44

Re: Xbox 360 controllers
 
thanks for all the help!


All times are GMT -5. The time now is 10:31.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi