bool CJoystickInterfaceCocoa::ScanForJoysticks(JoystickVector& joysticks)
{
    CLockObject lock(m_deviceDiscoveryMutex);

    for (auto it = m_discoveredDevices.begin(); it != m_discoveredDevices.end(); ++it)
        joysticks.push_back(JoystickPtr(new CJoystickCocoa(*it, this)));

    return true;
}
Example #2
0
PERIPHERAL_ERROR PerformDeviceScan(unsigned int* peripheral_count, PERIPHERAL_INFO** scan_results)
{
  if (!peripheral_count || !scan_results)
    return PERIPHERAL_ERROR_INVALID_PARAMETERS;

  JoystickVector joysticks;
  if (!CJoystickManager::Get().PerformJoystickScan(joysticks))
    return PERIPHERAL_ERROR_FAILED;

  // Upcast array pointers
  std::vector<ADDON::Peripheral*> peripherals;
  for (JoystickVector::const_iterator it = joysticks.begin(); it != joysticks.end(); ++it)
    peripherals.push_back(it->get());

  *peripheral_count = peripherals.size();
  ADDON::Peripherals::ToStructs(peripherals, scan_results);

  return PERIPHERAL_NO_ERROR;
}
bool CJoystickInterfaceXInput::ScanForJoysticks(JoystickVector& joysticks)
{
  XINPUT_STATE_EX controllerState; // No need to memset, only checking for controller existence

  for (unsigned int i = 0; i < MAX_JOYSTICKS; i++)
  {
    if (!CXInputDLL::Get().GetState(i, controllerState))
      continue;

    joysticks.push_back(JoystickPtr(new CJoystickXInput(i)));
  }

  return true;
}