-
Notifications
You must be signed in to change notification settings - Fork 5
Attack3 Legacy Code
egordon edited this page Jan 8, 2013
·
1 revision
##Attack3 C++ Code ###Attack3.h
#ifndef ATTACK3_H_
#define ATTACK3_H_
#include "Joystick.h"
#include "WPILib.h"
/**
* Class designed to interface with an Attack3 joystick.
* This class was designed to allow better definition of the joysticks
* in the source code of a program since now the class would be named
* with the joystick type.
*
* This class uses the Joystick class to interface with the Drivers Station
* to get the input from the joystick.
*/
class Attack3 : public Joystick
{
public:
explicit Attack3(UINT32 port);
float GetTwist();
float GetX();
float GetY();
float GetZ();
float GetThrottle();
JoystickButton* GetButton(int button);
};
#endif
###Attack3.cpp
#include "Attack3.h"
#include <Joystick.h>
/**
* Construct an instance of a Logitech Attack3 joystick (The kind in the KoP).
*
* @param port The port on the driver station that the joystick is plugged into.
*/
Attack3::Attack3(UINT32 port) : Joystick(port)
{
//Do Nothing
}
/**
* Return the value of the Twist axis for this joystick
* This value is always 0 since there is no twist axis.
*
* @return 0 since there is no twist axis
*/
float Attack3::GetTwist()
{
return(0); //Return 0 since there is no twist axis
}
/**
* Return the value of the Z axis for this joystick
* This value is always 0 since there is no Z axis.
*
* @return 0 since there is no Z axis
*/
float Attack3::GetZ()
{
return(0); //Return 0 since there is no Z axis
}
/**
* Get the X value of the joystick.
* The right side of the axis is positive.
*
* @return The current X value of the joystick between -1 and 1
*/
float Attack3::GetX()
{
return(Joystick::GetX());
}
/**
* Get the Y value of the joystick.
* The forward part of the axis is negative.
*
* @return The current Y value of the joystick between -1 and 1
*/
float Attack3::GetY()
{
return(Joystick::GetY());
}
/**
* Get the Throttle value of the joystick.
* The top part of the axis is negative.
*
* @return The current Throttle value of the joystick between -1 and 1
*/
float Attack3::GetThrottle()
{
return(Joystick::GetThrottle());
}
/**
* Get a JoystickButton for the Command Subsystem OI Class
*
* @return JoystickButton Pointer
*/
JoystickButton* Attack3::GetButton(int button)
{
return(new JoystickButton(this, button));
}