/**
 * Returns the number of buttons on a given joystick port
 *
 * @param stick The joystick port number
 * @return The number of buttons on the indicated joystick
 */
int DriverStation::GetStickButtonCount(uint32_t stick) const {
  if (stick >= kJoystickPorts) {
    wpi_setWPIError(BadJoystickIndex);
    return 0;
  }
  HALJoystickButtons joystickButtons;
  HALGetJoystickButtons(stick, &joystickButtons);
  return joystickButtons.count;
}
/**
 * Copy data from the DS task for the user.
 * If no new data exists, it will just be returned, otherwise
 * the data will be copied from the DS polling loop.
 */
void DriverStation::GetData() {
  // Get the status of all of the joysticks
  for (uint8_t stick = 0; stick < kJoystickPorts; stick++) {
    HALGetJoystickAxes(stick, &m_joystickAxes[stick]);
    HALGetJoystickPOVs(stick, &m_joystickPOVs[stick]);
    HALGetJoystickButtons(stick, &m_joystickButtons[stick]);
    HALGetJoystickDescriptor(stick, &m_joystickDescriptor[stick]);
  }
  m_newControlData.give();
}
/**
 * Copy data from the DS task for the user.
 * If no new data exists, it will just be returned, otherwise
 * the data will be copied from the DS polling loop.
 */
void DriverStation::GetData()
{

	// Get the status of all of the joysticks
	for(uint8_t stick = 0; stick < kJoystickPorts; stick++) {
		HALGetJoystickAxes(stick, &m_joystickAxes[stick]);
		HALGetJoystickPOVs(stick, &m_joystickPOVs[stick]);
		HALGetJoystickButtons(stick, &m_joystickButtons[stick]);
	}
	giveSemaphore(m_newControlData);
}