diff options
| author | manuel <manuel@mausz.at> | 2016-12-13 13:45:04 +0100 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2016-12-13 13:45:04 +0100 |
| commit | 1e5bdca69f7676b2dbcd64f0f44f31b12b337b7c (patch) | |
| tree | de36b55c5b49c0b266ebf8a5276815d2ac1a8ae5 /xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h | |
| parent | 8cdf8dec703d882b46ca50a769fabb95ffc48e2c (diff) | |
| download | kodi-pvr-build-1e5bdca69f7676b2dbcd64f0f44f31b12b337b7c.tar.gz kodi-pvr-build-1e5bdca69f7676b2dbcd64f0f44f31b12b337b7c.tar.bz2 kodi-pvr-build-1e5bdca69f7676b2dbcd64f0f44f31b12b337b7c.zip | |
sync with upstream
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 | 287 |
1 files changed, 287 insertions, 0 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 new file mode 100644 index 0000000..247f24b --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h | |||
| @@ -0,0 +1,287 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-2016 Team Kodi | ||
| 3 | * http://kodi.tv | ||
| 4 | * | ||
| 5 | * This Program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 8 | * any later version. | ||
| 9 | * | ||
| 10 | * This Program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this Program; see the file COPYING. If not, see | ||
| 17 | * <http://www.gnu.org/licenses/>. | ||
| 18 | * | ||
| 19 | */ | ||
| 20 | #ifndef KODI_GAME_DLL_H_ | ||
| 21 | #define KODI_GAME_DLL_H_ | ||
| 22 | |||
| 23 | #include "kodi_game_types.h" | ||
| 24 | |||
| 25 | #ifdef __cplusplus | ||
| 26 | extern "C" { | ||
| 27 | #endif | ||
| 28 | |||
| 29 | // --- Game API operations ----------------------------------------------------- | ||
| 30 | |||
| 31 | /*! | ||
| 32 | * \brief Return GAME_API_VERSION_STRING | ||
| 33 | * | ||
| 34 | * The add-on is backwards compatible with the frontend if this API version is | ||
| 35 | * is at least the frontend's minimum API version. | ||
| 36 | * | ||
| 37 | * \return Must be GAME_API_VERSION_STRING | ||
| 38 | */ | ||
| 39 | const char* GetGameAPIVersion(void); | ||
| 40 | |||
| 41 | /*! | ||
| 42 | * \brief Return GAME_MIN_API_VERSION_STRING | ||
| 43 | * | ||
| 44 | * The add-on is forwards compatible with the frontend if this minimum version | ||
| 45 | * is no more than the frontend's API version. | ||
| 46 | * | ||
| 47 | * \return Must be GAME_MIN_API_VERSION_STRING | ||
| 48 | */ | ||
| 49 | const char* GetMininumGameAPIVersion(void); | ||
| 50 | |||
| 51 | // --- Game operations --------------------------------------------------------- | ||
| 52 | |||
| 53 | /*! | ||
| 54 | * \brief Load a game | ||
| 55 | * | ||
| 56 | * \param url The URL to load | ||
| 57 | * | ||
| 58 | * return the error, or GAME_ERROR_NO_ERROR if the game was loaded | ||
| 59 | */ | ||
| 60 | GAME_ERROR LoadGame(const char* url); | ||
| 61 | |||
| 62 | /*! | ||
| 63 | * \brief Load a game that requires multiple files | ||
| 64 | * | ||
| 65 | * \param type The game stype | ||
| 66 | * \param urls An array of urls | ||
| 67 | * \param urlCount The number of urls in the array | ||
| 68 | * | ||
| 69 | * \return the error, or GAME_ERROR_NO_ERROR if the game was loaded | ||
| 70 | */ | ||
| 71 | GAME_ERROR LoadGameSpecial(SPECIAL_GAME_TYPE type, const char** urls, size_t urlCount); | ||
| 72 | |||
| 73 | /*! | ||
| 74 | * \brief Begin playing without a game file | ||
| 75 | * | ||
| 76 | * If the add-on supports standalone mode, it must add the <supports_standalone> | ||
| 77 | * tag to the extension point in addon.xml: | ||
| 78 | * | ||
| 79 | * <supports_no_game>false</supports_no_game> | ||
| 80 | * | ||
| 81 | * \return the error, or GAME_ERROR_NO_ERROR if the game add-on was loaded | ||
| 82 | */ | ||
| 83 | GAME_ERROR LoadStandalone(void); | ||
| 84 | |||
| 85 | /*! | ||
| 86 | * \brief Unload the current game | ||
| 87 | * | ||
| 88 | * \return the error, or GAME_ERROR_NO_ERROR if the game was unloaded | ||
| 89 | */ | ||
| 90 | /*! Unloads a currently loaded game */ | ||
| 91 | GAME_ERROR UnloadGame(void); | ||
| 92 | |||
| 93 | /*! | ||
| 94 | * \brief Get information about the loaded game | ||
| 95 | * | ||
| 96 | * \param info The info structure to fill | ||
| 97 | * | ||
| 98 | * \return the error, or GAME_ERROR_NO_ERROR if info was filled | ||
| 99 | */ | ||
| 100 | GAME_ERROR GetGameInfo(game_system_av_info* info); | ||
| 101 | |||
| 102 | /*! | ||
| 103 | * \brief Get region of the loaded game | ||
| 104 | * | ||
| 105 | * \return the region, or GAME_REGION_UNKNOWN if unknown or no game is loaded | ||
| 106 | */ | ||
| 107 | GAME_REGION GetRegion(void); | ||
| 108 | |||
| 109 | /*! | ||
| 110 | * \brief Return true if the client requires the frontend to provide a game loop | ||
| 111 | * | ||
| 112 | * The game loop is a thread that calls RunFrame() in a loop at a rate | ||
| 113 | * determined by the playback speed and the client's FPS. | ||
| 114 | * | ||
| 115 | * \return true if the frontend should provide a game loop, false otherwise | ||
| 116 | */ | ||
| 117 | bool RequiresGameLoop(void); | ||
| 118 | |||
| 119 | /*! | ||
| 120 | * \brief Run a single frame for add-ons that use a game loop | ||
| 121 | * | ||
| 122 | * \return the error, or GAME_ERROR_NO_ERROR if there was no error | ||
| 123 | */ | ||
| 124 | GAME_ERROR RunFrame(void); | ||
| 125 | |||
| 126 | /*! | ||
| 127 | * \brief Reset the current game | ||
| 128 | * | ||
| 129 | * \return the error, or GAME_ERROR_NO_ERROR if the game was reset | ||
| 130 | */ | ||
| 131 | GAME_ERROR Reset(void); | ||
| 132 | |||
| 133 | // --- Hardware rendering operations ------------------------------------------- | ||
| 134 | |||
| 135 | /*! | ||
| 136 | * \brief Invalidates the current HW context and reinitializes GPU resources | ||
| 137 | * | ||
| 138 | * Any GL state is lost, and must not be deinitialized explicitly. | ||
| 139 | * | ||
| 140 | * \return the error, or GAME_ERROR_NO_ERROR if the HW context was reset | ||
| 141 | */ | ||
| 142 | GAME_ERROR HwContextReset(void); | ||
| 143 | |||
| 144 | /*! | ||
| 145 | * \brief Called before the context is destroyed | ||
| 146 | * | ||
| 147 | * Resources can be deinitialized at this step. | ||
| 148 | * | ||
| 149 | * \return the error, or GAME_ERROR_NO_ERROR if the HW context was destroyed | ||
| 150 | */ | ||
| 151 | GAME_ERROR HwContextDestroy(void); | ||
| 152 | |||
| 153 | // --- Input operations -------------------------------------------------------- | ||
| 154 | |||
| 155 | /*! | ||
| 156 | * \brief Notify the add-on of a status change on an open port | ||
| 157 | * | ||
| 158 | * Ports can be opened using the OpenPort() callback | ||
| 159 | * | ||
| 160 | * \param port Non-negative for a joystick port, or GAME_INPUT_PORT value otherwise | ||
| 161 | * \param collected True if a controller was connected, false if disconnected | ||
| 162 | * \param controller The connected controller | ||
| 163 | */ | ||
| 164 | void UpdatePort(int port, bool connected, const game_controller* controller); | ||
| 165 | |||
| 166 | /*! | ||
| 167 | * \brief Check if input is accepted for a feature on the controller | ||
| 168 | * | ||
| 169 | * If only a subset of the controller profile is used, this can return false | ||
| 170 | * for unsupported features to not absorb their input. | ||
| 171 | * | ||
| 172 | * If the entire controller profile is used, this should always return true. | ||
| 173 | * | ||
| 174 | * \param controller_id The ID of the controller profile | ||
| 175 | * \param feature_name The name of a feature in that profile | ||
| 176 | * \return true if input is accepted for the feature, false otherwise | ||
| 177 | */ | ||
| 178 | bool HasFeature(const char* controller_id, const char* feature_name); | ||
| 179 | |||
| 180 | /*! | ||
| 181 | * \brief Notify the add-on of an input event | ||
| 182 | * | ||
| 183 | * \param event The input event | ||
| 184 | * | ||
| 185 | * \return true if the event was handled, false otherwise | ||
| 186 | */ | ||
| 187 | bool InputEvent(const game_input_event* event); | ||
| 188 | |||
| 189 | // --- Serialization operations ------------------------------------------------ | ||
| 190 | |||
| 191 | /*! | ||
| 192 | * \brief Get the number of bytes required to serialize the game | ||
| 193 | * | ||
| 194 | * \return the number of bytes, or 0 if serialization is not supported | ||
| 195 | */ | ||
| 196 | size_t SerializeSize(void); | ||
| 197 | |||
| 198 | /*! | ||
| 199 | * \brief Serialize the state of the game | ||
| 200 | * | ||
| 201 | * \param data The buffer receiving the serialized game data | ||
| 202 | * \param size The size of the buffer | ||
| 203 | * | ||
| 204 | * \return the error, or GAME_ERROR_NO_ERROR if the game was serialized into the buffer | ||
| 205 | */ | ||
| 206 | GAME_ERROR Serialize(uint8_t* data, size_t size); | ||
| 207 | |||
| 208 | /*! | ||
| 209 | * \brief Deserialize the game from the given state | ||
| 210 | * | ||
| 211 | * \param data A buffer containing the game's new state | ||
| 212 | * \param size The size of the buffer | ||
| 213 | * | ||
| 214 | * \return the error, or GAME_ERROR_NO_ERROR if the game deserialized | ||
| 215 | */ | ||
| 216 | GAME_ERROR Deserialize(const uint8_t* data, size_t size); | ||
| 217 | |||
| 218 | // --- Cheat operations -------------------------------------------------------- | ||
| 219 | |||
| 220 | /*! | ||
| 221 | * \brief Reset the cheat system | ||
| 222 | * | ||
| 223 | * \return the error, or GAME_ERROR_NO_ERROR if the cheat system was reset | ||
| 224 | */ | ||
| 225 | GAME_ERROR CheatReset(void); | ||
| 226 | |||
| 227 | /*! | ||
| 228 | * \brief Get a region of memory | ||
| 229 | * | ||
| 230 | * \param type The type of memory to retrieve | ||
| 231 | * \param data Set to the region of memory; must remain valid until UnloadGame() is called | ||
| 232 | * \param size Set to the size of the region of memory | ||
| 233 | * | ||
| 234 | * \return the error, or GAME_ERROR_NO_ERROR if data was set to a valid buffer | ||
| 235 | */ | ||
| 236 | GAME_ERROR GetMemory(GAME_MEMORY type, const uint8_t** data, size_t* size); | ||
| 237 | |||
| 238 | /*! | ||
| 239 | * \brief Set a cheat code | ||
| 240 | * | ||
| 241 | * \param index | ||
| 242 | * \param enabled | ||
| 243 | * \param code | ||
| 244 | * | ||
| 245 | * \return the error, or GAME_ERROR_NO_ERROR if the cheat was set | ||
| 246 | */ | ||
| 247 | GAME_ERROR SetCheat(unsigned int index, bool enabled, const char* code); | ||
| 248 | |||
| 249 | // --- Add-on helper implementation -------------------------------------------- | ||
| 250 | |||
| 251 | /*! | ||
| 252 | * \brief Called by Kodi to assign the function pointers of this add-on to pClient | ||
| 253 | * | ||
| 254 | * Note that get_addon() is defined here, so it will be available in all | ||
| 255 | * compiled game clients. | ||
| 256 | */ | ||
| 257 | void __declspec(dllexport) get_addon(GameClient* pClient) | ||
| 258 | { | ||
| 259 | pClient->GetGameAPIVersion = GetGameAPIVersion; | ||
| 260 | pClient->GetMininumGameAPIVersion = GetMininumGameAPIVersion; | ||
| 261 | pClient->LoadGame = LoadGame; | ||
| 262 | pClient->LoadGameSpecial = LoadGameSpecial; | ||
| 263 | pClient->LoadStandalone = LoadStandalone; | ||
| 264 | pClient->UnloadGame = UnloadGame; | ||
| 265 | pClient->GetGameInfo = GetGameInfo; | ||
| 266 | pClient->GetRegion = GetRegion; | ||
| 267 | pClient->RequiresGameLoop = RequiresGameLoop; | ||
| 268 | pClient->RunFrame = RunFrame; | ||
| 269 | pClient->Reset = Reset; | ||
| 270 | pClient->HwContextReset = HwContextReset; | ||
| 271 | pClient->HwContextDestroy = HwContextDestroy; | ||
| 272 | pClient->UpdatePort = UpdatePort; | ||
| 273 | pClient->HasFeature = HasFeature; | ||
| 274 | pClient->InputEvent = InputEvent; | ||
| 275 | pClient->SerializeSize = SerializeSize; | ||
| 276 | pClient->Serialize = Serialize; | ||
| 277 | pClient->Deserialize = Deserialize; | ||
| 278 | pClient->CheatReset = CheatReset; | ||
| 279 | pClient->GetMemory = GetMemory; | ||
| 280 | pClient->SetCheat = SetCheat; | ||
| 281 | } | ||
| 282 | |||
| 283 | #ifdef __cplusplus | ||
| 284 | } | ||
| 285 | #endif | ||
| 286 | |||
| 287 | #endif // KODI_GAME_DLL_H_ | ||
