code/WPILib/DriverStation.cpp
/**
 * Get the value of the axis on a joystick.
 * This depends on the mapping of the joystick connected to the specified port.
 * 
 * @param stick The joystick to read.
 * @param axis The analog axis value to read from the joystick.
 * @return The value of the axis on the joystick.
 */
Get the value of the axis on a joystick.
This depends on the mapping of the joystick connected to the specified port.

@param stick The joystick to read.
@param axis The analog axis value to read from the joystick.
@return The value of the axis on the joystick.
Get the value of the axis on a joystick . This depends on the mapping of the joystick connected to the specified port . @param stick The joystick to read . @param axis The analog axis value to read from the joystick . @return The value of the axis on the joystick .
float DriverStation::GetStickAxis(UINT32 stick, UINT32 axis)
{
	if (axis < 1 || axis > kJoystickAxes)
	{
		wpi_fatal(BadJoystickAxis);
		return 0.0;
	}
	INT8 value;
	switch (stick)
	{
		case 1:
			value = m_controlData->stick0Axes[axis-1];
			break;
		case 2:
			value = m_controlData->stick1Axes[axis-1];
			break;
		case 3:
			value = m_controlData->stick2Axes[axis-1];
			break;
		case 4:
			value = m_controlData->stick3Axes[axis-1];
			break;
		default:
			wpi_fatal(BadJoystickIndex);
			return 0.0;
	}
	float result;
	if (value < 0)
		result = ((float) value) / 128.0;
	else
		result = ((float) value) / 127.0;
	wpi_assert(result <= 1.0 && result >= -1.0);
	if (result > 1.0)
		result = 1.0;
	else if (result < -1.0)
		result = -1.0;
	return result;
}
float DriverStation :: GetStickAxis ( UINT32 stick , UINT32 axis ) { if ( axis < 1 || axis > kJoystickAxes ) { wpi_fatal ( BadJoystickAxis ) ; return 0.0 ; } INT8 value ; switch ( stick ) { case 1 : value = m_controlData -> stick0Axes [ axis - 1 ] ; break ; case 2 : value = m_controlData -> stick1Axes [ axis - 1 ] ; break ; case 3 : value = m_controlData -> stick2Axes [ axis - 1 ] ; break ; case 4 : value = m_controlData -> stick3Axes [ axis - 1 ] ; break ; default : wpi_fatal ( BadJoystickIndex ) ; return 0.0 ; } float result ; if ( value < 0 ) result = ( ( float ) value ) / 128.0 ; else result = ( ( float ) value ) / 127.0 ; wpi_assert ( result <= 1.0 && result >= -1.0 ) ; if ( result > 1.0 ) result = 1.0 ; else if ( result < -1.0 ) result = -1.0 ; return result ; }
Get the value of the axis on a joystick.
Get the value of the axis on a joystick .