The Joysticks do return a value from -1 to 1, so you can put the values directly into the Jaguars.
If you were looking for a drive system off of one joystick you would use something like this. This could basically is a copy of the old code just usable on the new brain.
NOTE: In the code this year it seems to be easier to just declare all the variables you are going to be using as pointers. This code has also not been completely tested but it should work.
For global variables
Code:
Joystick *controller;
Jaguar *LeftMotor, *RightMotor;
In your constructor
Code:
//This creates a new joystick object to usb1 from the drive station
controller = new Joystick(1);
//Sets the left motor the pwm out 1 and right to pwm out 2
LeftMotor = new Jaguar(1);
RightMotor = new Jaguar(2);
You will need to put this function in the code. All it does is makes sure that the values given to the Jaguars are valid;
Code:
float valid_value(float value)
{
if(value > 1)
return 1;
if(value < -1)
return -1;
return value;
}
Then finally in the teleoperated function you would use
Code:
LeftMotor->Set(valid_value(controller->GetX() - controller->GetY());
RightMotor->Set(valid_value(controller->GetX() + controller->GetY());
Now, if you want to grab button states from the joystick there are two ways to do this. In terms of this example i will use the controller variable declared above.
Code:
controller->GetRawButton(4);
controller->GetButton(Joystick::kTriggerButton)
Both lines return a simple bool state
The first example though returns the state of the button on the controller labeled 4. The second one shows how to use the GetButton function using the constants from the Joystick class.
If you would like to see all the classes in the new code with your project open in windriver look for the project explorer. Inside the project explorer hit the plus next to includes, then look at the files that appear then click the plus next to the one named C:\windriver\vcworks-6.3/target/h/WPIlib
Hopefully that cleared up alot.