diff options
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit')
4 files changed, 0 insertions, 1173 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_callbacks.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_callbacks.h deleted file mode 100644 index 6057f46..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_callbacks.h +++ /dev/null | |||
| @@ -1,161 +0,0 @@ | |||
| 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_CALLBACKS_H_ | ||
| 21 | #define KODI_GAME_CALLBACKS_H_ | ||
| 22 | |||
| 23 | #include "kodi_game_types.h" | ||
| 24 | |||
| 25 | #ifdef __cplusplus | ||
| 26 | extern "C" { | ||
| 27 | #endif | ||
| 28 | |||
| 29 | typedef struct CB_GameLib | ||
| 30 | { | ||
| 31 | // --- Game callbacks -------------------------------------------------------- | ||
| 32 | |||
| 33 | /*! | ||
| 34 | * \brief Requests the frontend to stop the current game | ||
| 35 | */ | ||
| 36 | void (*CloseGame)(void* addonData); | ||
| 37 | |||
| 38 | /*! | ||
| 39 | * \brief Create a video stream for pixel data | ||
| 40 | * | ||
| 41 | * \param format The type of pixel data accepted by this stream | ||
| 42 | * \param width The frame width | ||
| 43 | * \param height The frame height | ||
| 44 | * \param rotation The rotation (counter-clockwise) of the video frames | ||
| 45 | * | ||
| 46 | * \return 0 on success or -1 if a video stream is already created | ||
| 47 | */ | ||
| 48 | int (*OpenPixelStream)(void* addonData, GAME_PIXEL_FORMAT format, unsigned int width, unsigned int height, GAME_VIDEO_ROTATION rotation); | ||
| 49 | |||
| 50 | /*! | ||
| 51 | * \brief Create a video stream for encoded video data | ||
| 52 | * | ||
| 53 | * \param codec The video format accepted by this stream | ||
| 54 | * | ||
| 55 | * \return 0 on success or -1 if a video stream is already created | ||
| 56 | */ | ||
| 57 | int (*OpenVideoStream)(void* addonData, GAME_VIDEO_CODEC codec); | ||
| 58 | |||
| 59 | /*! | ||
| 60 | * \brief Create an audio stream for PCM audio data | ||
| 61 | * | ||
| 62 | * \param format The type of audio data accepted by this stream | ||
| 63 | * \param channel_map The channel layout terminated by GAME_CH_NULL | ||
| 64 | * | ||
| 65 | * \return 0 on success or -1 if an audio stream is already created | ||
| 66 | */ | ||
| 67 | int (*OpenPCMStream)(void* addonData, GAME_PCM_FORMAT format, const GAME_AUDIO_CHANNEL* channel_map); | ||
| 68 | |||
| 69 | /*! | ||
| 70 | * \brief Create an audio stream for encoded audio data | ||
| 71 | * | ||
| 72 | * \param codec The audio format accepted by this stream | ||
| 73 | * \param channel_map The channel layout terminated by GAME_CH_NULL | ||
| 74 | * | ||
| 75 | * \return 0 on success or -1 if an audio stream is already created | ||
| 76 | */ | ||
| 77 | int(*OpenAudioStream)(void* addonData, GAME_AUDIO_CODEC codec, const GAME_AUDIO_CHANNEL* channel_map); | ||
| 78 | |||
| 79 | /*! | ||
| 80 | * \brief Add a data packet to an audio or video stream | ||
| 81 | * | ||
| 82 | * \param stream The target stream | ||
| 83 | * \param data The data packet | ||
| 84 | * \param size The size of the data | ||
| 85 | */ | ||
| 86 | void (*AddStreamData)(void* addonData, GAME_STREAM_TYPE stream, const uint8_t* data, unsigned int size); | ||
| 87 | |||
| 88 | /*! | ||
| 89 | * \brief Free the specified stream | ||
| 90 | * | ||
| 91 | * \param stream The stream to close | ||
| 92 | */ | ||
| 93 | void (*CloseStream)(void* addonData, GAME_STREAM_TYPE stream); | ||
| 94 | |||
| 95 | // -- Hardware rendering callbacks ------------------------------------------- | ||
| 96 | |||
| 97 | /*! | ||
| 98 | * \brief Enable hardware rendering | ||
| 99 | * | ||
| 100 | * \param hw_info A struct of properties for the hardware rendering system | ||
| 101 | */ | ||
| 102 | void (*EnableHardwareRendering)(void* addonData, const game_hw_info* hw_info); | ||
| 103 | |||
| 104 | /*! | ||
| 105 | * \brief Get the framebuffer for rendering | ||
| 106 | * | ||
| 107 | * \return The framebuffer | ||
| 108 | */ | ||
| 109 | uintptr_t (*HwGetCurrentFramebuffer)(void* addonData); | ||
| 110 | |||
| 111 | /*! | ||
| 112 | * \brief Get a symbol from the hardware context | ||
| 113 | * | ||
| 114 | * \param symbol The symbol's name | ||
| 115 | * | ||
| 116 | * \return A function pointer for the specified symbol | ||
| 117 | */ | ||
| 118 | game_proc_address_t (*HwGetProcAddress)(void* addonData, const char* symbol); | ||
| 119 | |||
| 120 | /*! | ||
| 121 | * \brief Called when a frame is being rendered | ||
| 122 | */ | ||
| 123 | void (*RenderFrame)(void* addonData); | ||
| 124 | |||
| 125 | // --- Input callbacks ------------------------------------------------------- | ||
| 126 | |||
| 127 | /*! | ||
| 128 | * \brief Begin reporting events for the specified joystick port | ||
| 129 | * | ||
| 130 | * \param port The zero-indexed port number | ||
| 131 | * | ||
| 132 | * \return true if the port was opened, false otherwise | ||
| 133 | */ | ||
| 134 | bool (*OpenPort)(void* addonData, unsigned int port); | ||
| 135 | |||
| 136 | /*! | ||
| 137 | * \brief End reporting events for the specified port | ||
| 138 | * | ||
| 139 | * \param port The port number passed to OpenPort() | ||
| 140 | */ | ||
| 141 | void (*ClosePort)(void* addonData, unsigned int port); | ||
| 142 | |||
| 143 | /*! | ||
| 144 | * \brief Notify the port of an input event | ||
| 145 | * | ||
| 146 | * \param event The input event | ||
| 147 | * | ||
| 148 | * Input events can arrive for the following sources: | ||
| 149 | * - GAME_INPUT_EVENT_MOTOR | ||
| 150 | * | ||
| 151 | * \return true if the event was handled, false otherwise | ||
| 152 | */ | ||
| 153 | bool (*InputEvent)(void* addonData, const game_input_event* event); | ||
| 154 | |||
| 155 | } CB_GameLib; | ||
| 156 | |||
| 157 | #ifdef __cplusplus | ||
| 158 | } | ||
| 159 | #endif | ||
| 160 | |||
| 161 | #endif // KODI_GAME_CALLBACKS_H_ | ||
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 247f24b..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h +++ /dev/null | |||
| @@ -1,287 +0,0 @@ | |||
| 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_ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h deleted file mode 100644 index fa2762d..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h +++ /dev/null | |||
| @@ -1,487 +0,0 @@ | |||
| 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_TYPES_H_ | ||
| 21 | #define KODI_GAME_TYPES_H_ | ||
| 22 | |||
| 23 | /* current game API version */ | ||
| 24 | #define GAME_API_VERSION "1.0.28" | ||
| 25 | |||
| 26 | /* min. game API version */ | ||
| 27 | #define GAME_MIN_API_VERSION "1.0.28" | ||
| 28 | |||
| 29 | #include <stddef.h> | ||
| 30 | #include <stdint.h> | ||
| 31 | |||
| 32 | #ifdef TARGET_WINDOWS | ||
| 33 | #include <windows.h> | ||
| 34 | #else | ||
| 35 | #ifndef __cdecl | ||
| 36 | #define __cdecl | ||
| 37 | #endif | ||
| 38 | #ifndef __declspec | ||
| 39 | #define __declspec(X) | ||
| 40 | #endif | ||
| 41 | #endif | ||
| 42 | |||
| 43 | #undef ATTRIBUTE_PACKED | ||
| 44 | #undef PRAGMA_PACK_BEGIN | ||
| 45 | #undef PRAGMA_PACK_END | ||
| 46 | |||
| 47 | #if defined(__GNUC__) | ||
| 48 | #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) | ||
| 49 | #define ATTRIBUTE_PACKED __attribute__ ((packed)) | ||
| 50 | #define PRAGMA_PACK 0 | ||
| 51 | #endif | ||
| 52 | #endif | ||
| 53 | |||
| 54 | #if !defined(ATTRIBUTE_PACKED) | ||
| 55 | #define ATTRIBUTE_PACKED | ||
| 56 | #define PRAGMA_PACK 1 | ||
| 57 | #endif | ||
| 58 | |||
| 59 | #ifdef BUILD_KODI_ADDON | ||
| 60 | #include "XBMC_vkeys.h" | ||
| 61 | #else | ||
| 62 | #include "input/XBMC_vkeys.h" | ||
| 63 | #endif | ||
| 64 | |||
| 65 | #ifdef __cplusplus | ||
| 66 | extern "C" { | ||
| 67 | #endif | ||
| 68 | |||
| 69 | /*! Game add-on error codes */ | ||
| 70 | typedef enum GAME_ERROR | ||
| 71 | { | ||
| 72 | GAME_ERROR_NO_ERROR, // no error occurred | ||
| 73 | GAME_ERROR_UNKNOWN, // an unknown error occurred | ||
| 74 | GAME_ERROR_NOT_IMPLEMENTED, // the method that the frontend called is not implemented | ||
| 75 | GAME_ERROR_REJECTED, // the command was rejected by the game client | ||
| 76 | GAME_ERROR_INVALID_PARAMETERS, // the parameters of the method that was called are invalid for this operation | ||
| 77 | GAME_ERROR_FAILED, // the command failed | ||
| 78 | GAME_ERROR_NOT_LOADED, // no game is loaded | ||
| 79 | GAME_ERROR_RESTRICTED, // game requires restricted resources | ||
| 80 | } GAME_ERROR; | ||
| 81 | |||
| 82 | typedef enum GAME_STREAM_TYPE | ||
| 83 | { | ||
| 84 | GAME_STREAM_UNKNOWN, | ||
| 85 | GAME_STREAM_AUDIO, | ||
| 86 | GAME_STREAM_VIDEO, | ||
| 87 | } GAME_STREAM_TYPE; | ||
| 88 | |||
| 89 | typedef enum GAME_PIXEL_FORMAT | ||
| 90 | { | ||
| 91 | GAME_PIXEL_FORMAT_UNKNOWN, | ||
| 92 | GAME_PIXEL_FORMAT_YUV420P, | ||
| 93 | GAME_PIXEL_FORMAT_0RGB8888, | ||
| 94 | GAME_PIXEL_FORMAT_RGB565, | ||
| 95 | GAME_PIXEL_FORMAT_0RGB1555, | ||
| 96 | } GAME_PIXEL_FORMAT; | ||
| 97 | |||
| 98 | typedef enum GAME_VIDEO_CODEC | ||
| 99 | { | ||
| 100 | GAME_VIDEO_CODEC_UNKNOWN, | ||
| 101 | GAME_VIDEO_CODEC_H264, | ||
| 102 | GAME_VIDEO_CODEC_THEORA, | ||
| 103 | } GAME_VIDEO_CODEC; | ||
| 104 | |||
| 105 | typedef enum GAME_VIDEO_ROTATION // Counter-clockwise | ||
| 106 | { | ||
| 107 | GAME_VIDEO_ROTATION_0, | ||
| 108 | GAME_VIDEO_ROTATION_90, | ||
| 109 | GAME_VIDEO_ROTATION_180, | ||
| 110 | GAME_VIDEO_ROTATION_270, | ||
| 111 | } GAME_VIDEO_ROTATION; | ||
| 112 | |||
| 113 | typedef enum GAME_PCM_FORMAT | ||
| 114 | { | ||
| 115 | GAME_PCM_FORMAT_UNKNOWN, | ||
| 116 | GAME_PCM_FORMAT_S16NE, | ||
| 117 | } GAME_PCM_FORMAT; | ||
| 118 | |||
| 119 | typedef enum GAME_AUDIO_CODEC | ||
| 120 | { | ||
| 121 | GAME_AUDIO_CODEC_UNKNOWN, | ||
| 122 | GAME_AUDIO_CODEC_OPUS, | ||
| 123 | } GAME_AUDIO_CODEC; | ||
| 124 | |||
| 125 | typedef enum GAME_AUDIO_CHANNEL | ||
| 126 | { | ||
| 127 | GAME_CH_NULL, // Channel list terminator | ||
| 128 | GAME_CH_FL, | ||
| 129 | GAME_CH_FR, | ||
| 130 | GAME_CH_FC, | ||
| 131 | GAME_CH_LFE, | ||
| 132 | GAME_CH_BL, | ||
| 133 | GAME_CH_BR, | ||
| 134 | GAME_CH_FLOC, | ||
| 135 | GAME_CH_FROC, | ||
| 136 | GAME_CH_BC, | ||
| 137 | GAME_CH_SL, | ||
| 138 | GAME_CH_SR, | ||
| 139 | GAME_CH_TFL, | ||
| 140 | GAME_CH_TFR, | ||
| 141 | GAME_CH_TFC, | ||
| 142 | GAME_CH_TC, | ||
| 143 | GAME_CH_TBL, | ||
| 144 | GAME_CH_TBR, | ||
| 145 | GAME_CH_TBC, | ||
| 146 | GAME_CH_BLOC, | ||
| 147 | GAME_CH_BROC, | ||
| 148 | } GAME_AUDIO_CHANNEL; | ||
| 149 | |||
| 150 | // TODO | ||
| 151 | typedef enum GAME_HW_FRAME_BUFFER | ||
| 152 | { | ||
| 153 | GAME_HW_FRAME_BUFFER_VALID, // Pass this to game_video_refresh if rendering to hardware | ||
| 154 | GAME_HW_FRAME_BUFFER_DUPLICATE, // Passing NULL to game_video_refresh is still a frame dupe as normal | ||
| 155 | GAME_HW_FRAME_BUFFER_RENDER, | ||
| 156 | } GAME_HW_FRAME_BUFFER; | ||
| 157 | |||
| 158 | typedef enum GAME_HW_CONTEXT_TYPE | ||
| 159 | { | ||
| 160 | GAME_HW_CONTEXT_NONE, | ||
| 161 | GAME_HW_CONTEXT_OPENGL, // OpenGL 2.x. Latest version available before 3.x+. Driver can choose to use latest compatibility context | ||
| 162 | GAME_HW_CONTEXT_OPENGLES2, // GLES 2.0 | ||
| 163 | GAME_HW_CONTEXT_OPENGL_CORE, // Modern desktop core GL context. Use major/minor fields to set GL version | ||
| 164 | GAME_HW_CONTEXT_OPENGLES3, // GLES 3.0 | ||
| 165 | } GAME_HW_CONTEXT_TYPE; | ||
| 166 | |||
| 167 | typedef enum GAME_INPUT_PORT | ||
| 168 | { | ||
| 169 | GAME_INPUT_PORT_JOYSTICK_START = 0, // Non-negative values are for joystick ports | ||
| 170 | GAME_INPUT_PORT_KEYBOARD = -1, | ||
| 171 | GAME_INPUT_PORT_MOUSE = -2, | ||
| 172 | } GAME_INPUT_PORT; | ||
| 173 | |||
| 174 | typedef enum GAME_INPUT_EVENT_SOURCE | ||
| 175 | { | ||
| 176 | GAME_INPUT_EVENT_DIGITAL_BUTTON, | ||
| 177 | GAME_INPUT_EVENT_ANALOG_BUTTON, | ||
| 178 | GAME_INPUT_EVENT_ANALOG_STICK, | ||
| 179 | GAME_INPUT_EVENT_ACCELEROMETER, | ||
| 180 | GAME_INPUT_EVENT_KEY, | ||
| 181 | GAME_INPUT_EVENT_RELATIVE_POINTER, | ||
| 182 | GAME_INPUT_EVENT_ABSOLUTE_POINTER, | ||
| 183 | GAME_INPUT_EVENT_MOTOR, | ||
| 184 | } GAME_INPUT_EVENT_SOURCE; | ||
| 185 | |||
| 186 | typedef enum GAME_KEY_MOD | ||
| 187 | { | ||
| 188 | GAME_KEY_MOD_NONE = 0x00, | ||
| 189 | |||
| 190 | GAME_KEY_MOD_SHIFT = 0x01, | ||
| 191 | GAME_KEY_MOD_CTRL = 0x02, | ||
| 192 | GAME_KEY_MOD_ALT = 0x04, | ||
| 193 | GAME_KEY_MOD_RALT = 0x08, | ||
| 194 | GAME_KEY_MOD_META = 0x10, | ||
| 195 | |||
| 196 | GAME_KEY_MOD_NUMLOCK = 0x20, | ||
| 197 | GAME_KEY_MOD_CAPSLOCK = 0x40, | ||
| 198 | GAME_KEY_MOD_SCROLLOCK = 0x80, | ||
| 199 | } GAME_KEY_MOD; | ||
| 200 | |||
| 201 | /*! Returned from game_get_region() */ | ||
| 202 | typedef enum GAME_REGION | ||
| 203 | { | ||
| 204 | GAME_REGION_UNKNOWN, | ||
| 205 | GAME_REGION_NTSC, | ||
| 206 | GAME_REGION_PAL, | ||
| 207 | } GAME_REGION; | ||
| 208 | |||
| 209 | /*! | ||
| 210 | * Special game types passed into game_load_game_special(). Only used when | ||
| 211 | * multiple ROMs are required. | ||
| 212 | */ | ||
| 213 | typedef enum SPECIAL_GAME_TYPE | ||
| 214 | { | ||
| 215 | SPECIAL_GAME_TYPE_BSX, | ||
| 216 | SPECIAL_GAME_TYPE_BSX_SLOTTED, | ||
| 217 | SPECIAL_GAME_TYPE_SUFAMI_TURBO, | ||
| 218 | SPECIAL_GAME_TYPE_SUPER_GAME_BOY, | ||
| 219 | } SPECIAL_GAME_TYPE; | ||
| 220 | |||
| 221 | typedef enum GAME_MEMORY | ||
| 222 | { | ||
| 223 | /*! | ||
| 224 | * Passed to game_get_memory_data/size(). If the memory type doesn't apply | ||
| 225 | * to the implementation NULL/0 can be returned. | ||
| 226 | */ | ||
| 227 | GAME_MEMORY_MASK = 0xff, | ||
| 228 | |||
| 229 | /*! | ||
| 230 | * Regular save ram. This ram is usually found on a game cartridge, backed | ||
| 231 | * up by a battery. If save game data is too complex for a single memory | ||
| 232 | * buffer, the SYSTEM_DIRECTORY environment callback can be used. | ||
| 233 | */ | ||
| 234 | GAME_MEMORY_SAVE_RAM = 0, | ||
| 235 | |||
| 236 | /*! | ||
| 237 | * Some games have a built-in clock to keep track of time. This memory is | ||
| 238 | * usually just a couple of bytes to keep track of time. | ||
| 239 | */ | ||
| 240 | GAME_MEMORY_RTC = 1, | ||
| 241 | |||
| 242 | /*! System ram lets a frontend peek into a game systems main RAM */ | ||
| 243 | GAME_MEMORY_SYSTEM_RAM = 2, | ||
| 244 | |||
| 245 | /*! Video ram lets a frontend peek into a game systems video RAM (VRAM) */ | ||
| 246 | GAME_MEMORY_VIDEO_RAM = 3, | ||
| 247 | |||
| 248 | /*! Special memory types */ | ||
| 249 | GAME_MEMORY_SNES_BSX_RAM = ((1 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 250 | GAME_MEMORY_SNES_BSX_PRAM = ((2 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 251 | GAME_MEMORY_SNES_SUFAMI_TURBO_A_RAM= ((3 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 252 | GAME_MEMORY_SNES_SUFAMI_TURBO_B_RAM= ((4 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 253 | GAME_MEMORY_SNES_GAME_BOY_RAM = ((5 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 254 | GAME_MEMORY_SNES_GAME_BOY_RTC = ((6 << 8) | GAME_MEMORY_RTC), | ||
| 255 | } GAME_MEMORY; | ||
| 256 | |||
| 257 | /*! ID values for SIMD CPU features */ | ||
| 258 | typedef enum GAME_SIMD | ||
| 259 | { | ||
| 260 | GAME_SIMD_SSE = (1 << 0), | ||
| 261 | GAME_SIMD_SSE2 = (1 << 1), | ||
| 262 | GAME_SIMD_VMX = (1 << 2), | ||
| 263 | GAME_SIMD_VMX128 = (1 << 3), | ||
| 264 | GAME_SIMD_AVX = (1 << 4), | ||
| 265 | GAME_SIMD_NEON = (1 << 5), | ||
| 266 | GAME_SIMD_SSE3 = (1 << 6), | ||
| 267 | GAME_SIMD_SSSE3 = (1 << 7), | ||
| 268 | GAME_SIMD_MMX = (1 << 8), | ||
| 269 | GAME_SIMD_MMXEXT = (1 << 9), | ||
| 270 | GAME_SIMD_SSE4 = (1 << 10), | ||
| 271 | GAME_SIMD_SSE42 = (1 << 11), | ||
| 272 | GAME_SIMD_AVX2 = (1 << 12), | ||
| 273 | GAME_SIMD_VFPU = (1 << 13), | ||
| 274 | } GAME_SIMD; | ||
| 275 | |||
| 276 | typedef enum GAME_ROTATION | ||
| 277 | { | ||
| 278 | GAME_ROTATION_0_CW, | ||
| 279 | GAME_ROTATION_90_CW, | ||
| 280 | GAME_ROTATION_180_CW, | ||
| 281 | GAME_ROTATION_270_CW, | ||
| 282 | } GAME_ROTATION; | ||
| 283 | |||
| 284 | typedef struct game_controller | ||
| 285 | { | ||
| 286 | const char* controller_id; | ||
| 287 | unsigned int digital_button_count; | ||
| 288 | unsigned int analog_button_count; | ||
| 289 | unsigned int analog_stick_count; | ||
| 290 | unsigned int accelerometer_count; | ||
| 291 | unsigned int key_count; | ||
| 292 | unsigned int rel_pointer_count; | ||
| 293 | unsigned int abs_pointer_count; | ||
| 294 | unsigned int motor_count; | ||
| 295 | } ATTRIBUTE_PACKED game_controller; | ||
| 296 | |||
| 297 | typedef struct game_digital_button_event | ||
| 298 | { | ||
| 299 | bool pressed; | ||
| 300 | } ATTRIBUTE_PACKED game_digital_button_event; | ||
| 301 | |||
| 302 | typedef struct game_analog_button_event | ||
| 303 | { | ||
| 304 | float magnitude; | ||
| 305 | } ATTRIBUTE_PACKED game_analog_button_event; | ||
| 306 | |||
| 307 | typedef struct game_analog_stick_event | ||
| 308 | { | ||
| 309 | float x; | ||
| 310 | float y; | ||
| 311 | } ATTRIBUTE_PACKED game_analog_stick_event; | ||
| 312 | |||
| 313 | typedef struct game_accelerometer_event | ||
| 314 | { | ||
| 315 | float x; | ||
| 316 | float y; | ||
| 317 | float z; | ||
| 318 | } ATTRIBUTE_PACKED game_accelerometer_event; | ||
| 319 | |||
| 320 | typedef struct game_key_event | ||
| 321 | { | ||
| 322 | bool pressed; | ||
| 323 | XBMCVKey character; | ||
| 324 | GAME_KEY_MOD modifiers; | ||
| 325 | } ATTRIBUTE_PACKED game_key_event; | ||
| 326 | |||
| 327 | typedef struct game_rel_pointer_event | ||
| 328 | { | ||
| 329 | int x; | ||
| 330 | int y; | ||
| 331 | } ATTRIBUTE_PACKED game_rel_pointer_event; | ||
| 332 | |||
| 333 | typedef struct game_abs_pointer_event | ||
| 334 | { | ||
| 335 | bool pressed; | ||
| 336 | float x; | ||
| 337 | float y; | ||
| 338 | } ATTRIBUTE_PACKED game_abs_pointer_event; | ||
| 339 | |||
| 340 | typedef struct game_motor_event | ||
| 341 | { | ||
| 342 | float magnitude; | ||
| 343 | } ATTRIBUTE_PACKED game_motor_event; | ||
| 344 | |||
| 345 | typedef struct game_input_event | ||
| 346 | { | ||
| 347 | GAME_INPUT_EVENT_SOURCE type; | ||
| 348 | int port; | ||
| 349 | const char* controller_id; | ||
| 350 | const char* feature_name; | ||
| 351 | union | ||
| 352 | { | ||
| 353 | struct game_digital_button_event digital_button; | ||
| 354 | struct game_analog_button_event analog_button; | ||
| 355 | struct game_analog_stick_event analog_stick; | ||
| 356 | struct game_accelerometer_event accelerometer; | ||
| 357 | struct game_key_event key; | ||
| 358 | struct game_rel_pointer_event rel_pointer; | ||
| 359 | struct game_abs_pointer_event abs_pointer; | ||
| 360 | struct game_motor_event motor; | ||
| 361 | }; | ||
| 362 | } ATTRIBUTE_PACKED game_input_event; | ||
| 363 | |||
| 364 | struct game_geometry | ||
| 365 | { | ||
| 366 | unsigned base_width; // Nominal video width of game | ||
| 367 | unsigned base_height; // Nominal video height of game | ||
| 368 | unsigned max_width; // Maximum possible width of game | ||
| 369 | unsigned max_height; // Maximum possible height of game | ||
| 370 | float aspect_ratio; // Nominal aspect ratio of game. If aspect_ratio is <= 0.0, | ||
| 371 | // an aspect ratio of base_width / base_height is assumed. | ||
| 372 | // A frontend could override this setting if desired. | ||
| 373 | }; | ||
| 374 | |||
| 375 | struct game_system_timing | ||
| 376 | { | ||
| 377 | double fps; // FPS of video content. | ||
| 378 | double sample_rate; // Sampling rate of audio. | ||
| 379 | }; | ||
| 380 | |||
| 381 | struct game_system_av_info | ||
| 382 | { | ||
| 383 | struct game_geometry geometry; | ||
| 384 | struct game_system_timing timing; | ||
| 385 | }; | ||
| 386 | |||
| 387 | typedef void (*game_proc_address_t)(void); | ||
| 388 | |||
| 389 | struct game_hw_info | ||
| 390 | { | ||
| 391 | GAME_HW_CONTEXT_TYPE context_type; // Which API to use. Set by game client | ||
| 392 | bool depth; // Set if render buffers should have depth component attached | ||
| 393 | bool stencil; // Set if stencil buffers should be attached | ||
| 394 | // If depth and stencil are true, a packed 24/8 buffer will be added. Only attaching stencil is invalid and will be ignored | ||
| 395 | bool bottom_left_origin; // Use conventional bottom-left origin convention. Is false, standard top-left origin semantics are used | ||
| 396 | unsigned version_major; // Major version number for core GL context | ||
| 397 | unsigned version_minor; // Minor version number for core GL context | ||
| 398 | bool cache_context; // If this is true, the frontend will go very far to avoid resetting context in scenarios like toggling fullscreen, etc. | ||
| 399 | // The reset callback might still be called in extreme situations such as if the context is lost beyond recovery | ||
| 400 | // For optimal stability, set this to false, and allow context to be reset at any time | ||
| 401 | bool debug_context; // Creates a debug context | ||
| 402 | }; | ||
| 403 | |||
| 404 | /*! Properties passed to the ADDON_Create() method of a game client */ | ||
| 405 | typedef struct game_client_properties | ||
| 406 | { | ||
| 407 | /*! | ||
| 408 | * The path of the game client being loaded. | ||
| 409 | */ | ||
| 410 | const char* game_client_dll_path; | ||
| 411 | |||
| 412 | /*! | ||
| 413 | * Paths to proxy DLLs used to load the game client. | ||
| 414 | */ | ||
| 415 | const char** proxy_dll_paths; | ||
| 416 | |||
| 417 | /*! | ||
| 418 | * Number of proxy DLL paths provided. | ||
| 419 | */ | ||
| 420 | unsigned int proxy_dll_count; | ||
| 421 | |||
| 422 | /*! | ||
| 423 | * The "system" directories of the frontend. These directories can be used to | ||
| 424 | * store system-specific ROMs such as BIOSes, configuration data, etc. | ||
| 425 | */ | ||
| 426 | const char** resource_directories; | ||
| 427 | |||
| 428 | /*! | ||
| 429 | * Number of resource directories provided | ||
| 430 | */ | ||
| 431 | unsigned int resource_directory_count; | ||
| 432 | |||
| 433 | /*! | ||
| 434 | * The writable directory of the frontend. This directory can be used to store | ||
| 435 | * SRAM, memory cards, high scores, etc, if the game client cannot use the | ||
| 436 | * regular memory interface, GetMemoryData(). | ||
| 437 | */ | ||
| 438 | const char* profile_directory; | ||
| 439 | |||
| 440 | /*! | ||
| 441 | * The value of the <supports_vfs> property from addon.xml | ||
| 442 | */ | ||
| 443 | bool supports_vfs; | ||
| 444 | |||
| 445 | /*! | ||
| 446 | * The extensions in the <extensions> property from addon.xml | ||
| 447 | */ | ||
| 448 | const char** extensions; | ||
| 449 | |||
| 450 | /*! | ||
| 451 | * Number of extensions provided | ||
| 452 | */ | ||
| 453 | unsigned int extension_count; | ||
| 454 | } game_client_properties; | ||
| 455 | |||
| 456 | /*! Structure to transfer the methods from kodi_game_dll.h to Kodi */ | ||
| 457 | typedef struct GameClient | ||
| 458 | { | ||
| 459 | const char* (__cdecl* GetGameAPIVersion)(void); | ||
| 460 | const char* (__cdecl* GetMininumGameAPIVersion)(void); | ||
| 461 | GAME_ERROR (__cdecl* LoadGame)(const char*); | ||
| 462 | GAME_ERROR (__cdecl* LoadGameSpecial)(SPECIAL_GAME_TYPE, const char**, size_t); | ||
| 463 | GAME_ERROR (__cdecl* LoadStandalone)(void); | ||
| 464 | GAME_ERROR (__cdecl* UnloadGame)(void); | ||
| 465 | GAME_ERROR (__cdecl* GetGameInfo)(game_system_av_info*); | ||
| 466 | GAME_REGION (__cdecl* GetRegion)(void); | ||
| 467 | bool (__cdecl* RequiresGameLoop)(void); | ||
| 468 | GAME_ERROR (__cdecl* RunFrame)(void); | ||
| 469 | GAME_ERROR (__cdecl* Reset)(void); | ||
| 470 | GAME_ERROR (__cdecl* HwContextReset)(void); | ||
| 471 | GAME_ERROR (__cdecl* HwContextDestroy)(void); | ||
| 472 | void (__cdecl* UpdatePort)(int, bool, const game_controller*); | ||
| 473 | bool (__cdecl* HasFeature)(const char* controller_id, const char* feature_name); | ||
| 474 | bool (__cdecl* InputEvent)(const game_input_event*); | ||
| 475 | size_t (__cdecl* SerializeSize)(void); | ||
| 476 | GAME_ERROR (__cdecl* Serialize)(uint8_t*, size_t); | ||
| 477 | GAME_ERROR (__cdecl* Deserialize)(const uint8_t*, size_t); | ||
| 478 | GAME_ERROR (__cdecl* CheatReset)(void); | ||
| 479 | GAME_ERROR (__cdecl* GetMemory)(GAME_MEMORY, const uint8_t**, size_t*); | ||
| 480 | GAME_ERROR (__cdecl* SetCheat)(unsigned int, bool, const char*); | ||
| 481 | } GameClient; | ||
| 482 | |||
| 483 | #ifdef __cplusplus | ||
| 484 | } | ||
| 485 | #endif | ||
| 486 | |||
| 487 | #endif // KODI_GAME_TYPES_H_ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_game.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_game.h deleted file mode 100644 index b5a46dd..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_game.h +++ /dev/null | |||
| @@ -1,238 +0,0 @@ | |||
| 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 | #pragma once | ||
| 21 | |||
| 22 | #include "libXBMC_addon.h" | ||
| 23 | #include "kodi_game_callbacks.h" | ||
| 24 | |||
| 25 | #include <string> | ||
| 26 | #include <stdio.h> | ||
| 27 | |||
| 28 | #if defined(ANDROID) | ||
| 29 | #include <sys/stat.h> | ||
| 30 | #endif | ||
| 31 | |||
| 32 | #ifdef _WIN32 | ||
| 33 | #define GAME_HELPER_DLL "\\library.kodi.game\\libKODI_game" ADDON_HELPER_EXT | ||
| 34 | #else | ||
| 35 | #define GAME_HELPER_DLL_NAME "libKODI_game-" ADDON_HELPER_ARCH ADDON_HELPER_EXT | ||
| 36 | #define GAME_HELPER_DLL "/library.kodi.game/" GAME_HELPER_DLL_NAME | ||
| 37 | #endif | ||
| 38 | |||
| 39 | #define GAME_REGISTER_SYMBOL(dll, functionPtr) \ | ||
| 40 | CHelper_libKODI_game::RegisterSymbol(dll, functionPtr, #functionPtr) | ||
| 41 | |||
| 42 | class CHelper_libKODI_game | ||
| 43 | { | ||
| 44 | public: | ||
| 45 | CHelper_libKODI_game(void) : | ||
| 46 | GAME_register_me(nullptr), | ||
| 47 | GAME_unregister_me(nullptr), | ||
| 48 | GAME_close_game(nullptr), | ||
| 49 | GAME_open_pixel_stream(nullptr), | ||
| 50 | GAME_open_video_stream(nullptr), | ||
| 51 | GAME_open_pcm_stream(nullptr), | ||
| 52 | GAME_open_audio_stream(nullptr), | ||
| 53 | GAME_add_stream_data(nullptr), | ||
| 54 | GAME_close_stream(nullptr), | ||
| 55 | GAME_enable_hardware_rendering(nullptr), | ||
| 56 | GAME_hw_get_current_framebuffer(nullptr), | ||
| 57 | GAME_hw_get_proc_address(nullptr), | ||
| 58 | GAME_render_frame(nullptr), | ||
| 59 | GAME_open_port(nullptr), | ||
| 60 | GAME_close_port(nullptr), | ||
| 61 | GAME_input_event(nullptr), | ||
| 62 | m_handle(nullptr), | ||
| 63 | m_callbacks(nullptr), | ||
| 64 | m_libKODI_game(nullptr) | ||
| 65 | { | ||
| 66 | } | ||
| 67 | |||
| 68 | ~CHelper_libKODI_game(void) | ||
| 69 | { | ||
| 70 | if (m_libKODI_game) | ||
| 71 | { | ||
| 72 | GAME_unregister_me(m_handle, m_callbacks); | ||
| 73 | dlclose(m_libKODI_game); | ||
| 74 | } | ||
| 75 | } | ||
| 76 | |||
| 77 | template <typename T> | ||
| 78 | static bool RegisterSymbol(void* dll, T& functionPtr, const char* strFunctionPtr) | ||
| 79 | { | ||
| 80 | return (functionPtr = (T)dlsym(dll, strFunctionPtr)) != NULL; | ||
| 81 | } | ||
| 82 | |||
| 83 | /*! | ||
| 84 | * @brief Resolve all callback methods | ||
| 85 | * @param handle Pointer to the add-on | ||
| 86 | * @return True when all methods were resolved, false otherwise. | ||
| 87 | */ | ||
| 88 | bool RegisterMe(void* handle) | ||
| 89 | { | ||
| 90 | m_handle = handle; | ||
| 91 | |||
| 92 | std::string libBasePath; | ||
| 93 | libBasePath = ((cb_array*)m_handle)->libBasePath; | ||
| 94 | libBasePath += GAME_HELPER_DLL; | ||
| 95 | |||
| 96 | #if defined(ANDROID) | ||
| 97 | struct stat st; | ||
| 98 | if (stat(libBasePath.c_str(),&st) != 0) | ||
| 99 | { | ||
| 100 | std::string tempbin = getenv("XBMC_ANDROID_LIBS"); | ||
| 101 | libBasePath = tempbin + "/" + GAME_HELPER_DLL_NAME; | ||
| 102 | } | ||
| 103 | #endif | ||
| 104 | |||
| 105 | m_libKODI_game = dlopen(libBasePath.c_str(), RTLD_LAZY); | ||
| 106 | if (m_libKODI_game == NULL) | ||
| 107 | { | ||
| 108 | fprintf(stderr, "Unable to load %s\n", dlerror()); | ||
| 109 | return false; | ||
| 110 | } | ||
| 111 | |||
| 112 | try | ||
| 113 | { | ||
| 114 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_register_me)) throw false; | ||
| 115 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_unregister_me)) throw false; | ||
| 116 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_close_game)) throw false; | ||
| 117 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_open_pixel_stream)) throw false; | ||
| 118 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_open_video_stream)) throw false; | ||
| 119 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_open_pcm_stream)) throw false; | ||
| 120 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_open_audio_stream)) throw false; | ||
| 121 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_add_stream_data)) throw false; | ||
| 122 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_close_stream)) throw false; | ||
| 123 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_enable_hardware_rendering)) throw false; | ||
| 124 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_hw_get_current_framebuffer)) throw false; | ||
| 125 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_hw_get_proc_address)) throw false; | ||
| 126 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_render_frame)) throw false; | ||
| 127 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_open_port)) throw false; | ||
| 128 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_close_port)) throw false; | ||
| 129 | if (!GAME_REGISTER_SYMBOL(m_libKODI_game, GAME_input_event)) throw false; | ||
| 130 | } | ||
| 131 | catch (const bool& bSuccess) | ||
| 132 | { | ||
| 133 | fprintf(stderr, "ERROR: Unable to assign function %s\n", dlerror()); | ||
| 134 | return bSuccess; | ||
| 135 | } | ||
| 136 | |||
| 137 | m_callbacks = GAME_register_me(m_handle); | ||
| 138 | return m_callbacks != NULL; | ||
| 139 | } | ||
| 140 | |||
| 141 | void CloseGame(void) | ||
| 142 | { | ||
| 143 | return GAME_close_game(m_handle, m_callbacks); | ||
| 144 | } | ||
| 145 | |||
| 146 | bool OpenPixelStream(GAME_PIXEL_FORMAT format, unsigned int width, unsigned int height, GAME_VIDEO_ROTATION rotation) | ||
| 147 | { | ||
| 148 | return GAME_open_pixel_stream(m_handle, m_callbacks, format, width, height, rotation) == 0; | ||
| 149 | } | ||
| 150 | |||
| 151 | bool OpenVideoStream(GAME_VIDEO_CODEC codec) | ||
| 152 | { | ||
| 153 | return GAME_open_video_stream(m_handle, m_callbacks, codec) == 0; | ||
| 154 | } | ||
| 155 | |||
| 156 | bool OpenPCMStream(GAME_PCM_FORMAT format, const GAME_AUDIO_CHANNEL* channel_map) | ||
| 157 | { | ||
| 158 | return GAME_open_pcm_stream(m_handle, m_callbacks, format, channel_map) == 0; | ||
| 159 | } | ||
| 160 | |||
| 161 | bool OpenAudioStream(GAME_AUDIO_CODEC codec, const GAME_AUDIO_CHANNEL* channel_map) | ||
| 162 | { | ||
| 163 | return GAME_open_audio_stream(m_handle, m_callbacks, codec, channel_map) == 0; | ||
| 164 | } | ||
| 165 | |||
| 166 | void AddStreamData(GAME_STREAM_TYPE stream, const uint8_t* data, unsigned int size) | ||
| 167 | { | ||
| 168 | GAME_add_stream_data(m_handle, m_callbacks, stream, data, size); | ||
| 169 | } | ||
| 170 | |||
| 171 | void CloseStream(GAME_STREAM_TYPE stream) | ||
| 172 | { | ||
| 173 | GAME_close_stream(m_handle, m_callbacks, stream); | ||
| 174 | } | ||
| 175 | |||
| 176 | void EnableHardwareRendering(const struct game_hw_info* hw_info) | ||
| 177 | { | ||
| 178 | return GAME_enable_hardware_rendering(m_handle, m_callbacks, hw_info); | ||
| 179 | } | ||
| 180 | |||
| 181 | uintptr_t HwGetCurrentFramebuffer(void) | ||
| 182 | { | ||
| 183 | return GAME_hw_get_current_framebuffer(m_handle, m_callbacks); | ||
| 184 | } | ||
| 185 | |||
| 186 | game_proc_address_t HwGetProcAddress(const char* sym) | ||
| 187 | { | ||
| 188 | return GAME_hw_get_proc_address(m_handle, m_callbacks, sym); | ||
| 189 | } | ||
| 190 | |||
| 191 | void RenderFrame() | ||
| 192 | { | ||
| 193 | return GAME_render_frame(m_handle, m_callbacks); | ||
| 194 | } | ||
| 195 | |||
| 196 | bool OpenPort(unsigned int port) | ||
| 197 | { | ||
| 198 | return GAME_open_port(m_handle, m_callbacks, port); | ||
| 199 | } | ||
| 200 | |||
| 201 | void ClosePort(unsigned int port) | ||
| 202 | { | ||
| 203 | return GAME_close_port(m_handle, m_callbacks, port); | ||
| 204 | } | ||
| 205 | |||
| 206 | bool InputEvent(const game_input_event& event) | ||
| 207 | { | ||
| 208 | return GAME_input_event(m_handle, m_callbacks, &event); | ||
| 209 | } | ||
| 210 | |||
| 211 | protected: | ||
| 212 | CB_GameLib* (*GAME_register_me)(void* handle); | ||
| 213 | void (*GAME_unregister_me)(void* handle, CB_GameLib* cb); | ||
| 214 | void (*GAME_close_game)(void* handle, CB_GameLib* cb); | ||
| 215 | int (*GAME_open_pixel_stream)(void* handle, CB_GameLib* cb, GAME_PIXEL_FORMAT, unsigned int, unsigned int, GAME_VIDEO_ROTATION); | ||
| 216 | int (*GAME_open_video_stream)(void* handle, CB_GameLib* cb, GAME_VIDEO_CODEC); | ||
| 217 | int (*GAME_open_pcm_stream)(void* handle, CB_GameLib* cb, GAME_PCM_FORMAT, const GAME_AUDIO_CHANNEL*); | ||
| 218 | int (*GAME_open_audio_stream)(void* handle, CB_GameLib* cb, GAME_AUDIO_CODEC, const GAME_AUDIO_CHANNEL*); | ||
| 219 | int (*GAME_add_stream_data)(void* handle, CB_GameLib* cb, GAME_STREAM_TYPE, const uint8_t*, unsigned int); | ||
| 220 | int (*GAME_close_stream)(void* handle, CB_GameLib* cb, GAME_STREAM_TYPE); | ||
| 221 | void (*GAME_enable_hardware_rendering)(void* handle, CB_GameLib* cb, const struct game_hw_info*); | ||
| 222 | uintptr_t (*GAME_hw_get_current_framebuffer)(void* handle, CB_GameLib* cb); | ||
| 223 | game_proc_address_t (*GAME_hw_get_proc_address)(void* handle, CB_GameLib* cb, const char*); | ||
| 224 | void (*GAME_render_frame)(void* handle, CB_GameLib* cb); | ||
| 225 | bool (*GAME_open_port)(void* handle, CB_GameLib* cb, unsigned int); | ||
| 226 | void (*GAME_close_port)(void* handle, CB_GameLib* cb, unsigned int); | ||
| 227 | bool (*GAME_input_event)(void* handle, CB_GameLib* cb, const game_input_event* event); | ||
| 228 | |||
| 229 | private: | ||
| 230 | void* m_handle; | ||
| 231 | CB_GameLib* m_callbacks; | ||
| 232 | void* m_libKODI_game; | ||
| 233 | |||
| 234 | struct cb_array | ||
| 235 | { | ||
| 236 | const char* libBasePath; | ||
| 237 | }; | ||
| 238 | }; | ||
