diff options
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h')
| -rw-r--r-- | xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h | 340 |
1 files changed, 0 insertions, 340 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h deleted file mode 100644 index 4338606..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h +++ /dev/null | |||
| @@ -1,340 +0,0 @@ | |||
| 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 "kodi_game_types.h" | ||
| 12 | |||
| 13 | #ifdef __cplusplus | ||
| 14 | extern "C" { | ||
| 15 | #endif | ||
| 16 | |||
| 17 | // --- Game operations --------------------------------------------------------- | ||
| 18 | |||
| 19 | /*! | ||
| 20 | * \brief Load a game | ||
| 21 | * | ||
| 22 | * \param url The URL to load | ||
| 23 | * | ||
| 24 | * return the error, or GAME_ERROR_NO_ERROR if the game was loaded | ||
| 25 | */ | ||
| 26 | GAME_ERROR LoadGame(const char* url); | ||
| 27 | |||
| 28 | /*! | ||
| 29 | * \brief Load a game that requires multiple files | ||
| 30 | * | ||
| 31 | * \param type The game type | ||
| 32 | * \param urls An array of urls | ||
| 33 | * \param urlCount The number of urls in the array | ||
| 34 | * | ||
| 35 | * \return the error, or GAME_ERROR_NO_ERROR if the game was loaded | ||
| 36 | */ | ||
| 37 | GAME_ERROR LoadGameSpecial(SPECIAL_GAME_TYPE type, const char** urls, size_t urlCount); | ||
| 38 | |||
| 39 | /*! | ||
| 40 | * \brief Begin playing without a game file | ||
| 41 | * | ||
| 42 | * If the add-on supports standalone mode, it must add the <supports_standalone> | ||
| 43 | * tag to the extension point in addon.xml: | ||
| 44 | * | ||
| 45 | * <supports_no_game>false</supports_no_game> | ||
| 46 | * | ||
| 47 | * \return the error, or GAME_ERROR_NO_ERROR if the game add-on was loaded | ||
| 48 | */ | ||
| 49 | GAME_ERROR LoadStandalone(void); | ||
| 50 | |||
| 51 | /*! | ||
| 52 | * \brief Unload the current game | ||
| 53 | * | ||
| 54 | * \return the error, or GAME_ERROR_NO_ERROR if the game was unloaded | ||
| 55 | */ | ||
| 56 | /*! Unloads a currently loaded game */ | ||
| 57 | GAME_ERROR UnloadGame(void); | ||
| 58 | |||
| 59 | /*! | ||
| 60 | * \brief Get timing information about the loaded game | ||
| 61 | * | ||
| 62 | * \param[out] timing_info The info structure to fill | ||
| 63 | * | ||
| 64 | * \return the error, or GAME_ERROR_NO_ERROR if info was filled | ||
| 65 | */ | ||
| 66 | GAME_ERROR GetGameTiming(game_system_timing* timing_info); | ||
| 67 | |||
| 68 | /*! | ||
| 69 | * \brief Get region of the loaded game | ||
| 70 | * | ||
| 71 | * \return the region, or GAME_REGION_UNKNOWN if unknown or no game is loaded | ||
| 72 | */ | ||
| 73 | GAME_REGION GetRegion(void); | ||
| 74 | |||
| 75 | /*! | ||
| 76 | * \brief Return true if the client requires the frontend to provide a game loop | ||
| 77 | * | ||
| 78 | * The game loop is a thread that calls RunFrame() in a loop at a rate | ||
| 79 | * determined by the playback speed and the client's FPS. | ||
| 80 | * | ||
| 81 | * \return true if the frontend should provide a game loop, false otherwise | ||
| 82 | */ | ||
| 83 | bool RequiresGameLoop(void); | ||
| 84 | |||
| 85 | /*! | ||
| 86 | * \brief Run a single frame for add-ons that use a game loop | ||
| 87 | * | ||
| 88 | * \return the error, or GAME_ERROR_NO_ERROR if there was no error | ||
| 89 | */ | ||
| 90 | GAME_ERROR RunFrame(void); | ||
| 91 | |||
| 92 | /*! | ||
| 93 | * \brief Reset the current game | ||
| 94 | * | ||
| 95 | * \return the error, or GAME_ERROR_NO_ERROR if the game was reset | ||
| 96 | */ | ||
| 97 | GAME_ERROR Reset(void); | ||
| 98 | |||
| 99 | // --- Hardware rendering operations ------------------------------------------- | ||
| 100 | |||
| 101 | /*! | ||
| 102 | * \brief Invalidates the current HW context and reinitializes GPU resources | ||
| 103 | * | ||
| 104 | * Any GL state is lost, and must not be deinitialized explicitly. | ||
| 105 | * | ||
| 106 | * \return the error, or GAME_ERROR_NO_ERROR if the HW context was reset | ||
| 107 | */ | ||
| 108 | GAME_ERROR HwContextReset(void); | ||
| 109 | |||
| 110 | /*! | ||
| 111 | * \brief Called before the context is destroyed | ||
| 112 | * | ||
| 113 | * Resources can be deinitialized at this step. | ||
| 114 | * | ||
| 115 | * \return the error, or GAME_ERROR_NO_ERROR if the HW context was destroyed | ||
| 116 | */ | ||
| 117 | GAME_ERROR HwContextDestroy(void); | ||
| 118 | |||
| 119 | // --- Input operations -------------------------------------------------------- | ||
| 120 | |||
| 121 | /*! | ||
| 122 | * \brief Check if input is accepted for a feature on the controller | ||
| 123 | * | ||
| 124 | * If only a subset of the controller profile is used, this can return false | ||
| 125 | * for unsupported features to not absorb their input. | ||
| 126 | * | ||
| 127 | * If the entire controller profile is used, this should always return true. | ||
| 128 | * | ||
| 129 | * \param controller_id The ID of the controller profile | ||
| 130 | * \param feature_name The name of a feature in that profile | ||
| 131 | * \return true if input is accepted for the feature, false otherwise | ||
| 132 | */ | ||
| 133 | bool HasFeature(const char* controller_id, const char* feature_name); | ||
| 134 | |||
| 135 | /*! | ||
| 136 | * \brief Get the input topology that specifies which controllers can be connected | ||
| 137 | * | ||
| 138 | * \return The input topology, or null to use the default | ||
| 139 | * | ||
| 140 | * If this returns non-null, topology must be freed using FreeTopology(). | ||
| 141 | * | ||
| 142 | * If this returns null, the topology will default to a single port that can | ||
| 143 | * accept all controllers imported by addon.xml. The port ID is set to | ||
| 144 | * the DEFAULT_PORT_ID constant. | ||
| 145 | */ | ||
| 146 | game_input_topology* GetTopology(); | ||
| 147 | |||
| 148 | /*! | ||
| 149 | * \brief Free the topology's resources | ||
| 150 | * | ||
| 151 | * \param topology The topology returned by GetTopology() | ||
| 152 | */ | ||
| 153 | void FreeTopology(game_input_topology* topology); | ||
| 154 | |||
| 155 | /*! | ||
| 156 | * \brief Set the layouts for known controllers | ||
| 157 | * | ||
| 158 | * \param controllers The controller layouts | ||
| 159 | * \param controller_count The number of items in the array | ||
| 160 | * | ||
| 161 | * After loading the input topology, the frontend will call this with | ||
| 162 | * controller layouts for all controllers discovered in the topology. | ||
| 163 | */ | ||
| 164 | void SetControllerLayouts(const game_controller_layout* controllers, unsigned int controller_count); | ||
| 165 | |||
| 166 | /*! | ||
| 167 | * \brief Enable/disable keyboard input using the specified controller | ||
| 168 | * | ||
| 169 | * \param enable True to enable input, false otherwise | ||
| 170 | * \param controller_id The controller ID if enabling, or unused if disabling | ||
| 171 | * | ||
| 172 | * \return True if keyboard input was enabled, false otherwise | ||
| 173 | */ | ||
| 174 | bool EnableKeyboard(bool enable, const char* controller_id); | ||
| 175 | |||
| 176 | /*! | ||
| 177 | * \brief Enable/disable mouse input using the specified controller | ||
| 178 | * | ||
| 179 | * \param enable True to enable input, false otherwise | ||
| 180 | * \param controller_id The controller ID if enabling, or unused if disabling | ||
| 181 | * | ||
| 182 | * \return True if mouse input was enabled, false otherwise | ||
| 183 | */ | ||
| 184 | bool EnableMouse(bool enable, const char* controller_id); | ||
| 185 | |||
| 186 | /*! | ||
| 187 | * \brief Connect/disconnect a controller to a port on the virtual game console | ||
| 188 | * | ||
| 189 | * \param connect True to connect a controller, false to disconnect | ||
| 190 | * \param port_address The address of the port | ||
| 191 | * \param controller_id The controller ID if connecting, or unused if disconnecting | ||
| 192 | * \return True if the \p controller was (dis-)connected to the port, false otherwise | ||
| 193 | * | ||
| 194 | * The address is a string that allows traversal of the controller topology. | ||
| 195 | * It is formed by alternating port IDs and controller IDs separated by "/". | ||
| 196 | * | ||
| 197 | * For example, assume that the topology represented in XML for Snes9x is: | ||
| 198 | * | ||
| 199 | * <logicaltopology> | ||
| 200 | * <port type="controller" id="1"> | ||
| 201 | * <accepts controller="game.controller.snes"/> | ||
| 202 | * <accepts controller="game.controller.snes.multitap"> | ||
| 203 | * <port type="controller" id="1"> | ||
| 204 | * <accepts controller="game.controller.snes"/> | ||
| 205 | * </port> | ||
| 206 | * <port type="controller" id="2"> | ||
| 207 | * <accepts controller="game.controller.snes"/> | ||
| 208 | * </port> | ||
| 209 | * ... | ||
| 210 | * </accepts> | ||
| 211 | * </port> | ||
| 212 | * </logicaltopology> | ||
| 213 | * | ||
| 214 | * To connect a multitap to the console's first port, the multitap's controller | ||
| 215 | * info is set using the port address: | ||
| 216 | * | ||
| 217 | * /1 | ||
| 218 | * | ||
| 219 | * To connect a SNES controller to the second port of the multitap, the | ||
| 220 | * controller info is next set using the address: | ||
| 221 | * | ||
| 222 | * /1/game.controller.multitap/2 | ||
| 223 | * | ||
| 224 | * Any attempts to connect a controller to a port on a disconnected multitap | ||
| 225 | * will return false. | ||
| 226 | */ | ||
| 227 | bool ConnectController(bool connect, const char* port_address, const char* controller_id); | ||
| 228 | |||
| 229 | /*! | ||
| 230 | * \brief Notify the add-on of an input event | ||
| 231 | * | ||
| 232 | * \param event The input event | ||
| 233 | * | ||
| 234 | * \return true if the event was handled, false otherwise | ||
| 235 | */ | ||
| 236 | bool InputEvent(const game_input_event* event); | ||
| 237 | |||
| 238 | // --- Serialization operations ------------------------------------------------ | ||
| 239 | |||
| 240 | /*! | ||
| 241 | * \brief Get the number of bytes required to serialize the game | ||
| 242 | * | ||
| 243 | * \return the number of bytes, or 0 if serialization is not supported | ||
| 244 | */ | ||
| 245 | size_t SerializeSize(void); | ||
| 246 | |||
| 247 | /*! | ||
| 248 | * \brief Serialize the state of the game | ||
| 249 | * | ||
| 250 | * \param data The buffer receiving the serialized game data | ||
| 251 | * \param size The size of the buffer | ||
| 252 | * | ||
| 253 | * \return the error, or GAME_ERROR_NO_ERROR if the game was serialized into the buffer | ||
| 254 | */ | ||
| 255 | GAME_ERROR Serialize(uint8_t* data, size_t size); | ||
| 256 | |||
| 257 | /*! | ||
| 258 | * \brief Deserialize the game from the given state | ||
| 259 | * | ||
| 260 | * \param data A buffer containing the game's new state | ||
| 261 | * \param size The size of the buffer | ||
| 262 | * | ||
| 263 | * \return the error, or GAME_ERROR_NO_ERROR if the game deserialized | ||
| 264 | */ | ||
| 265 | GAME_ERROR Deserialize(const uint8_t* data, size_t size); | ||
| 266 | |||
| 267 | // --- Cheat operations -------------------------------------------------------- | ||
| 268 | |||
| 269 | /*! | ||
| 270 | * \brief Reset the cheat system | ||
| 271 | * | ||
| 272 | * \return the error, or GAME_ERROR_NO_ERROR if the cheat system was reset | ||
| 273 | */ | ||
| 274 | GAME_ERROR CheatReset(void); | ||
| 275 | |||
| 276 | /*! | ||
| 277 | * \brief Get a region of memory | ||
| 278 | * | ||
| 279 | * \param type The type of memory to retrieve | ||
| 280 | * \param data Set to the region of memory; must remain valid until UnloadGame() is called | ||
| 281 | * \param size Set to the size of the region of memory | ||
| 282 | * | ||
| 283 | * \return the error, or GAME_ERROR_NO_ERROR if data was set to a valid buffer | ||
| 284 | */ | ||
| 285 | GAME_ERROR GetMemory(GAME_MEMORY type, uint8_t** data, size_t* size); | ||
| 286 | |||
| 287 | /*! | ||
| 288 | * \brief Set a cheat code | ||
| 289 | * | ||
| 290 | * \param index | ||
| 291 | * \param enabled | ||
| 292 | * \param code | ||
| 293 | * | ||
| 294 | * \return the error, or GAME_ERROR_NO_ERROR if the cheat was set | ||
| 295 | */ | ||
| 296 | GAME_ERROR SetCheat(unsigned int index, bool enabled, const char* code); | ||
| 297 | |||
| 298 | // --- Add-on helper implementation -------------------------------------------- | ||
| 299 | |||
| 300 | /*! | ||
| 301 | * \brief Called by Kodi to assign the function pointers of this add-on to pClient | ||
| 302 | * | ||
| 303 | * Note that get_addon() is defined here, so it will be available in all | ||
| 304 | * compiled game clients. | ||
| 305 | */ | ||
| 306 | void __declspec(dllexport) get_addon(void* ptr) | ||
| 307 | { | ||
| 308 | AddonInstance_Game* pClient = static_cast<AddonInstance_Game*>(ptr); | ||
| 309 | |||
| 310 | pClient->toAddon.LoadGame = LoadGame; | ||
| 311 | pClient->toAddon.LoadGameSpecial = LoadGameSpecial; | ||
| 312 | pClient->toAddon.LoadStandalone = LoadStandalone; | ||
| 313 | pClient->toAddon.UnloadGame = UnloadGame; | ||
| 314 | pClient->toAddon.GetGameTiming = GetGameTiming; | ||
| 315 | pClient->toAddon.GetRegion = GetRegion; | ||
| 316 | pClient->toAddon.RequiresGameLoop = RequiresGameLoop; | ||
| 317 | pClient->toAddon.RunFrame = RunFrame; | ||
| 318 | pClient->toAddon.Reset = Reset; | ||
| 319 | pClient->toAddon.HwContextReset = HwContextReset; | ||
| 320 | pClient->toAddon.HwContextDestroy = HwContextDestroy; | ||
| 321 | pClient->toAddon.HasFeature = HasFeature; | ||
| 322 | pClient->toAddon.GetTopology = GetTopology; | ||
| 323 | pClient->toAddon.FreeTopology = FreeTopology; | ||
| 324 | pClient->toAddon.SetControllerLayouts = SetControllerLayouts; | ||
| 325 | pClient->toAddon.EnableKeyboard = EnableKeyboard; | ||
| 326 | pClient->toAddon.EnableMouse = EnableMouse; | ||
| 327 | pClient->toAddon.ConnectController = ConnectController; | ||
| 328 | pClient->toAddon.InputEvent = InputEvent; | ||
| 329 | pClient->toAddon.SerializeSize = SerializeSize; | ||
| 330 | pClient->toAddon.Serialize = Serialize; | ||
| 331 | pClient->toAddon.Deserialize = Deserialize; | ||
| 332 | pClient->toAddon.CheatReset = CheatReset; | ||
| 333 | pClient->toAddon.GetMemory = GetMemory; | ||
| 334 | pClient->toAddon.SetCheat = SetCheat; | ||
| 335 | } | ||
| 336 | |||
| 337 | #ifdef __cplusplus | ||
| 338 | } | ||
| 339 | #endif | ||
| 340 | |||
