Kodi Development 23.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches
Game.h
1/*
2 * Copyright (C) 2014-2025 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 "../AddonBase.h"
12#include "../c-api/addon-instance/game.h"
13
14#include <algorithm>
15#include <functional>
16
17#ifdef __cplusplus
18
19namespace kodi
20{
21namespace addon
22{
23
24//==============================================================================
33
34//==============================================================================
39
40//==============================================================================
48{
49public:
51 explicit GameControllerLayout() = default;
52 GameControllerLayout(const game_controller_layout& layout) : controller_id(layout.controller_id)
53 {
54 provides_input = layout.provides_input;
55 for (unsigned int i = 0; i < layout.digital_button_count; ++i)
56 digital_buttons.emplace_back(layout.digital_buttons[i]);
57 for (unsigned int i = 0; i < layout.analog_button_count; ++i)
58 analog_buttons.emplace_back(layout.analog_buttons[i]);
59 for (unsigned int i = 0; i < layout.analog_stick_count; ++i)
60 analog_sticks.emplace_back(layout.analog_sticks[i]);
61 for (unsigned int i = 0; i < layout.accelerometer_count; ++i)
62 accelerometers.emplace_back(layout.accelerometers[i]);
63 for (unsigned int i = 0; i < layout.key_count; ++i)
64 keys.emplace_back(layout.keys[i]);
65 for (unsigned int i = 0; i < layout.rel_pointer_count; ++i)
66 rel_pointers.emplace_back(layout.rel_pointers[i]);
67 for (unsigned int i = 0; i < layout.abs_pointer_count; ++i)
68 abs_pointers.emplace_back(layout.abs_pointers[i]);
69 for (unsigned int i = 0; i < layout.motor_count; ++i)
70 motors.emplace_back(layout.motors[i]);
71 }
75 std::string controller_id;
76
80 bool provides_input{false};
81
83 std::vector<std::string> digital_buttons;
84
86 std::vector<std::string> analog_buttons;
87
89 std::vector<std::string> analog_sticks;
90
92 std::vector<std::string> accelerometers;
93
95 std::vector<std::string> keys;
96
98 std::vector<std::string> rel_pointers;
99
101 std::vector<std::string> abs_pointers;
102
104 std::vector<std::string> motors;
105};
107//------------------------------------------------------------------------------
108
109//==============================================================================
118class ATTR_DLL_LOCAL CInstanceGame : public IAddonInstance
119{
120public:
121 //============================================================================
127
128 //============================================================================
161 CInstanceGame() : IAddonInstance(IInstanceInfo(CPrivateBase::m_interface->firstKodiInstance))
162 {
163 if (CPrivateBase::m_interface->globalSingleInstance != nullptr)
164 {
165 throw std::logic_error(
166 "kodi::addon::CInstanceGame: Cannot create more than one game instance!");
167 }
168 SetAddonStruct(CPrivateBase::m_interface->firstKodiInstance);
169 CPrivateBase::m_interface->globalSingleInstance = this;
170 }
171 //----------------------------------------------------------------------------
172
173 //============================================================================
176 ~CInstanceGame() override = default;
177 //----------------------------------------------------------------------------
178
179 //============================================================================
187 std::string GameClientDllPath() const { return m_instanceData->props->game_client_dll_path; }
188 //----------------------------------------------------------------------------
189
190 //============================================================================
200 bool ProxyDllPaths(std::vector<std::string>& paths)
201 {
202 for (unsigned int i = 0; i < m_instanceData->props->proxy_dll_count; ++i)
203 {
204 if (m_instanceData->props->proxy_dll_paths[i] != nullptr)
205 paths.emplace_back(m_instanceData->props->proxy_dll_paths[i]);
206 }
207 return !paths.empty();
208 }
209 //----------------------------------------------------------------------------
210
211 //============================================================================
224 bool ResourceDirectories(std::vector<std::string>& dirs)
225 {
226 for (unsigned int i = 0; i < m_instanceData->props->resource_directory_count; ++i)
227 {
228 if (m_instanceData->props->resource_directories[i] != nullptr)
229 dirs.emplace_back(m_instanceData->props->resource_directories[i]);
230 }
231 return !dirs.empty();
232 }
233 //----------------------------------------------------------------------------
234
235 //============================================================================
247 std::string ProfileDirectory() const { return m_instanceData->props->profile_directory; }
248 //----------------------------------------------------------------------------
249
250 //============================================================================
258 bool SupportsVFS() const { return m_instanceData->props->supports_vfs; }
259 //----------------------------------------------------------------------------
260
261 //============================================================================
271 bool Extensions(std::vector<std::string>& extensions)
272 {
273 for (unsigned int i = 0; i < m_instanceData->props->extension_count; ++i)
274 {
275 if (m_instanceData->props->extensions[i] != nullptr)
276 extensions.emplace_back(m_instanceData->props->extensions[i]);
277 }
278 return !extensions.empty();
279 }
280 //----------------------------------------------------------------------------
281
282 //============================================================================
291 std::string LibretroCore() const
292 {
293 if (!IsInstanceAPIVersionAtLeast(8, 2, 1) || m_instanceData->props->libretro_core == nullptr)
294 return "";
295 return m_instanceData->props->libretro_core;
296 }
297 //----------------------------------------------------------------------------
298
300
301 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
302
303 //============================================================================
322
323 //============================================================================
330 virtual GAME_ERROR LoadGame(const std::string& url) { return GAME_ERROR_NOT_IMPLEMENTED; }
331 //----------------------------------------------------------------------------
332
333 //============================================================================
341 virtual GAME_ERROR LoadGameSpecial(SPECIAL_GAME_TYPE type, const std::vector<std::string>& urls)
342 {
344 }
345 //----------------------------------------------------------------------------
346
347 //============================================================================
358 //----------------------------------------------------------------------------
359
360 //============================================================================
368 //----------------------------------------------------------------------------
369
370 //============================================================================
378 {
380 }
381 //----------------------------------------------------------------------------
382
383 //============================================================================
389 //----------------------------------------------------------------------------
390
391 //============================================================================
399 virtual bool RequiresGameLoop() { return false; }
400 //----------------------------------------------------------------------------
401
402 //============================================================================
408 //----------------------------------------------------------------------------
409
410 //============================================================================
416 //----------------------------------------------------------------------------
417
418 //==========================================================================
424 void CloseGame(void) { m_instanceData->toKodi->CloseGame(m_instanceData->toKodi->kodiInstance); }
425 //----------------------------------------------------------------------------
426
427 //============================================================================
437 void ReportMissingFile(const std::string& path)
438 {
439 if (IsInstanceAPIVersionAtLeast(8, 3, 0))
440 m_instanceData->toKodi->ReportMissingFile(m_instanceData->toKodi->kodiInstance, path.c_str());
441 }
442 //----------------------------------------------------------------------------
443
444 //============================================================================
467 {
468 return m_instanceData->toKodi->GetPlaybackSpeed(m_instanceData->toKodi->kodiInstance);
469 }
470 //----------------------------------------------------------------------------
471
472 //============================================================================
483 void SetGameTiming(const game_system_timing& timingInfo)
484 {
485 m_instanceData->toKodi->SetGameTiming(m_instanceData->toKodi->kodiInstance, &timingInfo);
486 }
487 //----------------------------------------------------------------------------
488
489 //============================================================================
503 void SetFastForwarding(bool fastForward, double ratio)
504 {
505 if (IsInstanceAPIVersionAtLeast(8, 4, 0))
506 m_instanceData->toKodi->SetFastForwarding(m_instanceData->toKodi->kodiInstance, fastForward,
507 ratio);
508 }
509 //----------------------------------------------------------------------------
510
511 //============================================================================
523 {
524 public:
525 CStream() = default;
526
527 CStream(const game_stream_properties& properties) { Open(properties); }
528
529 ~CStream() { Close(); }
530
531 //==========================================================================
544 bool Open(const game_stream_properties& properties)
545 {
546 if (!CPrivateBase::m_interface->globalSingleInstance)
547 return false;
548
549 if (m_handle)
550 {
551 kodi::Log(ADDON_LOG_INFO, "kodi::addon::CInstanceGame::CStream already reopened");
552 Close();
553 }
554
556 *static_cast<CInstanceGame*>(CPrivateBase::m_interface->globalSingleInstance)
557 ->m_instanceData->toKodi;
558 m_handle = cb.OpenStream(cb.kodiInstance, &properties);
559 if (m_handle && properties.type == GAME_STREAM_HW_FRAMEBUFFER)
560 {
561 const KODI_GAME_STREAM_HANDLE handle = m_handle;
562 const bool started = cb.StartStream(cb.kodiInstance, handle);
563 if (m_handle != handle)
564 return false;
565 if (!started)
566 Close();
567 }
568 return m_handle != nullptr;
569 }
570 //--------------------------------------------------------------------------
571
572 //==========================================================================
578 void Close()
579 {
580 if (!m_handle || !CPrivateBase::m_interface->globalSingleInstance)
581 return;
582
584 *static_cast<CInstanceGame*>(CPrivateBase::m_interface->globalSingleInstance)
585 ->m_instanceData->toKodi;
586 const KODI_GAME_STREAM_HANDLE handle = m_handle;
587 cb.CloseStream(cb.kodiInstance, handle);
588 if (m_handle == handle)
589 m_handle = nullptr;
590 }
591 //--------------------------------------------------------------------------
592
593 //==========================================================================
607 bool GetBuffer(unsigned int width, unsigned int height, game_stream_buffer& buffer)
608 {
609 if (!m_handle || !CPrivateBase::m_interface->globalSingleInstance)
610 return false;
611
613 *static_cast<CInstanceGame*>(CPrivateBase::m_interface->globalSingleInstance)
614 ->m_instanceData->toKodi;
615 return cb.GetStreamBuffer(cb.kodiInstance, m_handle, width, height, &buffer);
616 }
617 //--------------------------------------------------------------------------
618
619 //==========================================================================
631 void AddData(const game_stream_packet& packet)
632 {
633 if (!m_handle || !CPrivateBase::m_interface->globalSingleInstance)
634 return;
635
637 *static_cast<CInstanceGame*>(CPrivateBase::m_interface->globalSingleInstance)
638 ->m_instanceData->toKodi;
639 cb.AddStreamData(cb.kodiInstance, m_handle, &packet);
640 }
641 //--------------------------------------------------------------------------
642
643 //==========================================================================
652 {
653 if (!m_handle || !CPrivateBase::m_interface->globalSingleInstance)
654 return;
655
657 *static_cast<CInstanceGame*>(CPrivateBase::m_interface->globalSingleInstance)
658 ->m_instanceData->toKodi;
659 cb.ReleaseStreamBuffer(cb.kodiInstance, m_handle, &buffer);
660 }
661 //--------------------------------------------------------------------------
662
663 //==========================================================================
671 bool IsOpen() const { return m_handle != nullptr; }
672 //--------------------------------------------------------------------------
673
674 private:
675 KODI_GAME_STREAM_HANDLE m_handle = nullptr;
676 };
678
680
681 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
682
683 //============================================================================
699
700 //==========================================================================
709 {
710 return m_instanceData->toKodi->EnableHardwareRendering(m_instanceData->toKodi->kodiInstance,
711 &properties);
712 }
713 //----------------------------------------------------------------------------
714
715 //============================================================================
725 //----------------------------------------------------------------------------
726
727 //============================================================================
735
736 //============================================================================
746 {
747 return m_instanceData->toKodi->HwGetProcAddress(m_instanceData->toKodi->kodiInstance, sym);
748 }
749 //----------------------------------------------------------------------------
750
752
753 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
754
755 //============================================================================
771
772 //==========================================================================
783 //--------------------------------------------------------------------------
784
786
787 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
788
789 //============================================================================
804
805 //============================================================================
817 virtual bool HasFeature(const std::string& controller_id, const std::string& feature_name)
818 {
819 return false;
820 }
821 //----------------------------------------------------------------------------
822
823 //============================================================================
834 virtual game_input_topology* GetTopology() { return nullptr; }
835 //----------------------------------------------------------------------------
836
837 //============================================================================
842 virtual void FreeTopology(game_input_topology* topology) {}
843 //----------------------------------------------------------------------------
844
845 //============================================================================
854 const std::vector<kodi::addon::GameControllerLayout>& controllers)
855 {
856 }
857 //----------------------------------------------------------------------------
858
859 //============================================================================
867 virtual bool EnableKeyboard(bool enable, const std::string& controller_id) { return false; }
868 //----------------------------------------------------------------------------
869
870 //============================================================================
878 virtual bool EnableMouse(bool enable, const std::string& controller_id) { return false; }
879 //--------------------------------------------------------------------------
880
881 //==========================================================================
925 virtual bool ConnectController(bool connect,
926 const std::string& port_address,
927 const std::string& controller_id)
928 {
929 return false;
930 }
931 //----------------------------------------------------------------------------
932
933 //============================================================================
940 virtual bool InputEvent(const game_input_event& event) { return false; }
941 //----------------------------------------------------------------------------
942
943 //============================================================================
956 {
957 return m_instanceData->toKodi->InputEvent(m_instanceData->toKodi->kodiInstance, &event);
958 }
959 //----------------------------------------------------------------------------
960
962
963 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
964
965 //============================================================================
980
981 //============================================================================
986 virtual size_t SerializeSize() { return 0; }
987 //----------------------------------------------------------------------------
988
989 //============================================================================
997 virtual GAME_ERROR Serialize(uint8_t* data, size_t size) { return GAME_ERROR_NOT_IMPLEMENTED; }
998 //----------------------------------------------------------------------------
999
1000 //============================================================================
1008 virtual GAME_ERROR Deserialize(const uint8_t* data, size_t size)
1009 {
1011 }
1012 //----------------------------------------------------------------------------
1013
1014 //============================================================================
1023 virtual size_t AchievementStateSize() { return 0; }
1024 //----------------------------------------------------------------------------
1025
1026 //============================================================================
1035 virtual GAME_ERROR SerializeAchievements(uint8_t* data, size_t size)
1036 {
1038 }
1039 //----------------------------------------------------------------------------
1040
1041 //============================================================================
1057 virtual GAME_ERROR DeserializeAchievements(const uint8_t* data, size_t size)
1058 {
1060 }
1061 //----------------------------------------------------------------------------
1062
1064
1065 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
1066
1067 //============================================================================
1083
1084 //============================================================================
1090 //----------------------------------------------------------------------------
1091
1092 //============================================================================
1101 virtual GAME_ERROR GetMemory(GAME_MEMORY type, uint8_t*& data, size_t& size)
1102 {
1104 }
1105 //----------------------------------------------------------------------------
1106
1107 //============================================================================
1116 virtual GAME_ERROR SetCheat(unsigned int index, bool enabled, const std::string& code)
1117 {
1119 }
1120 //============================================================================
1128 virtual GAME_ERROR SetRetroAchievementsCredentials(const std::string& username,
1129 const std::string& token)
1130 {
1132 }
1133
1134 //============================================================================
1148 //----------------------------------------------------------------------------
1149
1150 //============================================================================
1160 //----------------------------------------------------------------------------
1161 //============================================================================
1170 virtual GAME_ERROR ActivateAchievement(unsigned int cheevoId,
1171 const std::string& memAddrExpression)
1172 {
1174 }
1175
1176 //============================================================================
1189 const std::function<void(const std::string& achievementUrl, unsigned int cheevoId)>& callback)
1190 {
1192 }
1193 //============================================================================
1205 {
1206 m_instanceData->toKodi->RCOnGameLoaded(m_instanceData->toKodi->kodiInstance, &data);
1207 }
1208
1209 //============================================================================
1220 {
1221 m_instanceData->toKodi->RCOnAchievementTriggered(m_instanceData->toKodi->kodiInstance, &data);
1222 }
1223
1224 //============================================================================
1235 void RCOnGameCompleted(const std::string& title, bool hardcore)
1236 {
1237 m_instanceData->toKodi->RCOnGameCompleted(m_instanceData->toKodi->kodiInstance, title.c_str(),
1238 hardcore);
1239 }
1240
1241 //============================================================================
1251 void RCOnRichPresenceUpdated(const std::string& evaluation)
1252 {
1253 m_instanceData->toKodi->RCOnRichPresenceUpdated(m_instanceData->toKodi->kodiInstance,
1254 evaluation.c_str());
1255 }
1256
1257 //============================================================================
1268 {
1269 m_instanceData->toKodi->RCOnLoginResult(m_instanceData->toKodi->kodiInstance, &data);
1270 }
1271
1272 //============================================================================
1285 void RCOnAchievementProgress(const std::vector<game_rc_achievement_progress>& progress)
1286 {
1287 m_instanceData->toKodi->RCOnAchievementProgress(m_instanceData->toKodi->kodiInstance,
1288 progress.empty() ? nullptr : progress.data(),
1289 static_cast<unsigned int>(progress.size()));
1290 }
1291
1292 //============================================================================
1303 void RCOnServerError(const std::string& message, const std::string& api)
1304 {
1305 m_instanceData->toKodi->RCOnServerError(m_instanceData->toKodi->kodiInstance, message.c_str(),
1306 api.c_str());
1307 }
1308
1309 //============================================================================
1322 void RCOnConnectionChanged(bool connected)
1323 {
1324 m_instanceData->toKodi->RCOnConnectionChanged(m_instanceData->toKodi->kodiInstance, connected);
1325 }
1326
1327 //============================================================================
1339 {
1340 m_instanceData->toKodi->RCOnChallengeIndicator(m_instanceData->toKodi->kodiInstance, &data,
1341 show);
1342 }
1343
1344 //============================================================================
1355 {
1356 m_instanceData->toKodi->RCOnAchievementProgressUpdate(m_instanceData->toKodi->kodiInstance,
1357 &data);
1358 }
1359
1360 //============================================================================
1371 {
1372 m_instanceData->toKodi->RCOnLeaderboardStarted(m_instanceData->toKodi->kodiInstance, &data);
1373 }
1374
1375 //============================================================================
1386 {
1387 m_instanceData->toKodi->RCOnLeaderboardFailed(m_instanceData->toKodi->kodiInstance, &data);
1388 }
1389
1390 //============================================================================
1404 {
1405 m_instanceData->toKodi->RCOnLeaderboardSubmitted(m_instanceData->toKodi->kodiInstance, &data);
1406 }
1407
1408 //============================================================================
1419 {
1420 m_instanceData->toKodi->RCOnLeaderboardTrackerUpdate(m_instanceData->toKodi->kodiInstance,
1421 &data);
1422 }
1423
1424 //============================================================================
1435 {
1436 m_instanceData->toKodi->RCOnLeaderboardScoreboard(m_instanceData->toKodi->kodiInstance, &data);
1437 }
1438
1439 //============================================================================
1450 void RCOnReset() { m_instanceData->toKodi->RCOnReset(m_instanceData->toKodi->kodiInstance); }
1451
1452 //============================================================================
1462 void RCOnSubsetCompleted(const std::string& title)
1463 {
1464 m_instanceData->toKodi->RCOnSubsetCompleted(m_instanceData->toKodi->kodiInstance,
1465 title.c_str());
1466 }
1467
1468 //============================================================================
1485 bool show)
1486 {
1487 if (show)
1488 m_instanceData->toKodi->RCOnAchievementProgressShow(m_instanceData->toKodi->kodiInstance,
1489 &data);
1490 else
1491 m_instanceData->toKodi->RCOnAchievementProgressHide(m_instanceData->toKodi->kodiInstance,
1492 &data);
1493 }
1494
1495 //============================================================================
1510 {
1511 if (show)
1512 m_instanceData->toKodi->RCOnLeaderboardTrackerShow(m_instanceData->toKodi->kodiInstance,
1513 &data);
1514 else
1515 m_instanceData->toKodi->RCOnLeaderboardTrackerHide(m_instanceData->toKodi->kodiInstance,
1516 &data);
1517 }
1518
1519 //----------------------------------------------------------------------------
1520
1522
1523 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
1524
1525 //============================================================================
1540
1541 //============================================================================
1549 virtual bool GetEjectState() { return false; }
1550 //----------------------------------------------------------------------------
1551
1552 //============================================================================
1562 virtual GAME_ERROR SetEjectState(bool ejected) { return GAME_ERROR_NOT_IMPLEMENTED; }
1563 //----------------------------------------------------------------------------
1564
1565 //============================================================================
1571 virtual unsigned int GetImageIndex() { return 0; }
1572 //----------------------------------------------------------------------------
1573
1574 //============================================================================
1583 virtual GAME_ERROR SetImageIndex(unsigned int imageIndex) { return GAME_ERROR_NOT_IMPLEMENTED; }
1584 //----------------------------------------------------------------------------
1585
1586 //============================================================================
1591 virtual unsigned int GetImageCount() { return 0; }
1592 //----------------------------------------------------------------------------
1593
1594 //============================================================================
1601 //----------------------------------------------------------------------------
1602
1603 //============================================================================
1613 virtual GAME_ERROR ReplaceImageIndex(unsigned int imageIndex, const std::string& filePath)
1614 {
1616 }
1617 //----------------------------------------------------------------------------
1618
1619 //============================================================================
1628 virtual GAME_ERROR RemoveImageIndex(unsigned int imageIndex)
1629 {
1631 }
1632 //----------------------------------------------------------------------------
1633
1634 //============================================================================
1643 virtual GAME_ERROR SetInitialImage(unsigned int imageIndex, const std::string& filePath)
1644 {
1646 }
1647 //----------------------------------------------------------------------------
1648
1649 //============================================================================
1656 virtual std::string GetImagePath(unsigned int imageIndex) { return ""; }
1657 //----------------------------------------------------------------------------
1658
1659 //============================================================================
1666 virtual std::string GetImageLabel(unsigned int imageIndex) { return ""; }
1667 //----------------------------------------------------------------------------
1668
1670
1671private:
1672 void SetAddonStruct(KODI_ADDON_INSTANCE_STRUCT* instance)
1673 {
1674 instance->hdl = this;
1675
1676 instance->game->toAddon->LoadGame = ADDON_LoadGame;
1677 instance->game->toAddon->LoadGameSpecial = ADDON_LoadGameSpecial;
1678 instance->game->toAddon->LoadStandalone = ADDON_LoadStandalone;
1679 instance->game->toAddon->UnloadGame = ADDON_UnloadGame;
1680 instance->game->toAddon->GetGameTiming = ADDON_GetGameTiming;
1681 instance->game->toAddon->GetRegion = ADDON_GetRegion;
1682 instance->game->toAddon->RequiresGameLoop = ADDON_RequiresGameLoop;
1683 instance->game->toAddon->RunFrame = ADDON_RunFrame;
1684 instance->game->toAddon->Reset = ADDON_Reset;
1685
1686 instance->game->toAddon->HwContextReset = ADDON_HwContextReset;
1687 instance->game->toAddon->HwContextDestroy = ADDON_HwContextDestroy;
1688
1689 instance->game->toAddon->AudioAvailable = ADDON_AudioAvailable;
1690
1691 instance->game->toAddon->HasFeature = ADDON_HasFeature;
1692 instance->game->toAddon->GetTopology = ADDON_GetTopology;
1693 instance->game->toAddon->FreeTopology = ADDON_FreeTopology;
1694 instance->game->toAddon->SetControllerLayouts = ADDON_SetControllerLayouts;
1695 instance->game->toAddon->EnableKeyboard = ADDON_EnableKeyboard;
1696 instance->game->toAddon->EnableMouse = ADDON_EnableMouse;
1697 instance->game->toAddon->ConnectController = ADDON_ConnectController;
1698 instance->game->toAddon->InputEvent = ADDON_InputEvent;
1699
1700 instance->game->toAddon->SerializeSize = ADDON_SerializeSize;
1701 instance->game->toAddon->Serialize = ADDON_Serialize;
1702 instance->game->toAddon->Deserialize = ADDON_Deserialize;
1703 instance->game->toAddon->AchievementStateSize = ADDON_AchievementStateSize;
1704 instance->game->toAddon->SerializeAchievements = ADDON_SerializeAchievements;
1705 instance->game->toAddon->DeserializeAchievements = ADDON_DeserializeAchievements;
1706
1707 instance->game->toAddon->CheatReset = ADDON_CheatReset;
1708 instance->game->toAddon->GetMemory = ADDON_GetMemory;
1709 instance->game->toAddon->SetCheat = ADDON_SetCheat;
1710
1711 instance->game->toAddon->SetRetroAchievementsCredentials =
1712 ADDON_SetRetroAchievementsCredentials;
1713 instance->game->toAddon->RCSetHardcoreEnabled = ADDON_RCSetHardcoreEnabled;
1714 instance->game->toAddon->RCSetEncoreModeEnabled = ADDON_RCSetEncoreModeEnabled;
1715 instance->game->toAddon->ActivateAchievement = ADDON_ActivateAchievement;
1716 instance->game->toAddon->GetCheevoUrlId = ADDON_GetCheevoUrlId;
1717
1718 instance->game->toAddon->GetEjectState = ADDON_GetEjectState;
1719 instance->game->toAddon->SetEjectState = ADDON_SetEjectState;
1720 instance->game->toAddon->GetImageIndex = ADDON_GetImageIndex;
1721 instance->game->toAddon->SetImageIndex = ADDON_SetImageIndex;
1722 instance->game->toAddon->GetImageCount = ADDON_GetImageCount;
1723 instance->game->toAddon->AddImageIndex = ADDON_AddImageIndex;
1724 instance->game->toAddon->ReplaceImageIndex = ADDON_ReplaceImageIndex;
1725 instance->game->toAddon->RemoveImageIndex = ADDON_RemoveImageIndex;
1726 instance->game->toAddon->SetInitialImage = ADDON_SetInitialImage;
1727 instance->game->toAddon->GetImagePath = ADDON_GetImagePath;
1728 instance->game->toAddon->GetImageLabel = ADDON_GetImageLabel;
1729
1730 instance->game->toAddon->FreeString = ADDON_FreeString;
1731
1732 m_instanceData = instance->game;
1733 m_instanceData->toAddon->addonInstance = this;
1734 }
1735
1736 // --- Game operations ---------------------------------------------------------
1737
1738 inline static GAME_ERROR ADDON_LoadGame(const AddonInstance_Game* instance, const char* url)
1739 {
1740 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->LoadGame(url);
1741 }
1742
1743 inline static GAME_ERROR ADDON_LoadGameSpecial(const AddonInstance_Game* instance,
1744 SPECIAL_GAME_TYPE type,
1745 const char** urls,
1746 size_t urlCount)
1747 {
1748 std::vector<std::string> urlList;
1749 for (size_t i = 0; i < urlCount; ++i)
1750 {
1751 if (urls[i] != nullptr)
1752 urlList.emplace_back(urls[i]);
1753 }
1754
1755 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1756 ->LoadGameSpecial(type, urlList);
1757 }
1758
1759 inline static GAME_ERROR ADDON_LoadStandalone(const AddonInstance_Game* instance)
1760 {
1761 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->LoadStandalone();
1762 }
1763
1764 inline static GAME_ERROR ADDON_UnloadGame(const AddonInstance_Game* instance)
1765 {
1766 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->UnloadGame();
1767 }
1768
1769 inline static GAME_ERROR ADDON_GetGameTiming(const AddonInstance_Game* instance,
1770 game_system_timing* timing_info)
1771 {
1772 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1773 ->GetGameTiming(*timing_info);
1774 }
1775
1776 inline static GAME_REGION ADDON_GetRegion(const AddonInstance_Game* instance)
1777 {
1778 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetRegion();
1779 }
1780
1781 inline static bool ADDON_RequiresGameLoop(const AddonInstance_Game* instance)
1782 {
1783 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->RequiresGameLoop();
1784 }
1785
1786 inline static GAME_ERROR ADDON_RunFrame(const AddonInstance_Game* instance)
1787 {
1788 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->RunFrame();
1789 }
1790
1791 inline static GAME_ERROR ADDON_Reset(const AddonInstance_Game* instance)
1792 {
1793 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->Reset();
1794 }
1795
1796 // --- Hardware rendering operations -------------------------------------------
1797
1798 inline static GAME_ERROR ADDON_HwContextReset(const AddonInstance_Game* instance)
1799 {
1800 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->HwContextReset();
1801 }
1802
1803 inline static GAME_ERROR ADDON_HwContextDestroy(const AddonInstance_Game* instance)
1804 {
1805 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->HwContextDestroy();
1806 }
1807
1808 // --- Audio operations --------------------------------------------------------
1809
1810 inline static GAME_ERROR ADDON_AudioAvailable(const AddonInstance_Game* instance)
1811 {
1812 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->AudioAvailable();
1813 }
1814
1815 // --- Input operations --------------------------------------------------------
1816
1817 inline static bool ADDON_HasFeature(const AddonInstance_Game* instance,
1818 const char* controller_id,
1819 const char* feature_name)
1820 {
1821 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1822 ->HasFeature(controller_id, feature_name);
1823 }
1824
1825 inline static game_input_topology* ADDON_GetTopology(const AddonInstance_Game* instance)
1826 {
1827 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetTopology();
1828 }
1829
1830 inline static void ADDON_FreeTopology(const AddonInstance_Game* instance,
1831 game_input_topology* topology)
1832 {
1833 static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->FreeTopology(topology);
1834 }
1835
1836 inline static void ADDON_SetControllerLayouts(const AddonInstance_Game* instance,
1837 const game_controller_layout* controllers,
1838 unsigned int controller_count)
1839 {
1840 if (controllers == nullptr)
1841 return;
1842
1843 std::vector<GameControllerLayout> controllerList;
1844 controllerList.reserve(controller_count);
1845 for (unsigned int i = 0; i < controller_count; ++i)
1846 controllerList.emplace_back(controllers[i]);
1847
1848 static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1849 ->SetControllerLayouts(controllerList);
1850 }
1851
1852 inline static bool ADDON_EnableKeyboard(const AddonInstance_Game* instance,
1853 bool enable,
1854 const char* controller_id)
1855 {
1856 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1857 ->EnableKeyboard(enable, controller_id);
1858 }
1859
1860 inline static bool ADDON_EnableMouse(const AddonInstance_Game* instance,
1861 bool enable,
1862 const char* controller_id)
1863 {
1864 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1865 ->EnableMouse(enable, controller_id);
1866 }
1867
1868 inline static bool ADDON_ConnectController(const AddonInstance_Game* instance,
1869 bool connect,
1870 const char* port_address,
1871 const char* controller_id)
1872 {
1873 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1874 ->ConnectController(connect, port_address, controller_id);
1875 }
1876
1877 inline static bool ADDON_InputEvent(const AddonInstance_Game* instance,
1878 const game_input_event* event)
1879 {
1880 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->InputEvent(*event);
1881 }
1882
1883 // --- Serialization operations ------------------------------------------------
1884
1885 inline static size_t ADDON_SerializeSize(const AddonInstance_Game* instance)
1886 {
1887 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->SerializeSize();
1888 }
1889
1890 inline static GAME_ERROR ADDON_Serialize(const AddonInstance_Game* instance,
1891 uint8_t* data,
1892 size_t size)
1893 {
1894 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->Serialize(data, size);
1895 }
1896
1897 inline static GAME_ERROR ADDON_Deserialize(const AddonInstance_Game* instance,
1898 const uint8_t* data,
1899 size_t size)
1900 {
1901 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->Deserialize(data, size);
1902 }
1903
1904 inline static size_t ADDON_AchievementStateSize(const AddonInstance_Game* instance)
1905 {
1906 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->AchievementStateSize();
1907 }
1908
1909 inline static GAME_ERROR ADDON_SerializeAchievements(const AddonInstance_Game* instance,
1910 uint8_t* data,
1911 size_t size)
1912 {
1913 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1914 ->SerializeAchievements(data, size);
1915 }
1916
1917 inline static GAME_ERROR ADDON_DeserializeAchievements(const AddonInstance_Game* instance,
1918 const uint8_t* data,
1919 size_t size)
1920 {
1921 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1922 ->DeserializeAchievements(data, size);
1923 }
1924
1925 // --- Cheat operations --------------------------------------------------------
1926
1927 inline static GAME_ERROR ADDON_CheatReset(const AddonInstance_Game* instance)
1928 {
1929 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->CheatReset();
1930 }
1931
1932 inline static GAME_ERROR ADDON_GetMemory(const AddonInstance_Game* instance,
1933 GAME_MEMORY type,
1934 uint8_t** data,
1935 size_t* size)
1936 {
1937 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1938 ->GetMemory(type, *data, *size);
1939 }
1940
1941 inline static GAME_ERROR ADDON_SetCheat(const AddonInstance_Game* instance,
1942 unsigned int index,
1943 bool enabled,
1944 const char* code)
1945 {
1946 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1947 ->SetCheat(index, enabled, code);
1948 }
1949
1950 inline static GAME_ERROR ADDON_SetRetroAchievementsCredentials(const AddonInstance_Game* instance,
1951 const char* username,
1952 const char* token)
1953 {
1954 if (username == nullptr || token == nullptr)
1956
1957 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1958 ->SetRetroAchievementsCredentials(username, token);
1959 }
1960
1961 inline static GAME_ERROR ADDON_RCSetHardcoreEnabled(const AddonInstance_Game* instance,
1962 bool enabled)
1963 {
1964 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1965 ->RCSetHardcoreEnabled(enabled);
1966 }
1967
1968 inline static GAME_ERROR ADDON_RCSetEncoreModeEnabled(const AddonInstance_Game* instance,
1969 bool enabled)
1970 {
1971 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1972 ->RCSetEncoreModeEnabled(enabled);
1973 }
1974
1975 inline static GAME_ERROR ADDON_ActivateAchievement(const AddonInstance_Game* instance,
1976 unsigned int cheevoId,
1977 const char* memAddrExpression)
1978 {
1979 if (memAddrExpression == nullptr)
1981
1982 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1983 ->ActivateAchievement(cheevoId, memAddrExpression);
1984 }
1985
1986 inline static GAME_ERROR ADDON_GetCheevoUrlId(const AddonInstance_Game* instance,
1987 void(__cdecl* callback)(const void* context,
1988 const char* achievementUrl,
1989 unsigned int cheevoId),
1990 const void* context)
1991 {
1992 if (callback == nullptr)
1994
1995 const auto cppCallback =
1996 [callback, context](const std::string& achievementUrl, unsigned int cheevoId)
1997 { callback(context, achievementUrl.c_str(), cheevoId); };
1998
1999 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
2000 ->GetCheevoUrlId(cppCallback);
2001 }
2002
2003 inline static bool ADDON_GetEjectState(const AddonInstance_Game* instance)
2004 {
2005 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetEjectState();
2006 }
2007
2008 inline static GAME_ERROR ADDON_SetEjectState(const AddonInstance_Game* instance, bool ejected)
2009 {
2010 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->SetEjectState(ejected);
2011 }
2012
2013 inline static unsigned int ADDON_GetImageIndex(const AddonInstance_Game* instance)
2014 {
2015 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetImageIndex();
2016 }
2017
2018 inline static GAME_ERROR ADDON_SetImageIndex(const AddonInstance_Game* instance,
2019 unsigned int imageIndex)
2020 {
2021 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->SetImageIndex(imageIndex);
2022 }
2023
2024 inline static unsigned int ADDON_GetImageCount(const AddonInstance_Game* instance)
2025 {
2026 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetImageCount();
2027 }
2028
2029 inline static GAME_ERROR ADDON_AddImageIndex(const AddonInstance_Game* instance)
2030 {
2031 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->AddImageIndex();
2032 }
2033
2034 inline static GAME_ERROR ADDON_ReplaceImageIndex(const AddonInstance_Game* instance,
2035 unsigned int imageIndex,
2036 const char* filePath)
2037 {
2038 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
2039 ->ReplaceImageIndex(imageIndex, filePath ? filePath : "");
2040 }
2041
2042 inline static GAME_ERROR ADDON_RemoveImageIndex(const AddonInstance_Game* instance,
2043 unsigned int imageIndex)
2044 {
2045 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
2046 ->RemoveImageIndex(imageIndex);
2047 }
2048
2049 inline static GAME_ERROR ADDON_SetInitialImage(const AddonInstance_Game* instance,
2050 unsigned int imageIndex,
2051 const char* filePath)
2052 {
2053 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
2054 ->SetInitialImage(imageIndex, filePath ? filePath : "");
2055 }
2056
2057 inline static char* ADDON_GetImagePath(const AddonInstance_Game* instance,
2058 unsigned int imageIndex)
2059 {
2060 std::string cppPath =
2061 static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetImagePath(imageIndex);
2062 if (cppPath.empty())
2063 return nullptr;
2064
2065 char* path = new char[cppPath.size() + 1];
2066 std::copy(cppPath.begin(), cppPath.end(), path);
2067 path[cppPath.size()] = '\0';
2068 return path;
2069 }
2070
2071 inline static char* ADDON_GetImageLabel(const AddonInstance_Game* instance,
2072 unsigned int imageIndex)
2073 {
2074 std::string cppLabel =
2075 static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetImageLabel(imageIndex);
2076 if (cppLabel.empty())
2077 return nullptr;
2078
2079 char* label = new char[cppLabel.size() + 1];
2080 std::copy(cppLabel.begin(), cppLabel.end(), label);
2081 label[cppLabel.size()] = '\0';
2082 return label;
2083 }
2084
2085 inline static void ADDON_FreeString(const AddonInstance_Game* instance, char* str)
2086 {
2087 delete[] str;
2088 }
2089
2090 AddonInstance_Game* m_instanceData;
2091};
2092
2093} /* namespace addon */
2094} /* namespace kodi */
2095
2096#endif /* __cplusplus */
Definition Game.h:119
Definition AddonBase.h:567
Definition AddonBase.h:503
@ ADDON_LOG_INFO
1 : To include information messages in the log file.
Definition addon_base.h:188
virtual GAME_ERROR AudioAvailable()
Tell the client the frontend is ready for audio.
Definition Game.h:782
CInstanceGame()
Game class constructor.
Definition Game.h:161
std::string GameClientDllPath() const
Callback to Kodi Function The path of the game client being loaded.
Definition Game.h:187
bool ProxyDllPaths(std::vector< std::string > &paths)
Callback to Kodi Function Paths to proxy DLLs used to load the game client.
Definition Game.h:200
bool ResourceDirectories(std::vector< std::string > &dirs)
Callback to Kodi Function The "system" directories of the frontend.
Definition Game.h:224
std::string ProfileDirectory() const
Callback to Kodi Function The writable directory of the frontend.
Definition Game.h:247
bool SupportsVFS() const
Callback to Kodi Function The value of the <supports_vfs> property from addon.xml.
Definition Game.h:258
~CInstanceGame() override=default
Destructor.
std::string LibretroCore() const
Callback to Kodi Function The <libretro_core> property from addon.xml, such as "fceumm_libretro".
Definition Game.h:291
bool Extensions(std::vector< std::string > &extensions)
Callback to Kodi Function The extensions in the <extensions> property from addon.xml.
Definition Game.h:271
void RCOnLeaderboardScoreboard(const game_rc_leaderboard_scoreboard &data)
Callback to Kodi Function Tell Kodi where a submitted attempt placed
Definition Game.h:1434
void RCOnSubsetCompleted(const std::string &title)
Callback to Kodi Function Notify Kodi that every achievement of a subset has been earned
Definition Game.h:1462
void RCOnLeaderboardSubmitted(const game_rc_leaderboard &data)
Callback to Kodi Function Notify Kodi that a leaderboard value has been sent to the server
Definition Game.h:1403
virtual GAME_ERROR ActivateAchievement(unsigned int cheevoId, const std::string &memAddrExpression)
Activate an achievement.
Definition Game.h:1170
void RCOnRichPresenceUpdated(const std::string &evaluation)
Callback to Kodi Function Publish the current rich presence evaluation to Kodi
Definition Game.h:1251
void RCOnLeaderboardTracker(const game_rc_leaderboard_tracker &data, bool show)
Callback to Kodi Function Show, update or hide the live value of an attempt in progress
Definition Game.h:1509
void RCOnChallengeIndicator(const game_rc_achievement_challenge &data, bool show)
Callback to Kodi Function Show or hide the indicator for an achievement the player is attempting
Definition Game.h:1338
virtual GAME_ERROR RCSetEncoreModeEnabled(bool enabled)
Set whether already-earned achievements can be earned again.
Definition Game.h:1159
void RCOnLeaderboardFailed(const game_rc_leaderboard &data)
Callback to Kodi Function Notify Kodi that an attempt at a leaderboard has been abandoned
Definition Game.h:1385
void RCOnServerError(const std::string &message, const std::string &api)
Callback to Kodi Function Report an error returned by the RetroAchievements server
Definition Game.h:1303
void RCOnAchievementProgress(const std::vector< game_rc_achievement_progress > &progress)
Callback to Kodi Function Publish progress towards the game's measured achievements
Definition Game.h:1285
void RCOnReset()
Callback to Kodi Function Ask the frontend to reset the game
Definition Game.h:1450
void RCOnGameLoaded(const game_rc_game_loaded &data)
Callback to Kodi Function Notify Kodi that a game has been identified by the achievement runtime
Definition Game.h:1204
void RCOnLoginResult(const game_rc_login_result &data)
Callback to Kodi Function Notify Kodi of the outcome of a login attempt
Definition Game.h:1267
void RCOnAchievementProgressIndicator(const game_rc_achievement_progress_indicator &data, bool show)
Callback to Kodi Function Show, update or hide how far along a measured achievement is
Definition Game.h:1484
virtual GAME_ERROR SetRetroAchievementsCredentials(const std::string &username, const std::string &token)
Set the credentials of the RetroAchievements user.
Definition Game.h:1128
void RCOnLeaderboardTrackerUpdate(const game_rc_leaderboard_tracker &data)
Callback to Kodi Function Give Kodi a new value for an attempt already on screen
Definition Game.h:1418
void RCOnAchievementProgressUpdate(const game_rc_achievement_progress_indicator &data)
Callback to Kodi Function Give Kodi a new value for a measured achievement already on screen
Definition Game.h:1354
void RCOnConnectionChanged(bool connected)
Callback to Kodi Function Report a change in connectivity to the RetroAchievements server
Definition Game.h:1322
void RCOnLeaderboardStarted(const game_rc_leaderboard &data)
Callback to Kodi Function Notify Kodi that an attempt at a leaderboard has begun
Definition Game.h:1370
virtual GAME_ERROR RCSetHardcoreEnabled(bool enabled)
Set whether achievements are earned in hardcore mode.
Definition Game.h:1147
void RCOnGameCompleted(const std::string &title, bool hardcore)
Callback to Kodi Function Notify Kodi that every achievement of the game has been earned
Definition Game.h:1235
virtual GAME_ERROR GetCheevoUrlId(const std::function< void(const std::string &achievementUrl, unsigned int cheevoId)> &callback)
Get triggered achievement URL and ID pairs.
Definition Game.h:1188
void RCOnAchievementTriggered(const game_rc_achievement_triggered &data)
Callback to Kodi Function Notify Kodi that the player has earned an achievement
Definition Game.h:1219
virtual GAME_ERROR CheatReset()
Reset the cheat system.
Definition Game.h:1089
virtual GAME_ERROR GetMemory(GAME_MEMORY type, uint8_t *&data, size_t &size)
Get a region of memory.
Definition Game.h:1101
virtual GAME_ERROR SetCheat(unsigned int index, bool enabled, const std::string &code)
Set a cheat code.
Definition Game.h:1116
Game system timing.
Definition game.h:1181
GAME_REGION
Game region definition
Definition game.h:626
SPECIAL_GAME_TYPE
Special game types passed into game_load_game_special().
Definition game.h:644
GAME_MEMORY
Game Memory
Definition game.h:663
@ GAME_REGION_UNKNOWN
Game region unknown.
Definition game.h:628
void(* game_proc_address_t)(void)
Hardware framebuffer process function address
Definition game.h:466
Hardware rendering properties
Definition game.h:341
std::vector< std::string > analog_buttons
Analog buttons.
Definition Game.h:86
std::vector< std::string > accelerometers
Accelerometers.
Definition Game.h:92
bool provides_input
Provides input.
Definition Game.h:80
std::vector< std::string > digital_buttons
Digital buttons.
Definition Game.h:83
std::vector< std::string > abs_pointers
Absolute pointers.
Definition Game.h:101
std::vector< std::string > motors
Motors.
Definition Game.h:104
std::string controller_id
Controller identifier.
Definition Game.h:75
std::vector< std::string > rel_pointers
Relative pointers.
Definition Game.h:98
std::vector< std::string > keys
Keys.
Definition Game.h:95
std::vector< std::string > analog_sticks
Analog sticks.
Definition Game.h:89
"C" Game add-on controller layout.
Definition game.h:911
An input event.
Definition game.h:1120
The input topology is the possible ways to connect input devices.
Definition game.h:992
**Payload of AddonToKodiFuncTable_Game::RCOnChallengeIndicator**
Definition game.h:1447
Payload of the achievement progress indicator callbacks
Definition game.h:1469
**Payload of AddonToKodiFuncTable_Game::RCOnAchievementTriggered**
Definition game.h:1292
**Payload of AddonToKodiFuncTable_Game::RCOnGameLoaded**
Definition game.h:1270
Payload of the leaderboard attempt callbacks
Definition game.h:1377
**Payload of AddonToKodiFuncTable_Game::RCOnLeaderboardScoreboard**
Definition game.h:1402
Payload of the leaderboard tracker callbacks
Definition game.h:1428
**Payload of AddonToKodiFuncTable_Game::RCOnLoginResult**
Definition game.h:1317
GAME_STREAM_TYPE type
The stream type.
Definition game.h:545
@ GAME_STREAM_HW_FRAMEBUFFER
Hardware framebuffer.
Definition game.h:529
Stream buffers for hardware rendering and zero-copy support
Definition game.h:568
Stream packet and ephemeral metadata
Definition game.h:591
Immutable stream metadata
Definition game.h:543
GAME_ERROR
Game add-on error codes
Definition game.h:29
@ GAME_ERROR_INVALID_PARAMETERS
The parameters of the called method are invalid for this operation.
Definition game.h:43
@ GAME_ERROR_NOT_IMPLEMENTED
The method called by the frontend is not implemented.
Definition game.h:37
virtual GAME_ERROR SetImageIndex(unsigned int imageIndex)
Inserts the disk image at the given index.
Definition Game.h:1583
virtual unsigned int GetImageCount()
Gets the number of available disk images.
Definition Game.h:1591
virtual std::string GetImageLabel(unsigned int imageIndex)
Gets a user-friendly label for a disk image.
Definition Game.h:1666
virtual GAME_ERROR ReplaceImageIndex(unsigned int imageIndex, const std::string &filePath)
Replaces the disk image at the given index.
Definition Game.h:1613
virtual GAME_ERROR RemoveImageIndex(unsigned int imageIndex)
Removes the disk image at the given index.
Definition Game.h:1628
virtual std::string GetImagePath(unsigned int imageIndex)
Gets the full path of a disk image.
Definition Game.h:1656
virtual unsigned int GetImageIndex()
Gets the index of the currently inserted disk image.
Definition Game.h:1571
virtual GAME_ERROR SetInitialImage(unsigned int imageIndex, const std::string &filePath)
Sets which image should be initially inserted on load.
Definition Game.h:1643
virtual GAME_ERROR SetEjectState(bool ejected)
Opens or closes the virtual disk tray.
Definition Game.h:1562
virtual GAME_ERROR AddImageIndex()
Adds a new disk image slot.
Definition Game.h:1600
virtual bool GetEjectState()
Returns whether the virtual disk tray is currently ejected.
Definition Game.h:1549
virtual GAME_ERROR HwContextDestroy()
Called before the context is destroyed.
Definition Game.h:734
virtual GAME_ERROR HwContextReset()
Invalidates the current HW context and reinitializes GPU resources.
Definition Game.h:724
bool EnableHardwareRendering(const game_hw_rendering_properties &properties)
Callback to Kodi Function Enable hardware rendering functionality
Definition Game.h:708
game_proc_address_t HwGetProcAddress(const char *sym)
Callback to Kodi Function Get a symbol from the hardware context
Definition Game.h:745
virtual bool HasFeature(const std::string &controller_id, const std::string &feature_name)
Check if input is accepted for a feature on the controller.
Definition Game.h:817
virtual bool InputEvent(const game_input_event &event)
Notify the add-on of an input event.
Definition Game.h:940
virtual void FreeTopology(game_input_topology *topology)
Free the topology's resources.
Definition Game.h:842
virtual bool ConnectController(bool connect, const std::string &port_address, const std::string &controller_id)
Connect/disconnect a controller to a port on the virtual game console.
Definition Game.h:925
virtual void SetControllerLayouts(const std::vector< kodi::addon::GameControllerLayout > &controllers)
Set the layouts for known controllers.
Definition Game.h:853
virtual bool EnableMouse(bool enable, const std::string &controller_id)
Enable/disable mouse input using the specified controller.
Definition Game.h:878
virtual bool EnableKeyboard(bool enable, const std::string &controller_id)
Enable/disable keyboard input using the specified controller.
Definition Game.h:867
bool KodiInputEvent(const game_input_event &event)
Callback to Kodi Function Notify the port of an input event
Definition Game.h:955
virtual game_input_topology * GetTopology()
Get the input topology that specifies which controllers can be connected.
Definition Game.h:834
bool IsOpen() const
Check if the stream opened correctly, e.g. after calling the constructor.
Definition Game.h:671
void ReleaseBuffer(game_stream_buffer &buffer)
Free an allocated buffer.
Definition Game.h:651
void Close()
Free the specified stream.
Definition Game.h:578
bool GetBuffer(unsigned int width, unsigned int height, game_stream_buffer &buffer)
Get a buffer for zero-copy stream data.
Definition Game.h:607
void AddData(const game_stream_packet &packet)
Add a data packet to a stream.
Definition Game.h:631
bool Open(const game_stream_properties &properties)
Create a stream for gameplay data.
Definition Game.h:544
virtual GAME_ERROR LoadGameSpecial(SPECIAL_GAME_TYPE type, const std::vector< std::string > &urls)
Load a game that requires multiple files.
Definition Game.h:341
virtual GAME_ERROR UnloadGame()
Unload the current game.
Definition Game.h:367
void SetGameTiming(const game_system_timing &timingInfo)
Callback to Kodi Function Update the video and audio timing of the running game
Definition Game.h:483
virtual GAME_ERROR GetGameTiming(game_system_timing &timing_info)
Get timing information about the loaded game.
Definition Game.h:377
virtual GAME_ERROR RunFrame()
Run a single frame for add-ons that use a game loop.
Definition Game.h:407
virtual bool RequiresGameLoop()
Return true if the client requires the frontend to provide a game loop.
Definition Game.h:399
void SetFastForwarding(bool fastForward, double ratio)
Callback to Kodi Function Ask Kodi to fast-forward the game, or to stop a fast-forward it asked for
Definition Game.h:503
virtual GAME_ERROR Reset()
Reset the current game.
Definition Game.h:415
virtual GAME_ERROR LoadStandalone()
Begin playing without a game file.
Definition Game.h:357
double GetPlaybackSpeed()
Callback to Kodi Function Get the speed the game is being played back at
Definition Game.h:466
void CloseGame(void)
Callback to Kodi Function Requests the frontend to stop the current game
Definition Game.h:424
void ReportMissingFile(const std::string &path)
Callback to Kodi Function Name a file the game client looked for and couldn't find,...
Definition Game.h:437
virtual GAME_ERROR LoadGame(const std::string &url)
Load a game.
Definition Game.h:330
virtual GAME_REGION GetRegion()
Get region of the loaded game.
Definition Game.h:388
virtual size_t AchievementStateSize()
How many bytes the achievement runtime's state needs right now.
Definition Game.h:1023
virtual GAME_ERROR SerializeAchievements(uint8_t *data, size_t size)
Write the achievement runtime's state.
Definition Game.h:1035
virtual GAME_ERROR DeserializeAchievements(const uint8_t *data, size_t size)
Restore achievement state written by SerializeAchievements()
Definition Game.h:1057
virtual GAME_ERROR Deserialize(const uint8_t *data, size_t size)
Deserialize the game from the given state.
Definition Game.h:1008
virtual GAME_ERROR Serialize(uint8_t *data, size_t size)
Serialize the state of the game.
Definition Game.h:997
virtual size_t SerializeSize()
Get the number of bytes required to serialize the game.
Definition Game.h:986
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition AddonBase.h:1957
std::string ATTR_DLL_LOCAL GetRegion(const std::string &id)
Returns your regions setting as a string for the specified id.
Definition General.h:331
Game instance.
Definition game.h:1738
Game callbacks.
Definition game.h:1577
bool(* StartStream)(KODI_HANDLE, KODI_GAME_STREAM_HANDLE)
Reset a prepared hardware stream after installing its returned handle.
Definition game.h:1641
Definition addon_base.h:269
Internal used structure to have stored C API data above and available for everything below.
Definition AddonBase.h:74