Skip to content

Commit d70ce98

Browse files
committed
[WIP] RetroEngine: A new player core for kodi
This includes two subsystems: * Rendering * Input
1 parent 900e345 commit d70ce98

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2387
-0
lines changed

addons/skin.estuary/xml/Includes_DialogSelect.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,13 @@
805805
<texture>$INFO[ListItem.Art(screenshot)]</texture>
806806
<aspectratio>keep</aspectratio>
807807
</control>
808+
<control type="gameengine">
809+
<left>10</left>
810+
<right>10</right>
811+
<top>10</top>
812+
<height>256</height>
813+
<savestate>$INFO[ListItem.FilenameAndPath]</savestate>
814+
</control>
808815
<control type="label">
809816
<left>10</left>
810817
<right>10</right>
@@ -843,6 +850,13 @@
843850
<texture>$INFO[ListItem.Art(screenshot)]</texture>
844851
<aspectratio>keep</aspectratio>
845852
</control>
853+
<control type="gameengine">
854+
<left>10</left>
855+
<right>10</right>
856+
<top>10</top>
857+
<height>256</height>
858+
<savestate>$INFO[ListItem.FilenameAndPath]</savestate>
859+
</control>
846860
<control type="label">
847861
<left>10</left>
848862
<right>10</right>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
xbmc/cores/RetroEngine cores/RetroEngine
2+
xbmc/cores/RetroEngine/guibridge cores/RetroEngine/guibridge
3+
xbmc/cores/RetroEngine/guicontrols cores/RetroEngine/guicontrols
4+
xbmc/cores/RetroEngine/input cores/RetroEngine/input
5+
xbmc/cores/RetroEngine/rendering cores/RetroEngine/rendering
6+
xbmc/cores/RetroEngine/streams cores/RetroEngine/streams

xbmc/ServiceBroker.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,3 +473,8 @@ std::shared_ptr<XFILE::CBlurayDiscCache> CServiceBroker::GetBlurayDiscCache()
473473
{
474474
return g_serviceBroker.m_blurayDiscCache;
475475
}
476+
477+
RETRO_ENGINE::CRetroEngineServices& CServiceBroker::GetRetroEngineServices()
478+
{
479+
return g_application.m_ServiceManager->GetRetroEngineServices();
480+
}

xbmc/ServiceBroker.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ namespace MESSAGING
4848
{
4949
class CApplicationMessenger;
5050
}
51+
52+
namespace RETRO_ENGINE
53+
{
54+
class CRetroEngineServices;
55+
}
5156
} // namespace KODI
5257

5358
class CAppParams;
@@ -239,6 +244,8 @@ class CServiceBroker
239244
static void UnregisterBlurayDiscCache();
240245
static std::shared_ptr<XFILE::CBlurayDiscCache> GetBlurayDiscCache();
241246

247+
static KODI::RETRO_ENGINE::CRetroEngineServices& GetRetroEngineServices();
248+
242249
private:
243250
std::shared_ptr<CAppParams> m_appParams;
244251
std::unique_ptr<CLog> m_logging;

xbmc/ServiceManager.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "addons/VFSEntry.h"
2020
#include "addons/binary-addons/BinaryAddonManager.h"
2121
#include "cores/DataCacheCore.h"
22+
#include "cores/RetroEngine/RetroEngineServices.h"
2223
#include "cores/RetroPlayer/guibridge/GUIGameRenderManager.h"
2324
#include "cores/playercorefactory/PlayerCoreFactory.h"
2425
#include "favourites/FavouritesService.h"
@@ -162,6 +163,8 @@ bool CServiceManager::InitStageTwo(const std::string& profilesUserDataFolder)
162163

163164
m_gameRenderManager = std::make_unique<RETRO::CGUIGameRenderManager>();
164165

166+
m_retroEngineServices = std::make_unique<RETRO_ENGINE::CRetroEngineServices>(*m_peripherals);
167+
165168
m_fileExtensionProvider = std::make_unique<CFileExtensionProvider>(*m_addonMgr);
166169

167170
m_powerManager = std::make_unique<CPowerManager>();
@@ -216,6 +219,8 @@ bool CServiceManager::InitStageThree(const std::shared_ptr<CProfileManager>& pro
216219
if (!m_Platform->InitStageThree())
217220
return false;
218221

222+
m_retroEngineServices->Initialize(*m_gameServices);
223+
219224
init_level = 3;
220225
return true;
221226
}
@@ -248,6 +253,8 @@ void CServiceManager::DeinitStageTwo()
248253
m_weatherManager.reset();
249254
m_powerManager.reset();
250255
m_fileExtensionProvider.reset();
256+
m_retroEngineServices->Deinitialize();
257+
m_retroEngineServices.reset();
251258
m_gameRenderManager.reset();
252259
m_peripherals.reset();
253260
m_inputManager.reset();
@@ -383,6 +390,11 @@ KODI::RETRO::CGUIGameRenderManager& CServiceManager::GetGameRenderManager()
383390
return *m_gameRenderManager;
384391
}
385392

393+
RETRO_ENGINE::CRetroEngineServices& CServiceManager::GetRetroEngineServices()
394+
{
395+
return *m_retroEngineServices;
396+
}
397+
386398
PERIPHERALS::CPeripherals& CServiceManager::GetPeripherals()
387399
{
388400
return *m_peripherals;

xbmc/ServiceManager.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ namespace RETRO
6767
{
6868
class CGUIGameRenderManager;
6969
}
70+
71+
namespace RETRO_ENGINE
72+
{
73+
class CRetroEngineServices;
74+
}
7075
} // namespace KODI
7176

7277
namespace MEDIA_DETECT
@@ -149,6 +154,8 @@ class CServiceManager
149154
MEDIA_DETECT::CDetectDVDMedia& GetDetectDVDMedia();
150155
#endif
151156

157+
KODI::RETRO_ENGINE::CRetroEngineServices& GetRetroEngineServices();
158+
152159
protected:
153160
std::unique_ptr<ADDON::CAddonMgr> m_addonMgr;
154161
std::unique_ptr<ADDON::CBinaryAddonManager> m_binaryAddonManager;
@@ -171,6 +178,7 @@ class CServiceManager
171178
std::unique_ptr<KODI::GAME::CControllerManager> m_gameControllerManager;
172179
std::unique_ptr<KODI::GAME::CGameServices> m_gameServices;
173180
std::unique_ptr<KODI::RETRO::CGUIGameRenderManager> m_gameRenderManager;
181+
std::unique_ptr<KODI::RETRO_ENGINE::CRetroEngineServices> m_retroEngineServices;
174182
std::unique_ptr<PERIPHERALS::CPeripherals> m_peripherals;
175183
std::unique_ptr<CFavouritesService> m_favouritesService;
176184
std::unique_ptr<CInputManager> m_inputManager;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set(SOURCES RetroEngine.cpp
2+
RetroEngineServices.cpp
3+
)
4+
5+
set(HEADERS RetroEngine.h
6+
RetroEngineServices.h
7+
)
8+
9+
core_add_library(retroengine)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (C) 2023-2024 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 "RetroEngine.h"
10+
11+
#include "cores/RetroEngine/guibridge/RetroEngineGuiBridge.h"
12+
#include "cores/RetroEngine/rendering/RetroEngineRenderer.h"
13+
#include "cores/RetroEngine/streams/IRetroEngineStream.h"
14+
#include "cores/RetroEngine/streams/RetroEngineStreamManager.h"
15+
#include "cores/RetroEngine/streams/RetroEngineStreamSwFramebuffer.h"
16+
17+
using namespace KODI;
18+
using namespace RETRO_ENGINE;
19+
20+
CRetroEngine::CRetroEngine(CRetroEngineGuiBridge& guiBridge, const std::string& savestatePath)
21+
: m_guiBridge(guiBridge),
22+
m_savestatePath(savestatePath),
23+
m_streamManager(std::make_unique<CRetroEngineStreamManager>()),
24+
m_renderer(std::make_unique<CRetroEngineRenderer>(m_guiBridge, *m_streamManager))
25+
{
26+
}
27+
28+
CRetroEngine::~CRetroEngine() = default;
29+
30+
void CRetroEngine::Initialize()
31+
{
32+
// Initialize rendering
33+
m_renderer->Initialize();
34+
}
35+
36+
void CRetroEngine::Deinitialize()
37+
{
38+
// Deinitialize stream
39+
if (m_stream)
40+
m_streamManager->CloseStream(std::move(m_stream));
41+
42+
// Deinitialize rendering
43+
m_renderer->Deinitialize();
44+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (C) 2023-2024 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+
#pragma once
10+
11+
#include <memory>
12+
#include <string>
13+
14+
namespace KODI
15+
{
16+
namespace RETRO_ENGINE
17+
{
18+
19+
class CRetroEngineGuiBridge;
20+
class CRetroEngineRenderer;
21+
class CRetroEngineStreamManager;
22+
class IRetroEngineStream;
23+
24+
class CRetroEngine
25+
{
26+
public:
27+
explicit CRetroEngine(CRetroEngineGuiBridge& guiBridge, const std::string& savestatePath);
28+
~CRetroEngine();
29+
30+
// Lifecycle functions
31+
void Initialize();
32+
void Deinitialize();
33+
34+
private:
35+
// Construction parameters
36+
CRetroEngineGuiBridge& m_guiBridge;
37+
const std::string m_savestatePath;
38+
39+
// RetroEngine parameters
40+
std::unique_ptr<CRetroEngineStreamManager> m_streamManager;
41+
std::unique_ptr<IRetroEngineStream> m_stream;
42+
std::unique_ptr<CRetroEngineRenderer> m_renderer;
43+
};
44+
} // namespace RETRO_ENGINE
45+
} // namespace KODI
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (C) 2021-2024 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 "cores/RetroEngine/RetroEngineServices.h"
10+
11+
#include "ServiceBroker.h"
12+
#include "application/AppParams.h"
13+
#include "cores/RetroEngine/guibridge/RetroEngineGuiBridge.h"
14+
#include "cores/RetroEngine/guibridge/RetroEngineGuiManager.h"
15+
#include "cores/RetroEngine/input/RetroEngineInputManager.h"
16+
#include "utils/log.h"
17+
18+
using namespace KODI;
19+
using namespace RETRO_ENGINE;
20+
21+
CRetroEngineServices::CRetroEngineServices(PERIPHERALS::CPeripherals& peripheralManager)
22+
: m_guiManager(std::make_unique<CRetroEngineGuiManager>()),
23+
m_inputManager(std::make_unique<CRetroEngineInputManager>(peripheralManager))
24+
{
25+
}
26+
27+
CRetroEngineServices::~CRetroEngineServices() = default;
28+
29+
void CRetroEngineServices::Initialize(GAME::CGameServices& gameServices)
30+
{
31+
CLog::Log(LOGDEBUG, "RETROENGINE: Initializing services");
32+
33+
m_inputManager->Initialize(gameServices);
34+
}
35+
36+
void CRetroEngineServices::Deinitialize()
37+
{
38+
CLog::Log(LOGDEBUG, "RETROENGINE: Deinitializing services");
39+
40+
m_inputManager->Deinitialize();
41+
}
42+
43+
CRetroEngineGuiBridge& CRetroEngineServices::GuiBridge(const std::string& savestatePath)
44+
{
45+
return m_guiManager->GetGuiBridge(savestatePath);
46+
}

0 commit comments

Comments
 (0)