Thread: XBox controller
View Single Post
  #1   Spotlight this post!  
Unread 09-12-2012, 12:38
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
XBox controller

Hello!
First of all, let it be said that I am new to robot programming. What I have been trying to do is modify the code below to utilize an xBox 360 controller. I have literally gone through every forum entry with the keyword "xBox" which resulted in nothing more than being lead to other entries and dead links to websites. I have already installed the drivers and tried treating the controller as a typical joystick. If anyone could Help, I would greatly appreciate it! Thanks!
Code:
#include <WPILib.h>

class DefaultRobot : public SimpleRobot
{	
	Joystick *leftStick;			
	Joystick *rightStick;	
			
	RobotDrive *myRobot;	
	
public:

	DefaultRobot(void)
	{	
		leftStick = new Joystick(1);			
		rightStick = new Joystick(2);
		
		myRobot = new RobotDrive(1, 3, 2, 4);

		myRobot->SetExpiration(0.005);
	}

	void Autonomous(void)
	{
		myRobot->SetSafetyEnabled(true);
				
			while(IsAutonomous())
			{
			
			}
				
	}


	void OperatorControl(void)
	{
		myRobot->SetSafetyEnabled(true);
		
		while (IsOperatorControl())
		{	
			myRobot->ArcadeDrive(leftStick);
			Wait(0.001);
		}
	}
};

START_ROBOT_CLASS(DefaultRobot);
Reply With Quote