bool CGameClientInput::OpenJoystick(const std::string &portAddress, const ControllerPtr &controller) { using namespace JOYSTICK; if (!controller) { CLog::Log(LOGERROR, "Failed to open port \"%s\", no controller given", portAddress.c_str()); return false; } const CControllerPortNode &port = m_controllers.GetPort(portAddress); if (!port.IsControllerAccepted(portAddress, controller->ID())) { CLog::Log(LOGERROR, "Failed to open port: Invalid controller \"%s\" on port \"%s\"", controller->ID().c_str(), portAddress.c_str()); return false; } std::string strId = controller->ID(); game_controller controllerStruct{}; controllerStruct.controller_id = strId.c_str(); controllerStruct.provides_input = controller->Topology().ProvidesInput(); controllerStruct.digital_button_count = controller->FeatureCount(FEATURE_TYPE::SCALAR, INPUT_TYPE::DIGITAL); controllerStruct.analog_button_count = controller->FeatureCount(FEATURE_TYPE::SCALAR, INPUT_TYPE::ANALOG); controllerStruct.analog_stick_count = controller->FeatureCount(FEATURE_TYPE::ANALOG_STICK); controllerStruct.accelerometer_count = controller->FeatureCount(FEATURE_TYPE::ACCELEROMETER); controllerStruct.key_count = controller->FeatureCount(FEATURE_TYPE::KEY); controllerStruct.rel_pointer_count = controller->FeatureCount(FEATURE_TYPE::RELPOINTER); controllerStruct.abs_pointer_count = controller->FeatureCount(FEATURE_TYPE::ABSPOINTER); controllerStruct.motor_count = controller->FeatureCount(FEATURE_TYPE::MOTOR); bool bSuccess = false; { CSingleLock lock(m_clientAccess); if (m_gameClient.Initialized()) { try { bSuccess = m_struct.toAddon.ConnectController(true, portAddress.c_str(), &controllerStruct); } catch (...) { m_gameClient.LogException("ConnectController()"); } } } if (bSuccess) { m_joysticks[portAddress].reset(new CGameClientJoystick(m_gameClient, portAddress, controller, m_struct.toAddon)); ProcessJoysticks(); return true; } return false; }