Exemplo n.º 1
0
/**
 * Return the axis determined by the argument.
 *
 * This is for cases where the gamepad axis is returned programatically,
 * otherwise one of the previous functions would be preferable (for example
 * GetLeftX()).
 *
 * @param axis The axis to read.
 * @return The value of the axis.
 */
float Gamepad::GetAxis(AxisType axis)
{
    switch(axis)
    {
        case kLeftXAxis: return GetLeftX();
        case kLeftYAxis: return GetLeftY();
        case kRightXAxis: return GetRightX();
        case kRightYAxis: return GetRightY();
        default:
//            wpi_fatal(BadJoystickAxis);
            return 0.0;
    }
}
Exemplo n.º 2
0
/**
 * Get the direction of the vector formed by the joystick and its origin
 * in radians
 * 
 * @return The direction of the vector in radians
 */
float Gamepad::GetLeftDirectionRadians(){
	return atan2(GetLeftX(), -GetLeftY());
}
Exemplo n.º 3
0
/**
 * Get the magnitude of the direction vector formed by the joystick's
 * current position relative to its origin
 * 
 * @return The magnitude of the direction vector
 */
float Gamepad::GetLeftMagnitude(){
	return sqrt(pow(GetLeftX(),2) + pow(GetLeftY(),2) );
}