![]() |
How do you use X-Box 360 controllers in C++?
We want to use either an X-Box controller or a PS3 controller to control out non-drive operations like arm control. The only problem is that we can't find the C++ code for how to use them. Any help would be greatly appreciated.
|
Re: How do you use X-Box 360 controllers in C++?
There have been a lot of threads about that, you should check it out, and team 2202 also made a class for it. Here are a some links to their documentation.
http://coolhub.imsa.edu/cybercollab/...i/Main/Xbox360 http://coolhub.imsa.edu/cybercollab/...4y/view/157916 I have never tried it out, but it seems fun. Tell me how it works out for you, because I want to try it out during off-season. Just google "Xbox controller chief delphi" and you should get a lot of CD threads. Read them over if you would like.:D |
Re: How do you use X-Box 360 controllers in C++?
if i was you i would use something else.
|
Re: How do you use X-Box 360 controllers in C++?
We have been using an XBox controller. Any Game Controller that can be recognized by Windows can be used for input. You can use a PS3 controller but you have to download drivers that may or may not work in competition.
First, construct a new Joystick object: Code:
Joystick j1 (1)You can then use the Joystick API to retrieve button and axis states. Some people like using the built in getter methods like j1.getX() but I just like calling j1.GetRawAxis(1). Here's a basic guide to the axises: 1: Left Stick X 2: Left Stick Y 3: Triggers (Pulling the Right Stick returns .5-1, Pulling the left stick is 0-.5, neutral is .5) 4: Right Stick X 5: Right Stick Y You can also run j1.GetRawButton(int button) which returns bool (true means the button is pressed down). I don't remember off the top of my head what the buttons map to, but in your driver station you can: Click Windows + R > type in joy.cpl > Click on the properties of the Xbox Controller > Watch the numbers light up as you press the buttons. I know pressing A will make "Button 1" light up. This means running j1.GetRawButton(1) will return true when pressed down. |
Re: How do you use X-Box 360 controllers in C++?
Quote:
|
Re: How do you use X-Box 360 controllers in C++?
Any HID (Human Input Device) compliant joysticks can be used. XBox 360 game controllers have two joysticks, a D-pad and a number of buttons. The joystick portion is the same as any other joysticks or game controllers. However, the button mappings are different. Here is the button map I used:
Code:
#define Btn(n) (1 << (n)) |
Re: How do you use X-Box 360 controllers in C++?
Quote:
|
Re: How do you use X-Box 360 controllers in C++?
Quote:
I think this is what you want: http://coolhub.imsa.edu/cybercollab/...ming-documents |
Re: How do you use X-Box 360 controllers in C++?
Any one know what the custom math file is...anyone....?
|
Re: How do you use X-Box 360 controllers in C++?
I scanned through the code in the Xbox360 class and didn't really find any reason for needing any custom math. The only methods that need some math are to return the joystick values in polar coordinates instead of the cartesian coordinates (i.e. returning magnitude/angle instead of returning X and Y). There are two things you can do:
Code:
#define MAGNITUDE(x,y) sqrt(pow(x, 2) + pow(y, 2)) |
Re: How do you use X-Box 360 controllers in C++?
|
Re: How do you use X-Box 360 controllers in C++?
i have a pnp-ready xbox class with a dead-zone if anyone wants it
|
Re: How do you use X-Box 360 controllers in C++?
that pnp-class would be a awesome:D
thank you everyone for responding:) |
Re: How do you use X-Box 360 controllers in C++?
its in java, but here goes:
Code:
package com.robototes.abomasnow; |
| All times are GMT -5. The time now is 10:19 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi