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 //============================================================================
422 //----------------------------------------------------------------------------
423
424 //============================================================================
430 //----------------------------------------------------------------------------
431
432 //==========================================================================
438 void CloseGame(void) { m_instanceData->toKodi->CloseGame(m_instanceData->toKodi->kodiInstance); }
439 //----------------------------------------------------------------------------
440
441 //============================================================================
451 void ReportMissingFile(const std::string& path)
452 {
453 if (IsInstanceAPIVersionAtLeast(8, 3, 0))
454 m_instanceData->toKodi->ReportMissingFile(m_instanceData->toKodi->kodiInstance, path.c_str());
455 }
456 //----------------------------------------------------------------------------
457
458 //============================================================================
481 {
482 return m_instanceData->toKodi->GetPlaybackSpeed(m_instanceData->toKodi->kodiInstance);
483 }
484 //----------------------------------------------------------------------------
485
486 //============================================================================
497 void SetGameTiming(const game_system_timing& timingInfo)
498 {
499 m_instanceData->toKodi->SetGameTiming(m_instanceData->toKodi->kodiInstance, &timingInfo);
500 }
501 //----------------------------------------------------------------------------
502
503 //============================================================================
517 void SetFastForwarding(bool fastForward, double ratio)
518 {
519 if (IsInstanceAPIVersionAtLeast(8, 4, 0))
520 m_instanceData->toKodi->SetFastForwarding(m_instanceData->toKodi->kodiInstance, fastForward,
521 ratio);
522 }
523 //----------------------------------------------------------------------------
524
525 //============================================================================
537 {
538 public:
539 CStream() = default;
540
541 CStream(const game_stream_properties& properties) { Open(properties); }
542
543 ~CStream() { Close(); }
544
545 //==========================================================================
558 bool Open(const game_stream_properties& properties)
559 {
560 if (!CPrivateBase::m_interface->globalSingleInstance)
561 return false;
562
563 if (m_handle)
564 {
565 kodi::Log(ADDON_LOG_INFO, "kodi::addon::CInstanceGame::CStream already reopened");
566 Close();
567 }
568
570 *static_cast<CInstanceGame*>(CPrivateBase::m_interface->globalSingleInstance)
571 ->m_instanceData->toKodi;
572 m_handle = cb.OpenStream(cb.kodiInstance, &properties);
573 if (m_handle && properties.type == GAME_STREAM_HW_FRAMEBUFFER)
574 {
575 const KODI_GAME_STREAM_HANDLE handle = m_handle;
576 const bool started = cb.StartStream(cb.kodiInstance, handle);
577 if (m_handle != handle)
578 return false;
579 if (!started)
580 Close();
581 }
582 return m_handle != nullptr;
583 }
584 //--------------------------------------------------------------------------
585
586 //==========================================================================
592 void Close()
593 {
594 if (!m_handle || !CPrivateBase::m_interface->globalSingleInstance)
595 return;
596
598 *static_cast<CInstanceGame*>(CPrivateBase::m_interface->globalSingleInstance)
599 ->m_instanceData->toKodi;
600 const KODI_GAME_STREAM_HANDLE handle = m_handle;
601 cb.CloseStream(cb.kodiInstance, handle);
602 if (m_handle == handle)
603 m_handle = nullptr;
604 }
605 //--------------------------------------------------------------------------
606
607 //==========================================================================
621 bool GetBuffer(unsigned int width, unsigned int height, game_stream_buffer& buffer)
622 {
623 if (!m_handle || !CPrivateBase::m_interface->globalSingleInstance)
624 return false;
625
627 *static_cast<CInstanceGame*>(CPrivateBase::m_interface->globalSingleInstance)
628 ->m_instanceData->toKodi;
629 return cb.GetStreamBuffer(cb.kodiInstance, m_handle, width, height, &buffer);
630 }
631 //--------------------------------------------------------------------------
632
633 //==========================================================================
645 void AddData(const game_stream_packet& packet)
646 {
647 if (!m_handle || !CPrivateBase::m_interface->globalSingleInstance)
648 return;
649
651 *static_cast<CInstanceGame*>(CPrivateBase::m_interface->globalSingleInstance)
652 ->m_instanceData->toKodi;
653 cb.AddStreamData(cb.kodiInstance, m_handle, &packet);
654 }
655 //--------------------------------------------------------------------------
656
657 //==========================================================================
666 {
667 if (!m_handle || !CPrivateBase::m_interface->globalSingleInstance)
668 return;
669
671 *static_cast<CInstanceGame*>(CPrivateBase::m_interface->globalSingleInstance)
672 ->m_instanceData->toKodi;
673 cb.ReleaseStreamBuffer(cb.kodiInstance, m_handle, &buffer);
674 }
675 //--------------------------------------------------------------------------
676
677 //==========================================================================
685 bool IsOpen() const { return m_handle != nullptr; }
686 //--------------------------------------------------------------------------
687
688 private:
689 KODI_GAME_STREAM_HANDLE m_handle = nullptr;
690 };
692
694
695 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
696
697 //============================================================================
713
714 //==========================================================================
723 {
724 return m_instanceData->toKodi->EnableHardwareRendering(m_instanceData->toKodi->kodiInstance,
725 &properties);
726 }
727 //----------------------------------------------------------------------------
728
729 //============================================================================
739 //----------------------------------------------------------------------------
740
741 //============================================================================
749
750 //============================================================================
760 {
761 return m_instanceData->toKodi->HwGetProcAddress(m_instanceData->toKodi->kodiInstance, sym);
762 }
763 //----------------------------------------------------------------------------
764
766
767 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
768
769 //============================================================================
785
786 //==========================================================================
797 //--------------------------------------------------------------------------
798
800
801 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
802
803 //============================================================================
818
819 //============================================================================
831 virtual bool HasFeature(const std::string& controller_id, const std::string& feature_name)
832 {
833 return false;
834 }
835 //----------------------------------------------------------------------------
836
837 //============================================================================
848 virtual game_input_topology* GetTopology() { return nullptr; }
849 //----------------------------------------------------------------------------
850
851 //============================================================================
856 virtual void FreeTopology(game_input_topology* topology) {}
857 //----------------------------------------------------------------------------
858
859 //============================================================================
868 const std::vector<kodi::addon::GameControllerLayout>& controllers)
869 {
870 }
871 //----------------------------------------------------------------------------
872
873 //============================================================================
881 virtual bool EnableKeyboard(bool enable, const std::string& controller_id) { return false; }
882 //----------------------------------------------------------------------------
883
884 //============================================================================
892 virtual bool EnableMouse(bool enable, const std::string& controller_id) { return false; }
893 //--------------------------------------------------------------------------
894
895 //==========================================================================
939 virtual bool ConnectController(bool connect,
940 const std::string& port_address,
941 const std::string& controller_id)
942 {
943 return false;
944 }
945 //----------------------------------------------------------------------------
946
947 //============================================================================
954 virtual bool InputEvent(const game_input_event& event) { return false; }
955 //----------------------------------------------------------------------------
956
957 //============================================================================
970 {
971 return m_instanceData->toKodi->InputEvent(m_instanceData->toKodi->kodiInstance, &event);
972 }
973 //----------------------------------------------------------------------------
974
976
977 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
978
979 //============================================================================
994
995 //============================================================================
1000 virtual size_t SerializeSize() { return 0; }
1001 //----------------------------------------------------------------------------
1002
1003 //============================================================================
1011 virtual GAME_ERROR Serialize(uint8_t* data, size_t size) { return GAME_ERROR_NOT_IMPLEMENTED; }
1012 //----------------------------------------------------------------------------
1013
1014 //============================================================================
1022 virtual GAME_ERROR Deserialize(const uint8_t* data, size_t size)
1023 {
1025 }
1026 //----------------------------------------------------------------------------
1027
1028 //============================================================================
1041 virtual GAME_ERROR SerializeSpeculative(uint8_t* data, size_t size)
1042 {
1043 return Serialize(data, size);
1044 }
1045 //----------------------------------------------------------------------------
1046
1047 //============================================================================
1055 virtual GAME_ERROR DeserializeSpeculative(const uint8_t* data, size_t size)
1056 {
1057 return Deserialize(data, size);
1058 }
1059 //----------------------------------------------------------------------------
1060
1061 //============================================================================
1070 virtual size_t AchievementStateSize() { return 0; }
1071 //----------------------------------------------------------------------------
1072
1073 //============================================================================
1082 virtual GAME_ERROR SerializeAchievements(uint8_t* data, size_t size)
1083 {
1085 }
1086 //----------------------------------------------------------------------------
1087
1088 //============================================================================
1104 virtual GAME_ERROR DeserializeAchievements(const uint8_t* data, size_t size)
1105 {
1107 }
1108 //----------------------------------------------------------------------------
1109
1111
1112 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
1113
1114 //============================================================================
1130
1131 //============================================================================
1137 //----------------------------------------------------------------------------
1138
1139 //============================================================================
1148 virtual GAME_ERROR GetMemory(GAME_MEMORY type, uint8_t*& data, size_t& size)
1149 {
1151 }
1152 //----------------------------------------------------------------------------
1153
1154 //============================================================================
1163 virtual GAME_ERROR SetCheat(unsigned int index, bool enabled, const std::string& code)
1164 {
1166 }
1167 //============================================================================
1175 virtual GAME_ERROR SetRetroAchievementsCredentials(const std::string& username,
1176 const std::string& token)
1177 {
1179 }
1180
1181 //============================================================================
1195 //----------------------------------------------------------------------------
1196
1197 //============================================================================
1207 //----------------------------------------------------------------------------
1208
1209 //============================================================================
1221 virtual GAME_ERROR RCSetAchievementSetEnabled(unsigned int setId, bool enabled)
1222 {
1224 }
1225 //----------------------------------------------------------------------------
1226 //============================================================================
1235 virtual GAME_ERROR ActivateAchievement(unsigned int cheevoId,
1236 const std::string& memAddrExpression)
1237 {
1239 }
1240
1241 //============================================================================
1254 const std::function<void(const std::string& achievementUrl, unsigned int cheevoId)>& callback)
1255 {
1257 }
1258 //============================================================================
1270 {
1271 m_instanceData->toKodi->RCOnGameLoaded(m_instanceData->toKodi->kodiInstance, &data);
1272 }
1273
1274 //============================================================================
1285 {
1286 m_instanceData->toKodi->RCOnAchievementTriggered(m_instanceData->toKodi->kodiInstance, &data);
1287 }
1288
1289 //============================================================================
1300 void RCOnGameCompleted(const std::string& title, bool hardcore)
1301 {
1302 m_instanceData->toKodi->RCOnGameCompleted(m_instanceData->toKodi->kodiInstance, title.c_str(),
1303 hardcore);
1304 }
1305
1306 //============================================================================
1316 void RCOnRichPresenceUpdated(const std::string& evaluation)
1317 {
1318 m_instanceData->toKodi->RCOnRichPresenceUpdated(m_instanceData->toKodi->kodiInstance,
1319 evaluation.c_str());
1320 }
1321
1322 //============================================================================
1333 {
1334 m_instanceData->toKodi->RCOnLoginResult(m_instanceData->toKodi->kodiInstance, &data);
1335 }
1336
1337 //============================================================================
1350 void RCOnAchievementProgress(const std::vector<game_rc_achievement_progress>& progress)
1351 {
1352 m_instanceData->toKodi->RCOnAchievementProgress(m_instanceData->toKodi->kodiInstance,
1353 progress.empty() ? nullptr : progress.data(),
1354 static_cast<unsigned int>(progress.size()));
1355 }
1356
1357 //============================================================================
1368 void RCOnServerError(const std::string& message, const std::string& api)
1369 {
1370 m_instanceData->toKodi->RCOnServerError(m_instanceData->toKodi->kodiInstance, message.c_str(),
1371 api.c_str());
1372 }
1373
1374 //============================================================================
1387 void RCOnConnectionChanged(bool connected)
1388 {
1389 m_instanceData->toKodi->RCOnConnectionChanged(m_instanceData->toKodi->kodiInstance, connected);
1390 }
1391
1392 //============================================================================
1404 {
1405 m_instanceData->toKodi->RCOnChallengeIndicator(m_instanceData->toKodi->kodiInstance, &data,
1406 show);
1407 }
1408
1409 //============================================================================
1420 {
1421 m_instanceData->toKodi->RCOnAchievementProgressUpdate(m_instanceData->toKodi->kodiInstance,
1422 &data);
1423 }
1424
1425 //============================================================================
1436 {
1437 m_instanceData->toKodi->RCOnLeaderboardStarted(m_instanceData->toKodi->kodiInstance, &data);
1438 }
1439
1440 //============================================================================
1451 {
1452 m_instanceData->toKodi->RCOnLeaderboardFailed(m_instanceData->toKodi->kodiInstance, &data);
1453 }
1454
1455 //============================================================================
1469 {
1470 m_instanceData->toKodi->RCOnLeaderboardSubmitted(m_instanceData->toKodi->kodiInstance, &data);
1471 }
1472
1473 //============================================================================
1484 {
1485 m_instanceData->toKodi->RCOnLeaderboardTrackerUpdate(m_instanceData->toKodi->kodiInstance,
1486 &data);
1487 }
1488
1489 //============================================================================
1500 {
1501 m_instanceData->toKodi->RCOnLeaderboardScoreboard(m_instanceData->toKodi->kodiInstance, &data);
1502 }
1503
1504 //============================================================================
1515 void RCOnReset() { m_instanceData->toKodi->RCOnReset(m_instanceData->toKodi->kodiInstance); }
1516
1517 //============================================================================
1527 void RCOnSubsetCompleted(const std::string& title)
1528 {
1529 m_instanceData->toKodi->RCOnSubsetCompleted(m_instanceData->toKodi->kodiInstance,
1530 title.c_str());
1531 }
1532
1533 //============================================================================
1546 {
1547 if (IsInstanceAPIVersionAtLeast(8, 5, 0))
1548 m_instanceData->toKodi->RCOnAchievementSets(m_instanceData->toKodi->kodiInstance, &data);
1549 }
1550
1551 //============================================================================
1568 bool show)
1569 {
1570 if (show)
1571 m_instanceData->toKodi->RCOnAchievementProgressShow(m_instanceData->toKodi->kodiInstance,
1572 &data);
1573 else
1574 m_instanceData->toKodi->RCOnAchievementProgressHide(m_instanceData->toKodi->kodiInstance,
1575 &data);
1576 }
1577
1578 //============================================================================
1593 {
1594 if (show)
1595 m_instanceData->toKodi->RCOnLeaderboardTrackerShow(m_instanceData->toKodi->kodiInstance,
1596 &data);
1597 else
1598 m_instanceData->toKodi->RCOnLeaderboardTrackerHide(m_instanceData->toKodi->kodiInstance,
1599 &data);
1600 }
1601
1602 //----------------------------------------------------------------------------
1603
1605
1606 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
1607
1608 //============================================================================
1623
1624 //============================================================================
1632 virtual bool GetEjectState() { return false; }
1633 //----------------------------------------------------------------------------
1634
1635 //============================================================================
1645 virtual GAME_ERROR SetEjectState(bool ejected) { return GAME_ERROR_NOT_IMPLEMENTED; }
1646 //----------------------------------------------------------------------------
1647
1648 //============================================================================
1654 virtual unsigned int GetImageIndex() { return 0; }
1655 //----------------------------------------------------------------------------
1656
1657 //============================================================================
1666 virtual GAME_ERROR SetImageIndex(unsigned int imageIndex) { return GAME_ERROR_NOT_IMPLEMENTED; }
1667 //----------------------------------------------------------------------------
1668
1669 //============================================================================
1674 virtual unsigned int GetImageCount() { return 0; }
1675 //----------------------------------------------------------------------------
1676
1677 //============================================================================
1684 //----------------------------------------------------------------------------
1685
1686 //============================================================================
1696 virtual GAME_ERROR ReplaceImageIndex(unsigned int imageIndex, const std::string& filePath)
1697 {
1699 }
1700 //----------------------------------------------------------------------------
1701
1702 //============================================================================
1711 virtual GAME_ERROR RemoveImageIndex(unsigned int imageIndex)
1712 {
1714 }
1715 //----------------------------------------------------------------------------
1716
1717 //============================================================================
1726 virtual GAME_ERROR SetInitialImage(unsigned int imageIndex, const std::string& filePath)
1727 {
1729 }
1730 //----------------------------------------------------------------------------
1731
1732 //============================================================================
1739 virtual std::string GetImagePath(unsigned int imageIndex) { return ""; }
1740 //----------------------------------------------------------------------------
1741
1742 //============================================================================
1749 virtual std::string GetImageLabel(unsigned int imageIndex) { return ""; }
1750 //----------------------------------------------------------------------------
1751
1753
1754private:
1755 void SetAddonStruct(KODI_ADDON_INSTANCE_STRUCT* instance)
1756 {
1757 instance->hdl = this;
1758
1759 instance->game->toAddon->LoadGame = ADDON_LoadGame;
1760 instance->game->toAddon->LoadGameSpecial = ADDON_LoadGameSpecial;
1761 instance->game->toAddon->LoadStandalone = ADDON_LoadStandalone;
1762 instance->game->toAddon->UnloadGame = ADDON_UnloadGame;
1763 instance->game->toAddon->GetGameTiming = ADDON_GetGameTiming;
1764 instance->game->toAddon->GetRegion = ADDON_GetRegion;
1765 instance->game->toAddon->RequiresGameLoop = ADDON_RequiresGameLoop;
1766 instance->game->toAddon->RunFrame = ADDON_RunFrame;
1767 instance->game->toAddon->Reset = ADDON_Reset;
1768
1769 instance->game->toAddon->HwContextReset = ADDON_HwContextReset;
1770 instance->game->toAddon->HwContextDestroy = ADDON_HwContextDestroy;
1771
1772 instance->game->toAddon->AudioAvailable = ADDON_AudioAvailable;
1773
1774 instance->game->toAddon->HasFeature = ADDON_HasFeature;
1775 instance->game->toAddon->GetTopology = ADDON_GetTopology;
1776 instance->game->toAddon->FreeTopology = ADDON_FreeTopology;
1777 instance->game->toAddon->SetControllerLayouts = ADDON_SetControllerLayouts;
1778 instance->game->toAddon->EnableKeyboard = ADDON_EnableKeyboard;
1779 instance->game->toAddon->EnableMouse = ADDON_EnableMouse;
1780 instance->game->toAddon->ConnectController = ADDON_ConnectController;
1781 instance->game->toAddon->InputEvent = ADDON_InputEvent;
1782
1783 instance->game->toAddon->SerializeSize = ADDON_SerializeSize;
1784 instance->game->toAddon->Serialize = ADDON_Serialize;
1785 instance->game->toAddon->Deserialize = ADDON_Deserialize;
1786 instance->game->toAddon->AchievementStateSize = ADDON_AchievementStateSize;
1787 instance->game->toAddon->SerializeAchievements = ADDON_SerializeAchievements;
1788 instance->game->toAddon->DeserializeAchievements = ADDON_DeserializeAchievements;
1789
1790 instance->game->toAddon->CheatReset = ADDON_CheatReset;
1791 instance->game->toAddon->GetMemory = ADDON_GetMemory;
1792 instance->game->toAddon->SetCheat = ADDON_SetCheat;
1793
1794 instance->game->toAddon->SetRetroAchievementsCredentials =
1795 ADDON_SetRetroAchievementsCredentials;
1796 instance->game->toAddon->RCSetHardcoreEnabled = ADDON_RCSetHardcoreEnabled;
1797 instance->game->toAddon->RCSetEncoreModeEnabled = ADDON_RCSetEncoreModeEnabled;
1798 instance->game->toAddon->ActivateAchievement = ADDON_ActivateAchievement;
1799 instance->game->toAddon->GetCheevoUrlId = ADDON_GetCheevoUrlId;
1800
1801 instance->game->toAddon->GetEjectState = ADDON_GetEjectState;
1802 instance->game->toAddon->SetEjectState = ADDON_SetEjectState;
1803 instance->game->toAddon->GetImageIndex = ADDON_GetImageIndex;
1804 instance->game->toAddon->SetImageIndex = ADDON_SetImageIndex;
1805 instance->game->toAddon->GetImageCount = ADDON_GetImageCount;
1806 instance->game->toAddon->AddImageIndex = ADDON_AddImageIndex;
1807 instance->game->toAddon->ReplaceImageIndex = ADDON_ReplaceImageIndex;
1808 instance->game->toAddon->RemoveImageIndex = ADDON_RemoveImageIndex;
1809 instance->game->toAddon->SetInitialImage = ADDON_SetInitialImage;
1810 instance->game->toAddon->GetImagePath = ADDON_GetImagePath;
1811 instance->game->toAddon->GetImageLabel = ADDON_GetImageLabel;
1812
1813 instance->game->toAddon->FreeString = ADDON_FreeString;
1814
1815 // An older Kodi's table ends before these entries
1816 if (IsInstanceAPIVersionAtLeast(8, 5, 0))
1817 instance->game->toAddon->RCSetAchievementSetEnabled = ADDON_RCSetAchievementSetEnabled;
1818 if (IsInstanceAPIVersionAtLeast(8, 6, 0))
1819 {
1820 instance->game->toAddon->RunFrameSpeculative = ADDON_RunFrameSpeculative;
1821 instance->game->toAddon->SerializeSpeculative = ADDON_SerializeSpeculative;
1822 instance->game->toAddon->DeserializeSpeculative = ADDON_DeserializeSpeculative;
1823 }
1824
1825 m_instanceData = instance->game;
1826 m_instanceData->toAddon->addonInstance = this;
1827 }
1828
1829 // --- Game operations ---------------------------------------------------------
1830
1831 inline static GAME_ERROR ADDON_LoadGame(const AddonInstance_Game* instance, const char* url)
1832 {
1833 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->LoadGame(url);
1834 }
1835
1836 inline static GAME_ERROR ADDON_LoadGameSpecial(const AddonInstance_Game* instance,
1837 SPECIAL_GAME_TYPE type,
1838 const char** urls,
1839 size_t urlCount)
1840 {
1841 std::vector<std::string> urlList;
1842 for (size_t i = 0; i < urlCount; ++i)
1843 {
1844 if (urls[i] != nullptr)
1845 urlList.emplace_back(urls[i]);
1846 }
1847
1848 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1849 ->LoadGameSpecial(type, urlList);
1850 }
1851
1852 inline static GAME_ERROR ADDON_LoadStandalone(const AddonInstance_Game* instance)
1853 {
1854 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->LoadStandalone();
1855 }
1856
1857 inline static GAME_ERROR ADDON_UnloadGame(const AddonInstance_Game* instance)
1858 {
1859 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->UnloadGame();
1860 }
1861
1862 inline static GAME_ERROR ADDON_GetGameTiming(const AddonInstance_Game* instance,
1863 game_system_timing* timing_info)
1864 {
1865 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1866 ->GetGameTiming(*timing_info);
1867 }
1868
1869 inline static GAME_REGION ADDON_GetRegion(const AddonInstance_Game* instance)
1870 {
1871 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetRegion();
1872 }
1873
1874 inline static bool ADDON_RequiresGameLoop(const AddonInstance_Game* instance)
1875 {
1876 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->RequiresGameLoop();
1877 }
1878
1879 inline static GAME_ERROR ADDON_RunFrame(const AddonInstance_Game* instance)
1880 {
1881 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->RunFrame();
1882 }
1883
1884 inline static GAME_ERROR ADDON_RunFrameSpeculative(const AddonInstance_Game* instance)
1885 {
1886 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->RunFrameSpeculative();
1887 }
1888
1889 inline static GAME_ERROR ADDON_SerializeSpeculative(const AddonInstance_Game* instance,
1890 uint8_t* data,
1891 size_t size)
1892 {
1893 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1894 ->SerializeSpeculative(data, size);
1895 }
1896
1897 inline static GAME_ERROR ADDON_DeserializeSpeculative(const AddonInstance_Game* instance,
1898 const uint8_t* data,
1899 size_t size)
1900 {
1901 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1902 ->DeserializeSpeculative(data, size);
1903 }
1904
1905 inline static GAME_ERROR ADDON_Reset(const AddonInstance_Game* instance)
1906 {
1907 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->Reset();
1908 }
1909
1910 // --- Hardware rendering operations -------------------------------------------
1911
1912 inline static GAME_ERROR ADDON_HwContextReset(const AddonInstance_Game* instance)
1913 {
1914 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->HwContextReset();
1915 }
1916
1917 inline static GAME_ERROR ADDON_HwContextDestroy(const AddonInstance_Game* instance)
1918 {
1919 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->HwContextDestroy();
1920 }
1921
1922 // --- Audio operations --------------------------------------------------------
1923
1924 inline static GAME_ERROR ADDON_AudioAvailable(const AddonInstance_Game* instance)
1925 {
1926 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->AudioAvailable();
1927 }
1928
1929 // --- Input operations --------------------------------------------------------
1930
1931 inline static bool ADDON_HasFeature(const AddonInstance_Game* instance,
1932 const char* controller_id,
1933 const char* feature_name)
1934 {
1935 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1936 ->HasFeature(controller_id, feature_name);
1937 }
1938
1939 inline static game_input_topology* ADDON_GetTopology(const AddonInstance_Game* instance)
1940 {
1941 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetTopology();
1942 }
1943
1944 inline static void ADDON_FreeTopology(const AddonInstance_Game* instance,
1945 game_input_topology* topology)
1946 {
1947 static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->FreeTopology(topology);
1948 }
1949
1950 inline static void ADDON_SetControllerLayouts(const AddonInstance_Game* instance,
1951 const game_controller_layout* controllers,
1952 unsigned int controller_count)
1953 {
1954 if (controllers == nullptr)
1955 return;
1956
1957 std::vector<GameControllerLayout> controllerList;
1958 controllerList.reserve(controller_count);
1959 for (unsigned int i = 0; i < controller_count; ++i)
1960 controllerList.emplace_back(controllers[i]);
1961
1962 static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1963 ->SetControllerLayouts(controllerList);
1964 }
1965
1966 inline static bool ADDON_EnableKeyboard(const AddonInstance_Game* instance,
1967 bool enable,
1968 const char* controller_id)
1969 {
1970 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1971 ->EnableKeyboard(enable, controller_id);
1972 }
1973
1974 inline static bool ADDON_EnableMouse(const AddonInstance_Game* instance,
1975 bool enable,
1976 const char* controller_id)
1977 {
1978 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1979 ->EnableMouse(enable, controller_id);
1980 }
1981
1982 inline static bool ADDON_ConnectController(const AddonInstance_Game* instance,
1983 bool connect,
1984 const char* port_address,
1985 const char* controller_id)
1986 {
1987 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1988 ->ConnectController(connect, port_address, controller_id);
1989 }
1990
1991 inline static bool ADDON_InputEvent(const AddonInstance_Game* instance,
1992 const game_input_event* event)
1993 {
1994 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->InputEvent(*event);
1995 }
1996
1997 // --- Serialization operations ------------------------------------------------
1998
1999 inline static size_t ADDON_SerializeSize(const AddonInstance_Game* instance)
2000 {
2001 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->SerializeSize();
2002 }
2003
2004 inline static GAME_ERROR ADDON_Serialize(const AddonInstance_Game* instance,
2005 uint8_t* data,
2006 size_t size)
2007 {
2008 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->Serialize(data, size);
2009 }
2010
2011 inline static GAME_ERROR ADDON_Deserialize(const AddonInstance_Game* instance,
2012 const uint8_t* data,
2013 size_t size)
2014 {
2015 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->Deserialize(data, size);
2016 }
2017
2018 inline static size_t ADDON_AchievementStateSize(const AddonInstance_Game* instance)
2019 {
2020 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->AchievementStateSize();
2021 }
2022
2023 inline static GAME_ERROR ADDON_SerializeAchievements(const AddonInstance_Game* instance,
2024 uint8_t* data,
2025 size_t size)
2026 {
2027 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
2028 ->SerializeAchievements(data, size);
2029 }
2030
2031 inline static GAME_ERROR ADDON_DeserializeAchievements(const AddonInstance_Game* instance,
2032 const uint8_t* data,
2033 size_t size)
2034 {
2035 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
2036 ->DeserializeAchievements(data, size);
2037 }
2038
2039 // --- Cheat operations --------------------------------------------------------
2040
2041 inline static GAME_ERROR ADDON_CheatReset(const AddonInstance_Game* instance)
2042 {
2043 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->CheatReset();
2044 }
2045
2046 inline static GAME_ERROR ADDON_GetMemory(const AddonInstance_Game* instance,
2047 GAME_MEMORY type,
2048 uint8_t** data,
2049 size_t* size)
2050 {
2051 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
2052 ->GetMemory(type, *data, *size);
2053 }
2054
2055 inline static GAME_ERROR ADDON_SetCheat(const AddonInstance_Game* instance,
2056 unsigned int index,
2057 bool enabled,
2058 const char* code)
2059 {
2060 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
2061 ->SetCheat(index, enabled, code);
2062 }
2063
2064 inline static GAME_ERROR ADDON_SetRetroAchievementsCredentials(const AddonInstance_Game* instance,
2065 const char* username,
2066 const char* token)
2067 {
2068 if (username == nullptr || token == nullptr)
2070
2071 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
2072 ->SetRetroAchievementsCredentials(username, token);
2073 }
2074
2075 inline static GAME_ERROR ADDON_RCSetHardcoreEnabled(const AddonInstance_Game* instance,
2076 bool enabled)
2077 {
2078 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
2079 ->RCSetHardcoreEnabled(enabled);
2080 }
2081
2082 inline static GAME_ERROR ADDON_RCSetEncoreModeEnabled(const AddonInstance_Game* instance,
2083 bool enabled)
2084 {
2085 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
2086 ->RCSetEncoreModeEnabled(enabled);
2087 }
2088
2089 inline static GAME_ERROR ADDON_RCSetAchievementSetEnabled(const AddonInstance_Game* instance,
2090 unsigned int setId,
2091 bool enabled)
2092 {
2093 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
2094 ->RCSetAchievementSetEnabled(setId, enabled);
2095 }
2096
2097 inline static GAME_ERROR ADDON_ActivateAchievement(const AddonInstance_Game* instance,
2098 unsigned int cheevoId,
2099 const char* memAddrExpression)
2100 {
2101 if (memAddrExpression == nullptr)
2103
2104 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
2105 ->ActivateAchievement(cheevoId, memAddrExpression);
2106 }
2107
2108 inline static GAME_ERROR ADDON_GetCheevoUrlId(const AddonInstance_Game* instance,
2109 void(__cdecl* callback)(const void* context,
2110 const char* achievementUrl,
2111 unsigned int cheevoId),
2112 const void* context)
2113 {
2114 if (callback == nullptr)
2116
2117 const auto cppCallback =
2118 [callback, context](const std::string& achievementUrl, unsigned int cheevoId)
2119 { callback(context, achievementUrl.c_str(), cheevoId); };
2120
2121 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
2122 ->GetCheevoUrlId(cppCallback);
2123 }
2124
2125 inline static bool ADDON_GetEjectState(const AddonInstance_Game* instance)
2126 {
2127 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetEjectState();
2128 }
2129
2130 inline static GAME_ERROR ADDON_SetEjectState(const AddonInstance_Game* instance, bool ejected)
2131 {
2132 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->SetEjectState(ejected);
2133 }
2134
2135 inline static unsigned int ADDON_GetImageIndex(const AddonInstance_Game* instance)
2136 {
2137 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetImageIndex();
2138 }
2139
2140 inline static GAME_ERROR ADDON_SetImageIndex(const AddonInstance_Game* instance,
2141 unsigned int imageIndex)
2142 {
2143 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->SetImageIndex(imageIndex);
2144 }
2145
2146 inline static unsigned int ADDON_GetImageCount(const AddonInstance_Game* instance)
2147 {
2148 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetImageCount();
2149 }
2150
2151 inline static GAME_ERROR ADDON_AddImageIndex(const AddonInstance_Game* instance)
2152 {
2153 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->AddImageIndex();
2154 }
2155
2156 inline static GAME_ERROR ADDON_ReplaceImageIndex(const AddonInstance_Game* instance,
2157 unsigned int imageIndex,
2158 const char* filePath)
2159 {
2160 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
2161 ->ReplaceImageIndex(imageIndex, filePath ? filePath : "");
2162 }
2163
2164 inline static GAME_ERROR ADDON_RemoveImageIndex(const AddonInstance_Game* instance,
2165 unsigned int imageIndex)
2166 {
2167 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
2168 ->RemoveImageIndex(imageIndex);
2169 }
2170
2171 inline static GAME_ERROR ADDON_SetInitialImage(const AddonInstance_Game* instance,
2172 unsigned int imageIndex,
2173 const char* filePath)
2174 {
2175 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
2176 ->SetInitialImage(imageIndex, filePath ? filePath : "");
2177 }
2178
2179 inline static char* ADDON_GetImagePath(const AddonInstance_Game* instance,
2180 unsigned int imageIndex)
2181 {
2182 std::string cppPath =
2183 static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetImagePath(imageIndex);
2184 if (cppPath.empty())
2185 return nullptr;
2186
2187 char* path = new char[cppPath.size() + 1];
2188 std::copy(cppPath.begin(), cppPath.end(), path);
2189 path[cppPath.size()] = '\0';
2190 return path;
2191 }
2192
2193 inline static char* ADDON_GetImageLabel(const AddonInstance_Game* instance,
2194 unsigned int imageIndex)
2195 {
2196 std::string cppLabel =
2197 static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetImageLabel(imageIndex);
2198 if (cppLabel.empty())
2199 return nullptr;
2200
2201 char* label = new char[cppLabel.size() + 1];
2202 std::copy(cppLabel.begin(), cppLabel.end(), label);
2203 label[cppLabel.size()] = '\0';
2204 return label;
2205 }
2206
2207 inline static void ADDON_FreeString(const AddonInstance_Game* instance, char* str)
2208 {
2209 delete[] str;
2210 }
2211
2212 AddonInstance_Game* m_instanceData;
2213};
2214
2215} /* namespace addon */
2216} /* namespace kodi */
2217
2218#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:796
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:1499
void RCOnSubsetCompleted(const std::string &title)
Callback to Kodi Function Notify Kodi that every achievement of a subset has been earned
Definition Game.h:1527
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:1468
void RCOnAchievementSets(const game_rc_achievement_sets &data)
Callback to Kodi Function Tell Kodi the loaded game's achievement sets, and which set and type each o...
Definition Game.h:1545
virtual GAME_ERROR ActivateAchievement(unsigned int cheevoId, const std::string &memAddrExpression)
Activate an achievement.
Definition Game.h:1235
void RCOnRichPresenceUpdated(const std::string &evaluation)
Callback to Kodi Function Publish the current rich presence evaluation to Kodi
Definition Game.h:1316
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:1592
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:1403
virtual GAME_ERROR RCSetEncoreModeEnabled(bool enabled)
Set whether already-earned achievements can be earned again.
Definition Game.h:1206
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:1450
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:1368
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:1350
void RCOnReset()
Callback to Kodi Function Ask the frontend to reset the game
Definition Game.h:1515
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:1269
void RCOnLoginResult(const game_rc_login_result &data)
Callback to Kodi Function Notify Kodi of the outcome of a login attempt
Definition Game.h:1332
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:1567
virtual GAME_ERROR SetRetroAchievementsCredentials(const std::string &username, const std::string &token)
Set the credentials of the RetroAchievements user.
Definition Game.h:1175
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:1483
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:1419
void RCOnConnectionChanged(bool connected)
Callback to Kodi Function Report a change in connectivity to the RetroAchievements server
Definition Game.h:1387
void RCOnLeaderboardStarted(const game_rc_leaderboard &data)
Callback to Kodi Function Notify Kodi that an attempt at a leaderboard has begun
Definition Game.h:1435
virtual GAME_ERROR RCSetHardcoreEnabled(bool enabled)
Set whether achievements are earned in hardcore mode.
Definition Game.h:1194
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:1300
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:1253
void RCOnAchievementTriggered(const game_rc_achievement_triggered &data)
Callback to Kodi Function Notify Kodi that the player has earned an achievement
Definition Game.h:1284
virtual GAME_ERROR CheatReset()
Reset the cheat system.
Definition Game.h:1136
virtual GAME_ERROR GetMemory(GAME_MEMORY type, uint8_t *&data, size_t &size)
Get a region of memory.
Definition Game.h:1148
virtual GAME_ERROR RCSetAchievementSetEnabled(unsigned int setId, bool enabled)
Turn one of the loaded game's achievement sets on or off.
Definition Game.h:1221
virtual GAME_ERROR SetCheat(unsigned int index, bool enabled, const std::string &code)
Set a cheat code.
Definition Game.h:1163
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:1523
Payload of the achievement progress indicator callbacks
Definition game.h:1545
**Payload of AddonToKodiFuncTable_Game::RCOnAchievementSets**
Definition game.h:1501
**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:1666
virtual unsigned int GetImageCount()
Gets the number of available disk images.
Definition Game.h:1674
virtual std::string GetImageLabel(unsigned int imageIndex)
Gets a user-friendly label for a disk image.
Definition Game.h:1749
virtual GAME_ERROR ReplaceImageIndex(unsigned int imageIndex, const std::string &filePath)
Replaces the disk image at the given index.
Definition Game.h:1696
virtual GAME_ERROR RemoveImageIndex(unsigned int imageIndex)
Removes the disk image at the given index.
Definition Game.h:1711
virtual std::string GetImagePath(unsigned int imageIndex)
Gets the full path of a disk image.
Definition Game.h:1739
virtual unsigned int GetImageIndex()
Gets the index of the currently inserted disk image.
Definition Game.h:1654
virtual GAME_ERROR SetInitialImage(unsigned int imageIndex, const std::string &filePath)
Sets which image should be initially inserted on load.
Definition Game.h:1726
virtual GAME_ERROR SetEjectState(bool ejected)
Opens or closes the virtual disk tray.
Definition Game.h:1645
virtual GAME_ERROR AddImageIndex()
Adds a new disk image slot.
Definition Game.h:1683
virtual bool GetEjectState()
Returns whether the virtual disk tray is currently ejected.
Definition Game.h:1632
virtual GAME_ERROR HwContextDestroy()
Called before the context is destroyed.
Definition Game.h:748
virtual GAME_ERROR HwContextReset()
Invalidates the current HW context and reinitializes GPU resources.
Definition Game.h:738
bool EnableHardwareRendering(const game_hw_rendering_properties &properties)
Callback to Kodi Function Enable hardware rendering functionality
Definition Game.h:722
game_proc_address_t HwGetProcAddress(const char *sym)
Callback to Kodi Function Get a symbol from the hardware context
Definition Game.h:759
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:831
virtual bool InputEvent(const game_input_event &event)
Notify the add-on of an input event.
Definition Game.h:954
virtual void FreeTopology(game_input_topology *topology)
Free the topology's resources.
Definition Game.h:856
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:939
virtual void SetControllerLayouts(const std::vector< kodi::addon::GameControllerLayout > &controllers)
Set the layouts for known controllers.
Definition Game.h:867
virtual bool EnableMouse(bool enable, const std::string &controller_id)
Enable/disable mouse input using the specified controller.
Definition Game.h:892
virtual bool EnableKeyboard(bool enable, const std::string &controller_id)
Enable/disable keyboard input using the specified controller.
Definition Game.h:881
bool KodiInputEvent(const game_input_event &event)
Callback to Kodi Function Notify the port of an input event
Definition Game.h:969
virtual game_input_topology * GetTopology()
Get the input topology that specifies which controllers can be connected.
Definition Game.h:848
bool IsOpen() const
Check if the stream opened correctly, e.g. after calling the constructor.
Definition Game.h:685
void ReleaseBuffer(game_stream_buffer &buffer)
Free an allocated buffer.
Definition Game.h:665
void Close()
Free the specified stream.
Definition Game.h:592
bool GetBuffer(unsigned int width, unsigned int height, game_stream_buffer &buffer)
Get a buffer for zero-copy stream data.
Definition Game.h:621
void AddData(const game_stream_packet &packet)
Add a data packet to a stream.
Definition Game.h:645
bool Open(const game_stream_properties &properties)
Create a stream for gameplay data.
Definition Game.h:558
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:497
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:517
virtual GAME_ERROR Reset()
Reset the current game.
Definition Game.h:429
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:480
virtual GAME_ERROR RunFrameSpeculative()
Run a frame that the frontend will roll back afterwards.
Definition Game.h:421
void CloseGame(void)
Callback to Kodi Function Requests the frontend to stop the current game
Definition Game.h:438
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:451
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 GAME_ERROR DeserializeSpeculative(const uint8_t *data, size_t size)
Deserialize a state saved by SerializeSpeculative()
Definition Game.h:1055
virtual size_t AchievementStateSize()
How many bytes the achievement runtime's state needs right now.
Definition Game.h:1070
virtual GAME_ERROR SerializeAchievements(uint8_t *data, size_t size)
Write the achievement runtime's state.
Definition Game.h:1082
virtual GAME_ERROR DeserializeAchievements(const uint8_t *data, size_t size)
Restore achievement state written by SerializeAchievements()
Definition Game.h:1104
virtual GAME_ERROR SerializeSpeculative(uint8_t *data, size_t size)
Serialize the state of the game for run-ahead.
Definition Game.h:1041
virtual GAME_ERROR Deserialize(const uint8_t *data, size_t size)
Deserialize the game from the given state.
Definition Game.h:1022
virtual GAME_ERROR Serialize(uint8_t *data, size_t size)
Serialize the state of the game.
Definition Game.h:1011
virtual size_t SerializeSize()
Get the number of bytes required to serialize the game.
Definition Game.h:1000
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:1827
Game callbacks.
Definition game.h:1653
bool(* StartStream)(KODI_HANDLE, KODI_GAME_STREAM_HANDLE)
Reset a prepared hardware stream after installing its returned handle.
Definition game.h:1717
Definition addon_base.h:269
Internal used structure to have stored C API data above and available for everything below.
Definition AddonBase.h:74