Kodi Development  20.0
for Binary and Script based Add-Ons
Game.h
1 /*
2  * Copyright (C) 2014-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "../AddonBase.h"
12 #include "../c-api/addon-instance/game.h"
13 
14 #ifdef __cplusplus
15 
16 namespace kodi
17 {
18 namespace addon
19 {
20 
21 //==============================================================================
30 
31 //==============================================================================
36 
37 //==============================================================================
45 {
46 public:
48  explicit GameControllerLayout() = default;
49  GameControllerLayout(const game_controller_layout& layout)
50  {
51  controller_id = layout.controller_id;
52  provides_input = layout.provides_input;
53  for (unsigned int i = 0; i < layout.digital_button_count; ++i)
54  digital_buttons.push_back(layout.digital_buttons[i]);
55  for (unsigned int i = 0; i < layout.analog_button_count; ++i)
56  analog_buttons.push_back(layout.analog_buttons[i]);
57  for (unsigned int i = 0; i < layout.analog_stick_count; ++i)
58  analog_sticks.push_back(layout.analog_sticks[i]);
59  for (unsigned int i = 0; i < layout.accelerometer_count; ++i)
60  accelerometers.push_back(layout.accelerometers[i]);
61  for (unsigned int i = 0; i < layout.key_count; ++i)
62  keys.push_back(layout.keys[i]);
63  for (unsigned int i = 0; i < layout.rel_pointer_count; ++i)
64  rel_pointers.push_back(layout.rel_pointers[i]);
65  for (unsigned int i = 0; i < layout.abs_pointer_count; ++i)
66  abs_pointers.push_back(layout.abs_pointers[i]);
67  for (unsigned int i = 0; i < layout.motor_count; ++i)
68  motors.push_back(layout.motors[i]);
69  }
73  std::string controller_id;
74 
79 
81  std::vector<std::string> digital_buttons;
82 
84  std::vector<std::string> analog_buttons;
85 
87  std::vector<std::string> analog_sticks;
88 
90  std::vector<std::string> accelerometers;
91 
93  std::vector<std::string> keys;
94 
96  std::vector<std::string> rel_pointers;
97 
99  std::vector<std::string> abs_pointers;
100 
102  std::vector<std::string> motors;
103 };
105 //------------------------------------------------------------------------------
106 
107 //==============================================================================
116 class ATTRIBUTE_HIDDEN CInstanceGame : public IAddonInstance
117 {
118 public:
119  //============================================================================
125 
126  //============================================================================
162  {
163  if (CAddonBase::m_interface->globalSingleInstance != nullptr)
164  throw std::logic_error("kodi::addon::CInstanceGame: Creation of more as one in single "
165  "instance way is not allowed!");
166 
167  SetAddonStruct(CAddonBase::m_interface->firstKodiInstance);
168  CAddonBase::m_interface->globalSingleInstance = this;
169  }
170  //----------------------------------------------------------------------------
171 
172  //============================================================================
175  ~CInstanceGame() override = default;
176  //----------------------------------------------------------------------------
177 
178  //============================================================================
186  std::string GameClientDllPath() const { return m_instanceData->props->game_client_dll_path; }
187  //----------------------------------------------------------------------------
188 
189  //============================================================================
198  bool ProxyDllPaths(std::vector<std::string>& paths)
199  {
200  for (unsigned int i = 0; i < m_instanceData->props->proxy_dll_count; ++i)
201  {
202  if (m_instanceData->props->proxy_dll_paths[i] != nullptr)
203  paths.push_back(m_instanceData->props->proxy_dll_paths[i]);
204  }
205  return !paths.empty();
206  }
207  //----------------------------------------------------------------------------
208 
209  //============================================================================
220  bool ResourceDirectories(std::vector<std::string>& dirs)
221  {
222  for (unsigned int i = 0; i < m_instanceData->props->resource_directory_count; ++i)
223  {
224  if (m_instanceData->props->resource_directories[i] != nullptr)
225  dirs.push_back(m_instanceData->props->resource_directories[i]);
226  }
227  return !dirs.empty();
228  }
229  //----------------------------------------------------------------------------
230 
231  //============================================================================
243  std::string ProfileDirectory() const { return m_instanceData->props->profile_directory; }
244  //----------------------------------------------------------------------------
245 
246  //============================================================================
254  bool SupportsVFS() const { return m_instanceData->props->supports_vfs; }
255  //----------------------------------------------------------------------------
256 
257  //============================================================================
266  bool Extensions(std::vector<std::string>& extensions)
267  {
268  for (unsigned int i = 0; i < m_instanceData->props->extension_count; ++i)
269  {
270  if (m_instanceData->props->extensions[i] != nullptr)
271  extensions.push_back(m_instanceData->props->extensions[i]);
272  }
273  return !extensions.empty();
274  }
275  //----------------------------------------------------------------------------
276 
278 
279 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
280 
281  //============================================================================
301 
302  //============================================================================
308  virtual GAME_ERROR LoadGame(const std::string& url)
309  {
311  }
312  //----------------------------------------------------------------------------
313 
314  //============================================================================
321  virtual GAME_ERROR LoadGameSpecial(SPECIAL_GAME_TYPE type, const std::vector<std::string>& urls)
322  {
324  }
325  //----------------------------------------------------------------------------
326 
327  //============================================================================
338  {
340  }
341  //----------------------------------------------------------------------------
342 
343  //============================================================================
351  {
353  }
354  //----------------------------------------------------------------------------
355 
356  //============================================================================
364  {
366  }
367  //----------------------------------------------------------------------------
368 
369  //============================================================================
375  {
376  return GAME_REGION_UNKNOWN;
377  }
378  //----------------------------------------------------------------------------
379 
380  //============================================================================
388  virtual bool RequiresGameLoop()
389  {
390  return false;
391  }
392  //----------------------------------------------------------------------------
393 
394  //============================================================================
400  {
402  }
403  //----------------------------------------------------------------------------
404 
405  //============================================================================
410  virtual GAME_ERROR Reset()
411  {
413  }
414  //----------------------------------------------------------------------------
415 
416  //==========================================================================
422  void CloseGame(void) { m_instanceData->toKodi->CloseGame(m_instanceData->toKodi->kodiInstance); }
423  //----------------------------------------------------------------------------
424 
425  //============================================================================
437  class CStream
438  {
439  public:
440  CStream() = default;
441 
442  CStream(const game_stream_properties& properties)
443  {
444  Open(properties);
445  }
446 
447  ~CStream()
448  {
449  Close();
450  }
451 
452  //==========================================================================
461  bool Open(const game_stream_properties& properties)
462  {
463  if (!CAddonBase::m_interface->globalSingleInstance)
464  return false;
465 
466  if (m_handle)
467  {
468  kodi::Log(ADDON_LOG_INFO, "kodi::addon::CInstanceGame::CStream already becomes reopened");
469  Close();
470  }
471 
473  *static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance)
474  ->m_instanceData->toKodi;
475  m_handle = cb.OpenStream(cb.kodiInstance, &properties);
476  return m_handle != nullptr;
477  }
478  //--------------------------------------------------------------------------
479 
480  //==========================================================================
486  void Close()
487  {
488  if (!m_handle || !CAddonBase::m_interface->globalSingleInstance)
489  return;
490 
492  *static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance)
493  ->m_instanceData->toKodi;
494  cb.CloseStream(cb.kodiInstance, m_handle);
495  m_handle = nullptr;
496  }
497  //--------------------------------------------------------------------------
498 
499  //==========================================================================
512  bool GetBuffer(unsigned int width, unsigned int height, game_stream_buffer& buffer)
513  {
514  if (!m_handle || !CAddonBase::m_interface->globalSingleInstance)
515  return false;
516 
518  *static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance)
519  ->m_instanceData->toKodi;
520  return cb.GetStreamBuffer(cb.kodiInstance, m_handle, width, height, &buffer);
521  }
522  //--------------------------------------------------------------------------
523 
524  //==========================================================================
532  void AddData(const game_stream_packet& packet)
533  {
534  if (!m_handle || !CAddonBase::m_interface->globalSingleInstance)
535  return;
536 
538  *static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance)
539  ->m_instanceData->toKodi;
540  cb.AddStreamData(cb.kodiInstance, m_handle, &packet);
541  }
542  //--------------------------------------------------------------------------
543 
544  //==========================================================================
553  {
554  if (!m_handle || !CAddonBase::m_interface->globalSingleInstance)
555  return;
556 
558  *static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance)
559  ->m_instanceData->toKodi;
560  cb.ReleaseStreamBuffer(cb.kodiInstance, m_handle, &buffer);
561  }
562  //--------------------------------------------------------------------------
563 
564  //==========================================================================
572  bool IsOpen() const { return m_handle != nullptr; }
573  //--------------------------------------------------------------------------
574 
575  private:
576  KODI_GAME_STREAM_HANDLE m_handle = nullptr;
577  };
579 
581 
582 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
583 
584  //============================================================================
601 
602  //============================================================================
610  {
612  }
613  //----------------------------------------------------------------------------
614 
615  //============================================================================
623  {
625  }
626 
627  //============================================================================
637  {
638  return m_instanceData->toKodi->HwGetProcAddress(m_instanceData->toKodi->kodiInstance, sym);
639  }
640  //----------------------------------------------------------------------------
641 
643 
644 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
645 
646  //============================================================================
662 
663  //============================================================================
675  virtual bool HasFeature(const std::string& controller_id, const std::string& feature_name)
676  {
677  return false;
678  }
679  //----------------------------------------------------------------------------
680 
681  //============================================================================
693  {
694  return nullptr;
695  }
696  //----------------------------------------------------------------------------
697 
698  //============================================================================
703  virtual void FreeTopology(game_input_topology* topology)
704  {
705  }
706  //----------------------------------------------------------------------------
707 
708  //============================================================================
716  virtual void SetControllerLayouts(const std::vector<kodi::addon::GameControllerLayout>& controllers)
717  {
718  }
719  //----------------------------------------------------------------------------
720 
721  //============================================================================
729  virtual bool EnableKeyboard(bool enable, const std::string& controller_id)
730  {
731  return false;
732  }
733  //----------------------------------------------------------------------------
734 
735  //============================================================================
743  virtual bool EnableMouse(bool enable, const std::string& controller_id)
744  {
745  return false;
746  }
747  //--------------------------------------------------------------------------
748 
749  //==========================================================================
792  virtual bool ConnectController(bool connect,
793  const std::string& port_address,
794  const std::string& controller_id)
795  {
796  return false;
797  }
798  //----------------------------------------------------------------------------
799 
800  //============================================================================
807  virtual bool InputEvent(const game_input_event& event)
808  {
809  return false;
810  }
811  //----------------------------------------------------------------------------
812 
813  //============================================================================
824  bool KodiInputEvent(const game_input_event& event)
825  {
826  return m_instanceData->toKodi->InputEvent(m_instanceData->toKodi->kodiInstance, &event);
827  }
828  //----------------------------------------------------------------------------
829 
831 
832 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
833 
834  //============================================================================
850 
851  //============================================================================
856  virtual size_t SerializeSize()
857  {
858  return 0;
859  }
860  //----------------------------------------------------------------------------
861 
862  //============================================================================
870  virtual GAME_ERROR Serialize(uint8_t* data, size_t size)
871  {
873  }
874  //----------------------------------------------------------------------------
875 
876  //============================================================================
884  virtual GAME_ERROR Deserialize(const uint8_t* data, size_t size)
885  {
887  }
888  //----------------------------------------------------------------------------
889 
891 
892 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
893 
894  //============================================================================
910 
911  //============================================================================
917  {
919  }
920  //----------------------------------------------------------------------------
921 
922  //============================================================================
931  virtual GAME_ERROR GetMemory(GAME_MEMORY type, uint8_t*& data, size_t& size)
932  {
934  }
935  //----------------------------------------------------------------------------
936 
937  //============================================================================
946  virtual GAME_ERROR SetCheat(unsigned int index, bool enabled, const std::string& code)
947  {
949  }
950  //----------------------------------------------------------------------------
951 
953 
954 private:
955  void SetAddonStruct(KODI_HANDLE instance)
956  {
957  if (instance == nullptr)
958  throw std::logic_error("kodi::addon::CInstanceGame: Creation with empty addon structure not"
959  "allowed, table must be given from Kodi!");
960 
961  m_instanceData = static_cast<AddonInstance_Game*>(instance);
962  m_instanceData->toAddon->addonInstance = this;
963 
964  m_instanceData->toAddon->LoadGame = ADDON_LoadGame;
965  m_instanceData->toAddon->LoadGameSpecial = ADDON_LoadGameSpecial;
966  m_instanceData->toAddon->LoadStandalone = ADDON_LoadStandalone;
967  m_instanceData->toAddon->UnloadGame = ADDON_UnloadGame;
968  m_instanceData->toAddon->GetGameTiming = ADDON_GetGameTiming;
969  m_instanceData->toAddon->GetRegion = ADDON_GetRegion;
970  m_instanceData->toAddon->RequiresGameLoop = ADDON_RequiresGameLoop;
971  m_instanceData->toAddon->RunFrame = ADDON_RunFrame;
972  m_instanceData->toAddon->Reset = ADDON_Reset;
973 
974  m_instanceData->toAddon->HwContextReset = ADDON_HwContextReset;
975  m_instanceData->toAddon->HwContextDestroy = ADDON_HwContextDestroy;
976 
977  m_instanceData->toAddon->HasFeature = ADDON_HasFeature;
978  m_instanceData->toAddon->GetTopology = ADDON_GetTopology;
979  m_instanceData->toAddon->FreeTopology = ADDON_FreeTopology;
980  m_instanceData->toAddon->SetControllerLayouts = ADDON_SetControllerLayouts;
981  m_instanceData->toAddon->EnableKeyboard = ADDON_EnableKeyboard;
982  m_instanceData->toAddon->EnableMouse = ADDON_EnableMouse;
983  m_instanceData->toAddon->ConnectController = ADDON_ConnectController;
984  m_instanceData->toAddon->InputEvent = ADDON_InputEvent;
985 
986  m_instanceData->toAddon->SerializeSize = ADDON_SerializeSize;
987  m_instanceData->toAddon->Serialize = ADDON_Serialize;
988  m_instanceData->toAddon->Deserialize = ADDON_Deserialize;
989 
990  m_instanceData->toAddon->CheatReset = ADDON_CheatReset;
991  m_instanceData->toAddon->GetMemory = ADDON_GetMemory;
992  m_instanceData->toAddon->SetCheat = ADDON_SetCheat;
993  }
994 
995  // --- Game operations ---------------------------------------------------------
996 
997  inline static GAME_ERROR ADDON_LoadGame(const AddonInstance_Game* instance, const char* url)
998  {
999  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->LoadGame(url);
1000  }
1001 
1002  inline static GAME_ERROR ADDON_LoadGameSpecial(const AddonInstance_Game* instance,
1003  SPECIAL_GAME_TYPE type,
1004  const char** urls,
1005  size_t urlCount)
1006  {
1007  std::vector<std::string> urlList;
1008  for (size_t i = 0; i < urlCount; ++i)
1009  {
1010  if (urls[i] != nullptr)
1011  urlList.push_back(urls[i]);
1012  }
1013 
1014  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1015  ->LoadGameSpecial(type, urlList);
1016  }
1017 
1018  inline static GAME_ERROR ADDON_LoadStandalone(const AddonInstance_Game* instance)
1019  {
1020  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->LoadStandalone();
1021  }
1022 
1023  inline static GAME_ERROR ADDON_UnloadGame(const AddonInstance_Game* instance)
1024  {
1025  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->UnloadGame();
1026  }
1027 
1028  inline static GAME_ERROR ADDON_GetGameTiming(const AddonInstance_Game* instance,
1029  game_system_timing* timing_info)
1030  {
1031  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1032  ->GetGameTiming(*timing_info);
1033  }
1034 
1035  inline static GAME_REGION ADDON_GetRegion(const AddonInstance_Game* instance)
1036  {
1037  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetRegion();
1038  }
1039 
1040  inline static bool ADDON_RequiresGameLoop(const AddonInstance_Game* instance)
1041  {
1042  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->RequiresGameLoop();
1043  }
1044 
1045  inline static GAME_ERROR ADDON_RunFrame(const AddonInstance_Game* instance)
1046  {
1047  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->RunFrame();
1048  }
1049 
1050  inline static GAME_ERROR ADDON_Reset(const AddonInstance_Game* instance)
1051  {
1052  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->Reset();
1053  }
1054 
1055 
1056  // --- Hardware rendering operations -------------------------------------------
1057 
1058  inline static GAME_ERROR ADDON_HwContextReset(const AddonInstance_Game* instance)
1059  {
1060  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->HwContextReset();
1061  }
1062 
1063  inline static GAME_ERROR ADDON_HwContextDestroy(const AddonInstance_Game* instance)
1064  {
1065  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->HwContextDestroy();
1066  }
1067 
1068 
1069  // --- Input operations --------------------------------------------------------
1070 
1071  inline static bool ADDON_HasFeature(const AddonInstance_Game* instance,
1072  const char* controller_id,
1073  const char* feature_name)
1074  {
1075  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1076  ->HasFeature(controller_id, feature_name);
1077  }
1078 
1079  inline static game_input_topology* ADDON_GetTopology(const AddonInstance_Game* instance)
1080  {
1081  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetTopology();
1082  }
1083 
1084  inline static void ADDON_FreeTopology(const AddonInstance_Game* instance,
1085  game_input_topology* topology)
1086  {
1087  static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->FreeTopology(topology);
1088  }
1089 
1090  inline static void ADDON_SetControllerLayouts(const AddonInstance_Game* instance,
1091  const game_controller_layout* controllers,
1092  unsigned int controller_count)
1093  {
1094  if (controllers == nullptr)
1095  return;
1096 
1097  std::vector<GameControllerLayout> controllerList;
1098  for (unsigned int i = 0; i < controller_count; ++i)
1099  controllerList.push_back(controllers[i]);
1100 
1101  static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1102  ->SetControllerLayouts(controllerList);
1103  }
1104 
1105  inline static bool ADDON_EnableKeyboard(const AddonInstance_Game* instance,
1106  bool enable,
1107  const char* controller_id)
1108  {
1109  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1110  ->EnableKeyboard(enable, controller_id);
1111  }
1112 
1113  inline static bool ADDON_EnableMouse(const AddonInstance_Game* instance,
1114  bool enable,
1115  const char* controller_id)
1116  {
1117  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1118  ->EnableMouse(enable, controller_id);
1119  }
1120 
1121  inline static bool ADDON_ConnectController(const AddonInstance_Game* instance,
1122  bool connect,
1123  const char* port_address,
1124  const char* controller_id)
1125  {
1126  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1127  ->ConnectController(connect, port_address, controller_id);
1128  }
1129 
1130  inline static bool ADDON_InputEvent(const AddonInstance_Game* instance,
1131  const game_input_event* event)
1132  {
1133  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->InputEvent(*event);
1134  }
1135 
1136 
1137  // --- Serialization operations ------------------------------------------------
1138 
1139  inline static size_t ADDON_SerializeSize(const AddonInstance_Game* instance)
1140  {
1141  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->SerializeSize();
1142  }
1143 
1144  inline static GAME_ERROR ADDON_Serialize(const AddonInstance_Game* instance,
1145  uint8_t* data,
1146  size_t size)
1147  {
1148  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->Serialize(data, size);
1149  }
1150 
1151  inline static GAME_ERROR ADDON_Deserialize(const AddonInstance_Game* instance,
1152  const uint8_t* data,
1153  size_t size)
1154  {
1155  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->Deserialize(data, size);
1156  }
1157 
1158 
1159  // --- Cheat operations --------------------------------------------------------
1160 
1161  inline static GAME_ERROR ADDON_CheatReset(const AddonInstance_Game* instance)
1162  {
1163  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->CheatReset();
1164  }
1165 
1166  inline static GAME_ERROR ADDON_GetMemory(const AddonInstance_Game* instance,
1167  GAME_MEMORY type,
1168  uint8_t** data,
1169  size_t* size)
1170  {
1171  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1172  ->GetMemory(type, *data, *size);
1173  }
1174 
1175  inline static GAME_ERROR ADDON_SetCheat(const AddonInstance_Game* instance,
1176  unsigned int index,
1177  bool enabled,
1178  const char* code)
1179  {
1180  return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1181  ->SetCheat(index, enabled, code);
1182  }
1183 
1184  AddonInstance_Game* m_instanceData;
1185 };
1186 
1187 } /* namespace addon */
1188 } /* namespace kodi */
1189 
1190 #endif /* __cplusplus */
Definition: Game.h:117
Definition: AddonBase.h:186
@ ADDON_LOG_INFO
1 : To include information messages in the log file.
Definition: addon_base.h:177
@ ADDON_INSTANCE_GAME
Game instance, see kodi::addon::CInstanceGame.
Definition: versions.h:223
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:186
bool ProxyDllPaths(std::vector< std::string > &paths)
Callback to Kodi Function Paths to proxy DLLs used to load the game client.
Definition: Game.h:198
bool ResourceDirectories(std::vector< std::string > &dirs)
Callback to Kodi Function The "system" directories of the frontend.
Definition: Game.h:220
std::string ProfileDirectory() const
Callback to Kodi Function The writable directory of the frontend.
Definition: Game.h:243
bool SupportsVFS() const
Callback to Kodi Function The value of the <supports_vfs> property from addon.xml.
Definition: Game.h:254
~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:266
virtual GAME_ERROR CheatReset()
Reset the cheat system.
Definition: Game.h:916
virtual GAME_ERROR GetMemory(GAME_MEMORY type, uint8_t *&data, size_t &size)
Get a region of memory.
Definition: Game.h:931
virtual GAME_ERROR SetCheat(unsigned int index, bool enabled, const std::string &code)
Set a cheat code.
Definition: Game.h:946
Game system timing.
Definition: game.h:1050
GAME_REGION
Game reguin definition
Definition: game.h:563
SPECIAL_GAME_TYPE
Special game types passed into game_load_game_special().
Definition: game.h:581
GAME_MEMORY
Game Memory
Definition: game.h:600
@ GAME_REGION_UNKNOWN
Game region unknown.
Definition: game.h:565
void(* game_proc_address_t)(void)
Hardware framebuffer process function address
Definition: game.h:406
std::vector< std::string > analog_buttons
Analog buttons.
Definition: Game.h:84
std::vector< std::string > accelerometers
Accelerometers.
Definition: Game.h:90
bool provides_input
Provides input.
Definition: Game.h:78
std::vector< std::string > digital_buttons
Digital buttons.
Definition: Game.h:81
std::vector< std::string > abs_pointers
Absolute pointers.
Definition: Game.h:99
std::vector< std::string > motors
Motors.
Definition: Game.h:102
std::string controller_id
Controller identifier.
Definition: Game.h:73
std::vector< std::string > rel_pointers
Relative pointers.
Definition: Game.h:96
std::vector< std::string > keys
Keys.
Definition: Game.h:93
std::vector< std::string > analog_sticks
Analog sticks.
Definition: Game.h:87
Definition: game.h:990
The input topology is the possible ways to connect input devices.
Definition: game.h:866
Stream buffers for hardware rendering and zero-copy support
Definition: game.h:507
Stream packet and ephemeral metadata
Definition: game.h:529
Immutable stream metadata
Definition: game.h:483
GAME_ERROR
Game add-on error codes
Definition: game.h:34
@ GAME_ERROR_NOT_IMPLEMENTED
the method that the frontend called is not implemented
Definition: game.h:42
virtual GAME_ERROR HwContextDestroy()
Called before the context is destroyed.
Definition: Game.h:622
virtual GAME_ERROR HwContextReset()
Invalidates the current HW context and reinitializes GPU resources.
Definition: Game.h:609
game_proc_address_t HwGetProcAddress(const char *sym)
Callback to Kodi Function Get a symbol from the hardware context
Definition: Game.h:636
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:675
virtual bool InputEvent(const game_input_event &event)
Notify the add-on of an input event.
Definition: Game.h:807
virtual void FreeTopology(game_input_topology *topology)
Free the topology's resources.
Definition: Game.h:703
virtual game_input_topology * GetTopology()
Get the input topology that specifies which controllers can be connected.
Definition: Game.h:692
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:792
virtual void SetControllerLayouts(const std::vector< kodi::addon::GameControllerLayout > &controllers)
Set the layouts for known controllers.
Definition: Game.h:716
virtual bool EnableMouse(bool enable, const std::string &controller_id)
Enable/disable mouse input using the specified controller.
Definition: Game.h:743
virtual bool EnableKeyboard(bool enable, const std::string &controller_id)
Enable/disable keyboard input using the specified controller.
Definition: Game.h:729
bool KodiInputEvent(const game_input_event &event)
Callback to Kodi Function Notify the port of an input event
Definition: Game.h:824
bool IsOpen() const
To check stream open was OK, e.g. after use of constructor.
Definition: Game.h:572
void ReleaseBuffer(game_stream_buffer &buffer)
Free an allocated buffer.
Definition: Game.h:552
void Close()
Free the specified stream.
Definition: Game.h:486
bool GetBuffer(unsigned int width, unsigned int height, game_stream_buffer &buffer)
Get a buffer for zero-copy stream data.
Definition: Game.h:512
void AddData(const game_stream_packet &packet)
Add a data packet to a stream.
Definition: Game.h:532
bool Open(const game_stream_properties &properties)
Create a stream for gameplay data.
Definition: Game.h:461
virtual GAME_ERROR LoadGameSpecial(SPECIAL_GAME_TYPE type, const std::vector< std::string > &urls)
Load a game that requires multiple files.
Definition: Game.h:321
virtual GAME_ERROR UnloadGame()
Unload the current game.
Definition: Game.h:350
virtual GAME_ERROR GetGameTiming(game_system_timing &timing_info)
Get timing information about the loaded game.
Definition: Game.h:363
virtual GAME_ERROR RunFrame()
Run a single frame for add-ons that use a game loop.
Definition: Game.h:399
virtual bool RequiresGameLoop()
Return true if the client requires the frontend to provide a game loop.
Definition: Game.h:388
virtual GAME_ERROR Reset()
Reset the current game.
Definition: Game.h:410
virtual GAME_ERROR LoadStandalone()
Begin playing without a game file.
Definition: Game.h:337
void CloseGame(void)
Callback to Kodi Function Requests the frontend to stop the current game
Definition: Game.h:422
virtual GAME_ERROR LoadGame(const std::string &url)
Load a game.
Definition: Game.h:308
virtual GAME_REGION GetRegion()
Get region of the loaded game.
Definition: Game.h:374
virtual GAME_ERROR Deserialize(const uint8_t *data, size_t size)
Deserialize the game from the given state.
Definition: Game.h:884
virtual GAME_ERROR Serialize(uint8_t *data, size_t size)
Serialize the state of the game.
Definition: Game.h:870
virtual size_t SerializeSize()
Get the number of bytes required to serialize the game.
Definition: Game.h:856
std::string ATTRIBUTE_HIDDEN GetKodiTypeVersion(int type)
To get used version inside Kodi itself about asked type.
Definition: AddonBase.h:630
std::string ATTRIBUTE_HIDDEN GetRegion(const std::string &id)
Returns your regions setting as a string for the specified id.
Definition: General.h:478
void ATTRIBUTE_HIDDEN Log(const AddonLog loglevel, const char *format,...)
Add a message to Kodi's log.
Definition: AddonBase.h:749
Game instance.
Definition: game.h:1200
Game callbacks.
Definition: game.h:1132