void
XboxdrvDaemon::connect(ControllerSlotPtr slot, ControllerPtr controller)
{
  log_info("connecting slot to thread");

  try 
  {
    // set the LED status
    if (slot->get_led_status() == -1)
    {
      controller->set_led(static_cast<uint8_t>(2 + (slot->get_id() % 4)));
    }
    else
    {
      controller->set_led(static_cast<uint8_t>(slot->get_led_status()));
    }
  }
  catch(const std::exception& err)
  {
    log_error("failed to set led: " << err.what());
  }
  
  slot->connect(controller);
  on_connect(slot);

  log_info("controller connected: " 
           << controller->get_usbpath() << " "
           << controller->get_usbid() << " "
           << "'" << controller->get_name() << "'");

  log_info("launched Controller for " << controller->get_usbpath()
           << " in slot " << slot->get_id() << ", free slots: " 
           << get_free_slot_count() << "/" << m_controller_slots.size());
}
Beispiel #2
0
void
XboxdrvMain::init_controller(const ControllerPtr& controller)
{
  m_jsdev_number = UInput::find_jsdev_number();
  m_evdev_number = UInput::find_evdev_number();

  if (m_opts.get_controller_slot().get_led_status() == -1)
  {
    controller->set_led(static_cast<uint8_t>(2 + m_jsdev_number % 4));
  }
  else
  {
    controller->set_led(static_cast<uint8_t>(m_opts.get_controller_slot().get_led_status()));
  }

  if (m_opts.rumble_l != -1 && m_opts.rumble_r != -1)
  { // Only set rumble when explicitly requested
    controller->set_rumble(static_cast<uint8_t>(m_opts.rumble_l),
                           static_cast<uint8_t>(m_opts.rumble_r));
  }
}