| 1 |
/* |
| 2 |
* Copyright (C) 2017-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "GameServices.h" |
| 10 |
|
| 11 |
#include "controllers/Controller.h" |
| 12 |
#include "controllers/ControllerManager.h" |
| 13 |
#include "games/GameSettings.h" |
| 14 |
#include "games/GameUtils.h" |
| 15 |
#include "games/agents/input/AgentInput.h" |
| 16 |
#include "profiles/ProfileManager.h" |
| 17 |
|
| 18 |
using namespace KODI; |
| 19 |
using namespace GAME; |
| 20 |
|
| 21 |
CGameServices::CGameServices(CControllerManager& controllerManager, |
| 22 |
RETRO::CGUIGameRenderManager& renderManager, |
| 23 |
PERIPHERALS::CPeripherals& peripheralManager, |
| 24 |
const CProfileManager& profileManager, |
| 25 |
CInputManager& inputManager) |
| 26 |
: m_controllerManager(controllerManager), |
| 27 |
m_gameRenderManager(renderManager), |
| 28 |
m_profileManager(profileManager), |
| 29 |
m_gameSettings(new CGameSettings()), |
| 30 |
m_agentInput(std::make_unique<CAgentInput>(peripheralManager, inputManager)) |
| 31 |
{ |
| 32 |
// Load the add-ons from the database asynchronously |
| 33 |
m_initializationTask = |
| 34 |
std::async(std::launch::async, []() { CGameUtils::UpdateInstallableAddons(); }); |
| 35 |
} |
| 36 |
|
| 37 |
CGameServices::~CGameServices() = default; |
| 38 |
|
| 39 |
ControllerPtr CGameServices::GetController(const std::string& controllerId) |
| 40 |
{ |
| 41 |
return m_controllerManager.GetController(controllerId); |
| 42 |
} |
| 43 |
|
| 44 |
ControllerPtr CGameServices::GetDefaultController() |
| 45 |
{ |
| 46 |
return m_controllerManager.GetDefaultController(); |
| 47 |
} |
| 48 |
|
| 49 |
ControllerPtr CGameServices::GetDefaultKeyboard() |
| 50 |
{ |
| 51 |
return m_controllerManager.GetDefaultKeyboard(); |
| 52 |
} |
| 53 |
|
| 54 |
ControllerPtr CGameServices::GetDefaultMouse() |
| 55 |
{ |
| 56 |
return m_controllerManager.GetDefaultMouse(); |
| 57 |
} |
| 58 |
|
| 59 |
ControllerVector CGameServices::GetControllers() |
| 60 |
{ |
| 61 |
return m_controllerManager.GetControllers(); |
| 62 |
} |
| 63 |
|
| 64 |
std::string CGameServices::TranslateFeature(const std::string& controllerId, |
| 65 |
const std::string& featureName) |
| 66 |
{ |
| 67 |
return m_controllerManager.TranslateFeature(controllerId, featureName); |
| 68 |
} |
| 69 |
|
| 70 |
std::string CGameServices::GetSavestatesFolder() const |
| 71 |
{ |
| 72 |
return m_profileManager.GetSavestatesFolder(); |
| 73 |
} |
| 74 |
|
| 75 |
void CGameServices::OnAddonRepoInstalled() |
| 76 |
{ |
| 77 |
CGameUtils::UpdateInstallableAddons(); |
| 78 |
} |