Ejemplo n.º 1
0
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());
}
Ejemplo n.º 2
0
void
XboxdrvDaemon::on_disconnect(ControllerSlotPtr slot)
{
  ControllerPtr controller = slot->get_controller();
  assert(controller);

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

  if (!m_opts.on_disconnect.empty())
  {
    log_info("launching disconnect script: " << m_opts.on_disconnect);

    std::vector<std::string> args;
    args.push_back(m_opts.on_disconnect);
    args.push_back(controller->get_usbpath());
    args.push_back(controller->get_usbid());
    args.push_back(controller->get_name());
    spawn_exe(args);
  }
}