Kodi Development 22.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
283
284 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
285
286 //============================================================================
305
306 //============================================================================
313 virtual GAME_ERROR LoadGame(const std::string& url) { return GAME_ERROR_NOT_IMPLEMENTED; }
314 //----------------------------------------------------------------------------
315
316 //============================================================================
324 virtual GAME_ERROR LoadGameSpecial(SPECIAL_GAME_TYPE type, const std::vector<std::string>& urls)
325 {
327 }
328 //----------------------------------------------------------------------------
329
330 //============================================================================
341 //----------------------------------------------------------------------------
342
343 //============================================================================
351 //----------------------------------------------------------------------------
352
353 //============================================================================
361 {
363 }
364 //----------------------------------------------------------------------------
365
366 //============================================================================
372 //----------------------------------------------------------------------------
373
374 //============================================================================
382 virtual bool RequiresGameLoop() { return false; }
383 //----------------------------------------------------------------------------
384
385 //============================================================================
391 //----------------------------------------------------------------------------
392
393 //============================================================================
399 //----------------------------------------------------------------------------
400
401 //==========================================================================
407 void CloseGame(void) { m_instanceData->toKodi->CloseGame(m_instanceData->toKodi->kodiInstance); }
408 //----------------------------------------------------------------------------
409
410 //============================================================================
433 {
434 return m_instanceData->toKodi->GetPlaybackSpeed(m_instanceData->toKodi->kodiInstance);
435 }
436 //----------------------------------------------------------------------------
437
438 //============================================================================
449 void SetGameTiming(const game_system_timing& timingInfo)
450 {
451 m_instanceData->toKodi->SetGameTiming(m_instanceData->toKodi->kodiInstance, &timingInfo);
452 }
453 //----------------------------------------------------------------------------
454
455 //============================================================================
467 {
468 public:
469 CStream() = default;
470
471 CStream(const game_stream_properties& properties) { Open(properties); }
472
473 ~CStream() { Close(); }
474
475 //==========================================================================
488 bool Open(const game_stream_properties& properties)
489 {
490 if (!CPrivateBase::m_interface->globalSingleInstance)
491 return false;
492
493 if (m_handle)
494 {
495 kodi::Log(ADDON_LOG_INFO, "kodi::addon::CInstanceGame::CStream already reopened");
496 Close();
497 }
498
500 *static_cast<CInstanceGame*>(CPrivateBase::m_interface->globalSingleInstance)
501 ->m_instanceData->toKodi;
502 m_handle = cb.OpenStream(cb.kodiInstance, &properties);
503 if (m_handle && properties.type == GAME_STREAM_HW_FRAMEBUFFER)
504 {
505 const KODI_GAME_STREAM_HANDLE handle = m_handle;
506 const bool started = cb.StartStream(cb.kodiInstance, handle);
507 if (m_handle != handle)
508 return false;
509 if (!started)
510 Close();
511 }
512 return m_handle != nullptr;
513 }
514 //--------------------------------------------------------------------------
515
516 //==========================================================================
522 void Close()
523 {
524 if (!m_handle || !CPrivateBase::m_interface->globalSingleInstance)
525 return;
526
528 *static_cast<CInstanceGame*>(CPrivateBase::m_interface->globalSingleInstance)
529 ->m_instanceData->toKodi;
530 const KODI_GAME_STREAM_HANDLE handle = m_handle;
531 cb.CloseStream(cb.kodiInstance, handle);
532 if (m_handle == handle)
533 m_handle = nullptr;
534 }
535 //--------------------------------------------------------------------------
536
537 //==========================================================================
551 bool GetBuffer(unsigned int width, unsigned int height, game_stream_buffer& buffer)
552 {
553 if (!m_handle || !CPrivateBase::m_interface->globalSingleInstance)
554 return false;
555
557 *static_cast<CInstanceGame*>(CPrivateBase::m_interface->globalSingleInstance)
558 ->m_instanceData->toKodi;
559 return cb.GetStreamBuffer(cb.kodiInstance, m_handle, width, height, &buffer);
560 }
561 //--------------------------------------------------------------------------
562
563 //==========================================================================
575 void AddData(const game_stream_packet& packet)
576 {
577 if (!m_handle || !CPrivateBase::m_interface->globalSingleInstance)
578 return;
579
581 *static_cast<CInstanceGame*>(CPrivateBase::m_interface->globalSingleInstance)
582 ->m_instanceData->toKodi;
583 cb.AddStreamData(cb.kodiInstance, m_handle, &packet);
584 }
585 //--------------------------------------------------------------------------
586
587 //==========================================================================
596 {
597 if (!m_handle || !CPrivateBase::m_interface->globalSingleInstance)
598 return;
599
601 *static_cast<CInstanceGame*>(CPrivateBase::m_interface->globalSingleInstance)
602 ->m_instanceData->toKodi;
603 cb.ReleaseStreamBuffer(cb.kodiInstance, m_handle, &buffer);
604 }
605 //--------------------------------------------------------------------------
606
607 //==========================================================================
615 bool IsOpen() const { return m_handle != nullptr; }
616 //--------------------------------------------------------------------------
617
618 private:
619 KODI_GAME_STREAM_HANDLE m_handle = nullptr;
620 };
622
624
625 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
626
627 //============================================================================
643
644 //==========================================================================
653 {
654 return m_instanceData->toKodi->EnableHardwareRendering(m_instanceData->toKodi->kodiInstance,
655 &properties);
656 }
657 //----------------------------------------------------------------------------
658
659 //============================================================================
669 //----------------------------------------------------------------------------
670
671 //============================================================================
679
680 //============================================================================
690 {
691 return m_instanceData->toKodi->HwGetProcAddress(m_instanceData->toKodi->kodiInstance, sym);
692 }
693 //----------------------------------------------------------------------------
694
696
697 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
698
699 //============================================================================
715
716 //==========================================================================
727 //--------------------------------------------------------------------------
728
730
731 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
732
733 //============================================================================
748
749 //============================================================================
761 virtual bool HasFeature(const std::string& controller_id, const std::string& feature_name)
762 {
763 return false;
764 }
765 //----------------------------------------------------------------------------
766
767 //============================================================================
778 virtual game_input_topology* GetTopology() { return nullptr; }
779 //----------------------------------------------------------------------------
780
781 //============================================================================
786 virtual void FreeTopology(game_input_topology* topology) {}
787 //----------------------------------------------------------------------------
788
789 //============================================================================
798 const std::vector<kodi::addon::GameControllerLayout>& controllers)
799 {
800 }
801 //----------------------------------------------------------------------------
802
803 //============================================================================
811 virtual bool EnableKeyboard(bool enable, const std::string& controller_id) { return false; }
812 //----------------------------------------------------------------------------
813
814 //============================================================================
822 virtual bool EnableMouse(bool enable, const std::string& controller_id) { return false; }
823 //--------------------------------------------------------------------------
824
825 //==========================================================================
869 virtual bool ConnectController(bool connect,
870 const std::string& port_address,
871 const std::string& controller_id)
872 {
873 return false;
874 }
875 //----------------------------------------------------------------------------
876
877 //============================================================================
884 virtual bool InputEvent(const game_input_event& event) { return false; }
885 //----------------------------------------------------------------------------
886
887 //============================================================================
900 {
901 return m_instanceData->toKodi->InputEvent(m_instanceData->toKodi->kodiInstance, &event);
902 }
903 //----------------------------------------------------------------------------
904
906
907 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
908
909 //============================================================================
924
925 //============================================================================
930 virtual size_t SerializeSize() { return 0; }
931 //----------------------------------------------------------------------------
932
933 //============================================================================
941 virtual GAME_ERROR Serialize(uint8_t* data, size_t size) { return GAME_ERROR_NOT_IMPLEMENTED; }
942 //----------------------------------------------------------------------------
943
944 //============================================================================
952 virtual GAME_ERROR Deserialize(const uint8_t* data, size_t size)
953 {
955 }
956 //----------------------------------------------------------------------------
957
958 //============================================================================
967 virtual size_t AchievementStateSize() { return 0; }
968 //----------------------------------------------------------------------------
969
970 //============================================================================
979 virtual GAME_ERROR SerializeAchievements(uint8_t* data, size_t size)
980 {
982 }
983 //----------------------------------------------------------------------------
984
985 //============================================================================
1001 virtual GAME_ERROR DeserializeAchievements(const uint8_t* data, size_t size)
1002 {
1004 }
1005 //----------------------------------------------------------------------------
1006
1008
1009 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
1010
1011 //============================================================================
1027
1028 //============================================================================
1034 //----------------------------------------------------------------------------
1035
1036 //============================================================================
1045 virtual GAME_ERROR GetMemory(GAME_MEMORY type, uint8_t*& data, size_t& size)
1046 {
1048 }
1049 //----------------------------------------------------------------------------
1050
1051 //============================================================================
1060 virtual GAME_ERROR SetCheat(unsigned int index, bool enabled, const std::string& code)
1061 {
1063 }
1064 //============================================================================
1072 virtual GAME_ERROR SetRetroAchievementsCredentials(const std::string& username,
1073 const std::string& token)
1074 {
1076 }
1077
1078 //============================================================================
1092 //----------------------------------------------------------------------------
1093
1094 //============================================================================
1104 //----------------------------------------------------------------------------
1105 //============================================================================
1114 virtual GAME_ERROR ActivateAchievement(unsigned int cheevoId,
1115 const std::string& memAddrExpression)
1116 {
1118 }
1119
1120 //============================================================================
1133 const std::function<void(const std::string& achievementUrl, unsigned int cheevoId)>& callback)
1134 {
1136 }
1137 //============================================================================
1149 {
1150 m_instanceData->toKodi->RCOnGameLoaded(m_instanceData->toKodi->kodiInstance, &data);
1151 }
1152
1153 //============================================================================
1164 {
1165 m_instanceData->toKodi->RCOnAchievementTriggered(m_instanceData->toKodi->kodiInstance, &data);
1166 }
1167
1168 //============================================================================
1179 void RCOnGameCompleted(const std::string& title, bool hardcore)
1180 {
1181 m_instanceData->toKodi->RCOnGameCompleted(m_instanceData->toKodi->kodiInstance, title.c_str(),
1182 hardcore);
1183 }
1184
1185 //============================================================================
1195 void RCOnRichPresenceUpdated(const std::string& evaluation)
1196 {
1197 m_instanceData->toKodi->RCOnRichPresenceUpdated(m_instanceData->toKodi->kodiInstance,
1198 evaluation.c_str());
1199 }
1200
1201 //============================================================================
1212 {
1213 m_instanceData->toKodi->RCOnLoginResult(m_instanceData->toKodi->kodiInstance, &data);
1214 }
1215
1216 //============================================================================
1229 void RCOnAchievementProgress(const std::vector<game_rc_achievement_progress>& progress)
1230 {
1231 m_instanceData->toKodi->RCOnAchievementProgress(m_instanceData->toKodi->kodiInstance,
1232 progress.empty() ? nullptr : progress.data(),
1233 static_cast<unsigned int>(progress.size()));
1234 }
1235
1236 //============================================================================
1247 void RCOnServerError(const std::string& message, const std::string& api)
1248 {
1249 m_instanceData->toKodi->RCOnServerError(m_instanceData->toKodi->kodiInstance, message.c_str(),
1250 api.c_str());
1251 }
1252
1253 //============================================================================
1266 void RCOnConnectionChanged(bool connected)
1267 {
1268 m_instanceData->toKodi->RCOnConnectionChanged(m_instanceData->toKodi->kodiInstance, connected);
1269 }
1270
1271 //============================================================================
1283 {
1284 m_instanceData->toKodi->RCOnChallengeIndicator(m_instanceData->toKodi->kodiInstance, &data,
1285 show);
1286 }
1287
1288 //============================================================================
1299 {
1300 m_instanceData->toKodi->RCOnAchievementProgressUpdate(m_instanceData->toKodi->kodiInstance,
1301 &data);
1302 }
1303
1304 //============================================================================
1315 {
1316 m_instanceData->toKodi->RCOnLeaderboardStarted(m_instanceData->toKodi->kodiInstance, &data);
1317 }
1318
1319 //============================================================================
1330 {
1331 m_instanceData->toKodi->RCOnLeaderboardFailed(m_instanceData->toKodi->kodiInstance, &data);
1332 }
1333
1334 //============================================================================
1348 {
1349 m_instanceData->toKodi->RCOnLeaderboardSubmitted(m_instanceData->toKodi->kodiInstance, &data);
1350 }
1351
1352 //============================================================================
1363 {
1364 m_instanceData->toKodi->RCOnLeaderboardTrackerUpdate(m_instanceData->toKodi->kodiInstance,
1365 &data);
1366 }
1367
1368 //============================================================================
1379 {
1380 m_instanceData->toKodi->RCOnLeaderboardScoreboard(m_instanceData->toKodi->kodiInstance, &data);
1381 }
1382
1383 //============================================================================
1394 void RCOnReset() { m_instanceData->toKodi->RCOnReset(m_instanceData->toKodi->kodiInstance); }
1395
1396 //============================================================================
1406 void RCOnSubsetCompleted(const std::string& title)
1407 {
1408 m_instanceData->toKodi->RCOnSubsetCompleted(m_instanceData->toKodi->kodiInstance,
1409 title.c_str());
1410 }
1411
1412 //============================================================================
1429 bool show)
1430 {
1431 if (show)
1432 m_instanceData->toKodi->RCOnAchievementProgressShow(m_instanceData->toKodi->kodiInstance,
1433 &data);
1434 else
1435 m_instanceData->toKodi->RCOnAchievementProgressHide(m_instanceData->toKodi->kodiInstance,
1436 &data);
1437 }
1438
1439 //============================================================================
1454 {
1455 if (show)
1456 m_instanceData->toKodi->RCOnLeaderboardTrackerShow(m_instanceData->toKodi->kodiInstance,
1457 &data);
1458 else
1459 m_instanceData->toKodi->RCOnLeaderboardTrackerHide(m_instanceData->toKodi->kodiInstance,
1460 &data);
1461 }
1462
1463 //----------------------------------------------------------------------------
1464
1466
1467 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
1468
1469 //============================================================================
1484
1485 //============================================================================
1493 virtual bool GetEjectState() { return false; }
1494 //----------------------------------------------------------------------------
1495
1496 //============================================================================
1506 virtual GAME_ERROR SetEjectState(bool ejected) { return GAME_ERROR_NOT_IMPLEMENTED; }
1507 //----------------------------------------------------------------------------
1508
1509 //============================================================================
1515 virtual unsigned int GetImageIndex() { return 0; }
1516 //----------------------------------------------------------------------------
1517
1518 //============================================================================
1527 virtual GAME_ERROR SetImageIndex(unsigned int imageIndex) { return GAME_ERROR_NOT_IMPLEMENTED; }
1528 //----------------------------------------------------------------------------
1529
1530 //============================================================================
1535 virtual unsigned int GetImageCount() { return 0; }
1536 //----------------------------------------------------------------------------
1537
1538 //============================================================================
1545 //----------------------------------------------------------------------------
1546
1547 //============================================================================
1557 virtual GAME_ERROR ReplaceImageIndex(unsigned int imageIndex, const std::string& filePath)
1558 {
1560 }
1561 //----------------------------------------------------------------------------
1562
1563 //============================================================================
1572 virtual GAME_ERROR RemoveImageIndex(unsigned int imageIndex)
1573 {
1575 }
1576 //----------------------------------------------------------------------------
1577
1578 //============================================================================
1587 virtual GAME_ERROR SetInitialImage(unsigned int imageIndex, const std::string& filePath)
1588 {
1590 }
1591 //----------------------------------------------------------------------------
1592
1593 //============================================================================
1600 virtual std::string GetImagePath(unsigned int imageIndex) { return ""; }
1601 //----------------------------------------------------------------------------
1602
1603 //============================================================================
1610 virtual std::string GetImageLabel(unsigned int imageIndex) { return ""; }
1611 //----------------------------------------------------------------------------
1612
1614
1615private:
1616 void SetAddonStruct(KODI_ADDON_INSTANCE_STRUCT* instance)
1617 {
1618 instance->hdl = this;
1619
1620 instance->game->toAddon->LoadGame = ADDON_LoadGame;
1621 instance->game->toAddon->LoadGameSpecial = ADDON_LoadGameSpecial;
1622 instance->game->toAddon->LoadStandalone = ADDON_LoadStandalone;
1623 instance->game->toAddon->UnloadGame = ADDON_UnloadGame;
1624 instance->game->toAddon->GetGameTiming = ADDON_GetGameTiming;
1625 instance->game->toAddon->GetRegion = ADDON_GetRegion;
1626 instance->game->toAddon->RequiresGameLoop = ADDON_RequiresGameLoop;
1627 instance->game->toAddon->RunFrame = ADDON_RunFrame;
1628 instance->game->toAddon->Reset = ADDON_Reset;
1629
1630 instance->game->toAddon->HwContextReset = ADDON_HwContextReset;
1631 instance->game->toAddon->HwContextDestroy = ADDON_HwContextDestroy;
1632
1633 instance->game->toAddon->AudioAvailable = ADDON_AudioAvailable;
1634
1635 instance->game->toAddon->HasFeature = ADDON_HasFeature;
1636 instance->game->toAddon->GetTopology = ADDON_GetTopology;
1637 instance->game->toAddon->FreeTopology = ADDON_FreeTopology;
1638 instance->game->toAddon->SetControllerLayouts = ADDON_SetControllerLayouts;
1639 instance->game->toAddon->EnableKeyboard = ADDON_EnableKeyboard;
1640 instance->game->toAddon->EnableMouse = ADDON_EnableMouse;
1641 instance->game->toAddon->ConnectController = ADDON_ConnectController;
1642 instance->game->toAddon->InputEvent = ADDON_InputEvent;
1643
1644 instance->game->toAddon->SerializeSize = ADDON_SerializeSize;
1645 instance->game->toAddon->Serialize = ADDON_Serialize;
1646 instance->game->toAddon->Deserialize = ADDON_Deserialize;
1647 instance->game->toAddon->AchievementStateSize = ADDON_AchievementStateSize;
1648 instance->game->toAddon->SerializeAchievements = ADDON_SerializeAchievements;
1649 instance->game->toAddon->DeserializeAchievements = ADDON_DeserializeAchievements;
1650
1651 instance->game->toAddon->CheatReset = ADDON_CheatReset;
1652 instance->game->toAddon->GetMemory = ADDON_GetMemory;
1653 instance->game->toAddon->SetCheat = ADDON_SetCheat;
1654
1655 instance->game->toAddon->SetRetroAchievementsCredentials =
1656 ADDON_SetRetroAchievementsCredentials;
1657 instance->game->toAddon->RCSetHardcoreEnabled = ADDON_RCSetHardcoreEnabled;
1658 instance->game->toAddon->RCSetEncoreModeEnabled = ADDON_RCSetEncoreModeEnabled;
1659 instance->game->toAddon->ActivateAchievement = ADDON_ActivateAchievement;
1660 instance->game->toAddon->GetCheevoUrlId = ADDON_GetCheevoUrlId;
1661
1662 instance->game->toAddon->GetEjectState = ADDON_GetEjectState;
1663 instance->game->toAddon->SetEjectState = ADDON_SetEjectState;
1664 instance->game->toAddon->GetImageIndex = ADDON_GetImageIndex;
1665 instance->game->toAddon->SetImageIndex = ADDON_SetImageIndex;
1666 instance->game->toAddon->GetImageCount = ADDON_GetImageCount;
1667 instance->game->toAddon->AddImageIndex = ADDON_AddImageIndex;
1668 instance->game->toAddon->ReplaceImageIndex = ADDON_ReplaceImageIndex;
1669 instance->game->toAddon->RemoveImageIndex = ADDON_RemoveImageIndex;
1670 instance->game->toAddon->SetInitialImage = ADDON_SetInitialImage;
1671 instance->game->toAddon->GetImagePath = ADDON_GetImagePath;
1672 instance->game->toAddon->GetImageLabel = ADDON_GetImageLabel;
1673
1674 instance->game->toAddon->FreeString = ADDON_FreeString;
1675
1676 m_instanceData = instance->game;
1677 m_instanceData->toAddon->addonInstance = this;
1678 }
1679
1680 // --- Game operations ---------------------------------------------------------
1681
1682 inline static GAME_ERROR ADDON_LoadGame(const AddonInstance_Game* instance, const char* url)
1683 {
1684 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->LoadGame(url);
1685 }
1686
1687 inline static GAME_ERROR ADDON_LoadGameSpecial(const AddonInstance_Game* instance,
1688 SPECIAL_GAME_TYPE type,
1689 const char** urls,
1690 size_t urlCount)
1691 {
1692 std::vector<std::string> urlList;
1693 for (size_t i = 0; i < urlCount; ++i)
1694 {
1695 if (urls[i] != nullptr)
1696 urlList.emplace_back(urls[i]);
1697 }
1698
1699 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1700 ->LoadGameSpecial(type, urlList);
1701 }
1702
1703 inline static GAME_ERROR ADDON_LoadStandalone(const AddonInstance_Game* instance)
1704 {
1705 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->LoadStandalone();
1706 }
1707
1708 inline static GAME_ERROR ADDON_UnloadGame(const AddonInstance_Game* instance)
1709 {
1710 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->UnloadGame();
1711 }
1712
1713 inline static GAME_ERROR ADDON_GetGameTiming(const AddonInstance_Game* instance,
1714 game_system_timing* timing_info)
1715 {
1716 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1717 ->GetGameTiming(*timing_info);
1718 }
1719
1720 inline static GAME_REGION ADDON_GetRegion(const AddonInstance_Game* instance)
1721 {
1722 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetRegion();
1723 }
1724
1725 inline static bool ADDON_RequiresGameLoop(const AddonInstance_Game* instance)
1726 {
1727 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->RequiresGameLoop();
1728 }
1729
1730 inline static GAME_ERROR ADDON_RunFrame(const AddonInstance_Game* instance)
1731 {
1732 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->RunFrame();
1733 }
1734
1735 inline static GAME_ERROR ADDON_Reset(const AddonInstance_Game* instance)
1736 {
1737 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->Reset();
1738 }
1739
1740 // --- Hardware rendering operations -------------------------------------------
1741
1742 inline static GAME_ERROR ADDON_HwContextReset(const AddonInstance_Game* instance)
1743 {
1744 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->HwContextReset();
1745 }
1746
1747 inline static GAME_ERROR ADDON_HwContextDestroy(const AddonInstance_Game* instance)
1748 {
1749 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->HwContextDestroy();
1750 }
1751
1752 // --- Audio operations --------------------------------------------------------
1753
1754 inline static GAME_ERROR ADDON_AudioAvailable(const AddonInstance_Game* instance)
1755 {
1756 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->AudioAvailable();
1757 }
1758
1759 // --- Input operations --------------------------------------------------------
1760
1761 inline static bool ADDON_HasFeature(const AddonInstance_Game* instance,
1762 const char* controller_id,
1763 const char* feature_name)
1764 {
1765 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1766 ->HasFeature(controller_id, feature_name);
1767 }
1768
1769 inline static game_input_topology* ADDON_GetTopology(const AddonInstance_Game* instance)
1770 {
1771 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetTopology();
1772 }
1773
1774 inline static void ADDON_FreeTopology(const AddonInstance_Game* instance,
1775 game_input_topology* topology)
1776 {
1777 static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->FreeTopology(topology);
1778 }
1779
1780 inline static void ADDON_SetControllerLayouts(const AddonInstance_Game* instance,
1781 const game_controller_layout* controllers,
1782 unsigned int controller_count)
1783 {
1784 if (controllers == nullptr)
1785 return;
1786
1787 std::vector<GameControllerLayout> controllerList;
1788 controllerList.reserve(controller_count);
1789 for (unsigned int i = 0; i < controller_count; ++i)
1790 controllerList.emplace_back(controllers[i]);
1791
1792 static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1793 ->SetControllerLayouts(controllerList);
1794 }
1795
1796 inline static bool ADDON_EnableKeyboard(const AddonInstance_Game* instance,
1797 bool enable,
1798 const char* controller_id)
1799 {
1800 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1801 ->EnableKeyboard(enable, controller_id);
1802 }
1803
1804 inline static bool ADDON_EnableMouse(const AddonInstance_Game* instance,
1805 bool enable,
1806 const char* controller_id)
1807 {
1808 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1809 ->EnableMouse(enable, controller_id);
1810 }
1811
1812 inline static bool ADDON_ConnectController(const AddonInstance_Game* instance,
1813 bool connect,
1814 const char* port_address,
1815 const char* controller_id)
1816 {
1817 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1818 ->ConnectController(connect, port_address, controller_id);
1819 }
1820
1821 inline static bool ADDON_InputEvent(const AddonInstance_Game* instance,
1822 const game_input_event* event)
1823 {
1824 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->InputEvent(*event);
1825 }
1826
1827 // --- Serialization operations ------------------------------------------------
1828
1829 inline static size_t ADDON_SerializeSize(const AddonInstance_Game* instance)
1830 {
1831 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->SerializeSize();
1832 }
1833
1834 inline static GAME_ERROR ADDON_Serialize(const AddonInstance_Game* instance,
1835 uint8_t* data,
1836 size_t size)
1837 {
1838 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->Serialize(data, size);
1839 }
1840
1841 inline static GAME_ERROR ADDON_Deserialize(const AddonInstance_Game* instance,
1842 const uint8_t* data,
1843 size_t size)
1844 {
1845 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->Deserialize(data, size);
1846 }
1847
1848 inline static size_t ADDON_AchievementStateSize(const AddonInstance_Game* instance)
1849 {
1850 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->AchievementStateSize();
1851 }
1852
1853 inline static GAME_ERROR ADDON_SerializeAchievements(const AddonInstance_Game* instance,
1854 uint8_t* data,
1855 size_t size)
1856 {
1857 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1858 ->SerializeAchievements(data, size);
1859 }
1860
1861 inline static GAME_ERROR ADDON_DeserializeAchievements(const AddonInstance_Game* instance,
1862 const uint8_t* data,
1863 size_t size)
1864 {
1865 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1866 ->DeserializeAchievements(data, size);
1867 }
1868
1869 // --- Cheat operations --------------------------------------------------------
1870
1871 inline static GAME_ERROR ADDON_CheatReset(const AddonInstance_Game* instance)
1872 {
1873 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->CheatReset();
1874 }
1875
1876 inline static GAME_ERROR ADDON_GetMemory(const AddonInstance_Game* instance,
1877 GAME_MEMORY type,
1878 uint8_t** data,
1879 size_t* size)
1880 {
1881 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1882 ->GetMemory(type, *data, *size);
1883 }
1884
1885 inline static GAME_ERROR ADDON_SetCheat(const AddonInstance_Game* instance,
1886 unsigned int index,
1887 bool enabled,
1888 const char* code)
1889 {
1890 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1891 ->SetCheat(index, enabled, code);
1892 }
1893
1894 inline static GAME_ERROR ADDON_SetRetroAchievementsCredentials(const AddonInstance_Game* instance,
1895 const char* username,
1896 const char* token)
1897 {
1898 if (username == nullptr || token == nullptr)
1900
1901 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1902 ->SetRetroAchievementsCredentials(username, token);
1903 }
1904
1905 inline static GAME_ERROR ADDON_RCSetHardcoreEnabled(const AddonInstance_Game* instance,
1906 bool enabled)
1907 {
1908 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1909 ->RCSetHardcoreEnabled(enabled);
1910 }
1911
1912 inline static GAME_ERROR ADDON_RCSetEncoreModeEnabled(const AddonInstance_Game* instance,
1913 bool enabled)
1914 {
1915 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1916 ->RCSetEncoreModeEnabled(enabled);
1917 }
1918
1919 inline static GAME_ERROR ADDON_ActivateAchievement(const AddonInstance_Game* instance,
1920 unsigned int cheevoId,
1921 const char* memAddrExpression)
1922 {
1923 if (memAddrExpression == nullptr)
1925
1926 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1927 ->ActivateAchievement(cheevoId, memAddrExpression);
1928 }
1929
1930 inline static GAME_ERROR ADDON_GetCheevoUrlId(const AddonInstance_Game* instance,
1931 void(__cdecl* callback)(const void* context,
1932 const char* achievementUrl,
1933 unsigned int cheevoId),
1934 const void* context)
1935 {
1936 if (callback == nullptr)
1938
1939 const auto cppCallback =
1940 [callback, context](const std::string& achievementUrl, unsigned int cheevoId)
1941 { callback(context, achievementUrl.c_str(), cheevoId); };
1942
1943 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1944 ->GetCheevoUrlId(cppCallback);
1945 }
1946
1947 inline static bool ADDON_GetEjectState(const AddonInstance_Game* instance)
1948 {
1949 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetEjectState();
1950 }
1951
1952 inline static GAME_ERROR ADDON_SetEjectState(const AddonInstance_Game* instance, bool ejected)
1953 {
1954 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->SetEjectState(ejected);
1955 }
1956
1957 inline static unsigned int ADDON_GetImageIndex(const AddonInstance_Game* instance)
1958 {
1959 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetImageIndex();
1960 }
1961
1962 inline static GAME_ERROR ADDON_SetImageIndex(const AddonInstance_Game* instance,
1963 unsigned int imageIndex)
1964 {
1965 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->SetImageIndex(imageIndex);
1966 }
1967
1968 inline static unsigned int ADDON_GetImageCount(const AddonInstance_Game* instance)
1969 {
1970 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetImageCount();
1971 }
1972
1973 inline static GAME_ERROR ADDON_AddImageIndex(const AddonInstance_Game* instance)
1974 {
1975 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->AddImageIndex();
1976 }
1977
1978 inline static GAME_ERROR ADDON_ReplaceImageIndex(const AddonInstance_Game* instance,
1979 unsigned int imageIndex,
1980 const char* filePath)
1981 {
1982 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1983 ->ReplaceImageIndex(imageIndex, filePath ? filePath : "");
1984 }
1985
1986 inline static GAME_ERROR ADDON_RemoveImageIndex(const AddonInstance_Game* instance,
1987 unsigned int imageIndex)
1988 {
1989 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1990 ->RemoveImageIndex(imageIndex);
1991 }
1992
1993 inline static GAME_ERROR ADDON_SetInitialImage(const AddonInstance_Game* instance,
1994 unsigned int imageIndex,
1995 const char* filePath)
1996 {
1997 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1998 ->SetInitialImage(imageIndex, filePath ? filePath : "");
1999 }
2000
2001 inline static char* ADDON_GetImagePath(const AddonInstance_Game* instance,
2002 unsigned int imageIndex)
2003 {
2004 std::string cppPath =
2005 static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetImagePath(imageIndex);
2006 if (cppPath.empty())
2007 return nullptr;
2008
2009 char* path = new char[cppPath.size() + 1];
2010 std::copy(cppPath.begin(), cppPath.end(), path);
2011 path[cppPath.size()] = '\0';
2012 return path;
2013 }
2014
2015 inline static char* ADDON_GetImageLabel(const AddonInstance_Game* instance,
2016 unsigned int imageIndex)
2017 {
2018 std::string cppLabel =
2019 static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetImageLabel(imageIndex);
2020 if (cppLabel.empty())
2021 return nullptr;
2022
2023 char* label = new char[cppLabel.size() + 1];
2024 std::copy(cppLabel.begin(), cppLabel.end(), label);
2025 label[cppLabel.size()] = '\0';
2026 return label;
2027 }
2028
2029 inline static void ADDON_FreeString(const AddonInstance_Game* instance, char* str)
2030 {
2031 delete[] str;
2032 }
2033
2034 AddonInstance_Game* m_instanceData;
2035};
2036
2037} /* namespace addon */
2038} /* namespace kodi */
2039
2040#endif /* __cplusplus */
Definition Game.h:119
Definition AddonBase.h:566
Definition AddonBase.h:502
@ 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:726
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.
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:1378
void RCOnSubsetCompleted(const std::string &title)
Callback to Kodi Function Notify Kodi that every achievement of a subset has been earned
Definition Game.h:1406
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:1347
virtual GAME_ERROR ActivateAchievement(unsigned int cheevoId, const std::string &memAddrExpression)
Activate an achievement.
Definition Game.h:1114
void RCOnRichPresenceUpdated(const std::string &evaluation)
Callback to Kodi Function Publish the current rich presence evaluation to Kodi
Definition Game.h:1195
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:1453
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:1282
virtual GAME_ERROR RCSetEncoreModeEnabled(bool enabled)
Set whether already-earned achievements can be earned again.
Definition Game.h:1103
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:1329
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:1247
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:1229
void RCOnReset()
Callback to Kodi Function Ask the frontend to reset the game
Definition Game.h:1394
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:1148
void RCOnLoginResult(const game_rc_login_result &data)
Callback to Kodi Function Notify Kodi of the outcome of a login attempt
Definition Game.h:1211
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:1428
virtual GAME_ERROR SetRetroAchievementsCredentials(const std::string &username, const std::string &token)
Set the credentials of the RetroAchievements user.
Definition Game.h:1072
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:1362
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:1298
void RCOnConnectionChanged(bool connected)
Callback to Kodi Function Report a change in connectivity to the RetroAchievements server
Definition Game.h:1266
void RCOnLeaderboardStarted(const game_rc_leaderboard &data)
Callback to Kodi Function Notify Kodi that an attempt at a leaderboard has begun
Definition Game.h:1314
virtual GAME_ERROR RCSetHardcoreEnabled(bool enabled)
Set whether achievements are earned in hardcore mode.
Definition Game.h:1091
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:1179
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:1132
void RCOnAchievementTriggered(const game_rc_achievement_triggered &data)
Callback to Kodi Function Notify Kodi that the player has earned an achievement
Definition Game.h:1163
virtual GAME_ERROR CheatReset()
Reset the cheat system.
Definition Game.h:1033
virtual GAME_ERROR GetMemory(GAME_MEMORY type, uint8_t *&data, size_t &size)
Get a region of memory.
Definition Game.h:1045
virtual GAME_ERROR SetCheat(unsigned int index, bool enabled, const std::string &code)
Set a cheat code.
Definition Game.h:1060
Game system timing.
Definition game.h:1178
GAME_REGION
Game region definition
Definition game.h:623
SPECIAL_GAME_TYPE
Special game types passed into game_load_game_special().
Definition game.h:641
GAME_MEMORY
Game Memory
Definition game.h:660
@ GAME_REGION_UNKNOWN
Game region unknown.
Definition game.h:625
void(* game_proc_address_t)(void)
Hardware framebuffer process function address
Definition game.h:463
Hardware rendering properties
Definition game.h:338
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:908
An input event.
Definition game.h:1117
The input topology is the possible ways to connect input devices.
Definition game.h:989
**Payload of AddonToKodiFuncTable_Game::RCOnChallengeIndicator**
Definition game.h:1444
Payload of the achievement progress indicator callbacks
Definition game.h:1466
**Payload of AddonToKodiFuncTable_Game::RCOnAchievementTriggered**
Definition game.h:1289
**Payload of AddonToKodiFuncTable_Game::RCOnGameLoaded**
Definition game.h:1267
Payload of the leaderboard attempt callbacks
Definition game.h:1374
**Payload of AddonToKodiFuncTable_Game::RCOnLeaderboardScoreboard**
Definition game.h:1399
Payload of the leaderboard tracker callbacks
Definition game.h:1425
**Payload of AddonToKodiFuncTable_Game::RCOnLoginResult**
Definition game.h:1314
GAME_STREAM_TYPE type
The stream type.
Definition game.h:542
@ GAME_STREAM_HW_FRAMEBUFFER
Hardware framebuffer.
Definition game.h:526
Stream buffers for hardware rendering and zero-copy support
Definition game.h:565
Stream packet and ephemeral metadata
Definition game.h:588
Immutable stream metadata
Definition game.h:540
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:1527
virtual unsigned int GetImageCount()
Gets the number of available disk images.
Definition Game.h:1535
virtual std::string GetImageLabel(unsigned int imageIndex)
Gets a user-friendly label for a disk image.
Definition Game.h:1610
virtual GAME_ERROR ReplaceImageIndex(unsigned int imageIndex, const std::string &filePath)
Replaces the disk image at the given index.
Definition Game.h:1557
virtual GAME_ERROR RemoveImageIndex(unsigned int imageIndex)
Removes the disk image at the given index.
Definition Game.h:1572
virtual std::string GetImagePath(unsigned int imageIndex)
Gets the full path of a disk image.
Definition Game.h:1600
virtual unsigned int GetImageIndex()
Gets the index of the currently inserted disk image.
Definition Game.h:1515
virtual GAME_ERROR SetInitialImage(unsigned int imageIndex, const std::string &filePath)
Sets which image should be initially inserted on load.
Definition Game.h:1587
virtual GAME_ERROR SetEjectState(bool ejected)
Opens or closes the virtual disk tray.
Definition Game.h:1506
virtual GAME_ERROR AddImageIndex()
Adds a new disk image slot.
Definition Game.h:1544
virtual bool GetEjectState()
Returns whether the virtual disk tray is currently ejected.
Definition Game.h:1493
virtual GAME_ERROR HwContextDestroy()
Called before the context is destroyed.
Definition Game.h:678
virtual GAME_ERROR HwContextReset()
Invalidates the current HW context and reinitializes GPU resources.
Definition Game.h:668
bool EnableHardwareRendering(const game_hw_rendering_properties &properties)
Callback to Kodi Function Enable hardware rendering functionality
Definition Game.h:652
game_proc_address_t HwGetProcAddress(const char *sym)
Callback to Kodi Function Get a symbol from the hardware context
Definition Game.h:689
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:761
virtual bool InputEvent(const game_input_event &event)
Notify the add-on of an input event.
Definition Game.h:884
virtual void FreeTopology(game_input_topology *topology)
Free the topology's resources.
Definition Game.h:786
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:869
virtual void SetControllerLayouts(const std::vector< kodi::addon::GameControllerLayout > &controllers)
Set the layouts for known controllers.
Definition Game.h:797
virtual bool EnableMouse(bool enable, const std::string &controller_id)
Enable/disable mouse input using the specified controller.
Definition Game.h:822
virtual bool EnableKeyboard(bool enable, const std::string &controller_id)
Enable/disable keyboard input using the specified controller.
Definition Game.h:811
bool KodiInputEvent(const game_input_event &event)
Callback to Kodi Function Notify the port of an input event
Definition Game.h:899
virtual game_input_topology * GetTopology()
Get the input topology that specifies which controllers can be connected.
Definition Game.h:778
bool IsOpen() const
Check if the stream opened correctly, e.g. after calling the constructor.
Definition Game.h:615
void ReleaseBuffer(game_stream_buffer &buffer)
Free an allocated buffer.
Definition Game.h:595
void Close()
Free the specified stream.
Definition Game.h:522
bool GetBuffer(unsigned int width, unsigned int height, game_stream_buffer &buffer)
Get a buffer for zero-copy stream data.
Definition Game.h:551
void AddData(const game_stream_packet &packet)
Add a data packet to a stream.
Definition Game.h:575
bool Open(const game_stream_properties &properties)
Create a stream for gameplay data.
Definition Game.h:488
virtual GAME_ERROR LoadGameSpecial(SPECIAL_GAME_TYPE type, const std::vector< std::string > &urls)
Load a game that requires multiple files.
Definition Game.h:324
virtual GAME_ERROR UnloadGame()
Unload the current game.
Definition Game.h:350
void SetGameTiming(const game_system_timing &timingInfo)
Callback to Kodi Function Update the video and audio timing of the running game
Definition Game.h:449
virtual GAME_ERROR GetGameTiming(game_system_timing &timing_info)
Get timing information about the loaded game.
Definition Game.h:360
virtual GAME_ERROR RunFrame()
Run a single frame for add-ons that use a game loop.
Definition Game.h:390
virtual bool RequiresGameLoop()
Return true if the client requires the frontend to provide a game loop.
Definition Game.h:382
virtual GAME_ERROR Reset()
Reset the current game.
Definition Game.h:398
virtual GAME_ERROR LoadStandalone()
Begin playing without a game file.
Definition Game.h:340
double GetPlaybackSpeed()
Callback to Kodi Function Get the speed the game is being played back at
Definition Game.h:432
void CloseGame(void)
Callback to Kodi Function Requests the frontend to stop the current game
Definition Game.h:407
virtual GAME_ERROR LoadGame(const std::string &url)
Load a game.
Definition Game.h:313
virtual GAME_REGION GetRegion()
Get region of the loaded game.
Definition Game.h:371
virtual size_t AchievementStateSize()
How many bytes the achievement runtime's state needs right now.
Definition Game.h:967
virtual GAME_ERROR SerializeAchievements(uint8_t *data, size_t size)
Write the achievement runtime's state.
Definition Game.h:979
virtual GAME_ERROR DeserializeAchievements(const uint8_t *data, size_t size)
Restore achievement state written by SerializeAchievements()
Definition Game.h:1001
virtual GAME_ERROR Deserialize(const uint8_t *data, size_t size)
Deserialize the game from the given state.
Definition Game.h:952
virtual GAME_ERROR Serialize(uint8_t *data, size_t size)
Serialize the state of the game.
Definition Game.h:941
virtual size_t SerializeSize()
Get the number of bytes required to serialize the game.
Definition Game.h:930
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition AddonBase.h:1939
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:1711
Game callbacks.
Definition game.h:1566
bool(* StartStream)(KODI_HANDLE, KODI_GAME_STREAM_HANDLE)
Reset a prepared hardware stream after installing its returned handle.
Definition game.h:1630
Definition addon_base.h:269
Internal used structure to have stored C API data above and available for everything below.
Definition AddonBase.h:73