![]() |
Kodi Documentation 18.0
Kodi is an open source media player and entertainment hub.
|
#include "kodi_game_types.h"
Functions | |
GAME_ERROR | LoadGame (const char *url) |
Load a game. More... | |
GAME_ERROR | LoadGameSpecial (SPECIAL_GAME_TYPE type, const char **urls, size_t urlCount) |
Load a game that requires multiple files. More... | |
GAME_ERROR | LoadStandalone (void) |
Begin playing without a game file. More... | |
GAME_ERROR | UnloadGame (void) |
Unload the current game. More... | |
GAME_ERROR | GetGameTiming (game_system_timing *timing_info) |
Get timing information about the loaded game. More... | |
GAME_REGION | GetRegion (void) |
Get region of the loaded game. More... | |
bool | RequiresGameLoop (void) |
Return true if the client requires the frontend to provide a game loop. More... | |
GAME_ERROR | RunFrame (void) |
Run a single frame for add-ons that use a game loop. More... | |
GAME_ERROR | Reset (void) |
Reset the current game. More... | |
GAME_ERROR | HwContextReset (void) |
Invalidates the current HW context and reinitializes GPU resources. More... | |
GAME_ERROR | HwContextDestroy (void) |
Called before the context is destroyed. More... | |
bool | HasFeature (const char *controller_id, const char *feature_name) |
Check if input is accepted for a feature on the controller. More... | |
game_input_topology * | GetTopology () |
Get the input topology that specifies which controllers can be connected. More... | |
void | FreeTopology (game_input_topology *topology) |
Free the topology's resources. More... | |
void | SetControllerLayouts (const game_controller_layout *controllers, unsigned int controller_count) |
Set the layouts for known controllers. More... | |
bool | EnableKeyboard (bool enable, const char *controller_id) |
Enable/disable keyboard input using the specified controller. More... | |
bool | EnableMouse (bool enable, const char *controller_id) |
Enable/disable mouse input using the specified controller. More... | |
bool | ConnectController (bool connect, const char *port_address, const char *controller_id) |
Connect/disconnect a controller to a port on the virtual game console. More... | |
bool | InputEvent (const game_input_event *event) |
Notify the add-on of an input event. More... | |
size_t | SerializeSize (void) |
Get the number of bytes required to serialize the game. More... | |
GAME_ERROR | Serialize (uint8_t *data, size_t size) |
Serialize the state of the game. More... | |
GAME_ERROR | Deserialize (const uint8_t *data, size_t size) |
Deserialize the game from the given state. More... | |
GAME_ERROR | CheatReset (void) |
Reset the cheat system. More... | |
GAME_ERROR | GetMemory (GAME_MEMORY type, uint8_t **data, size_t *size) |
Get a region of memory. More... | |
GAME_ERROR | SetCheat (unsigned int index, bool enabled, const char *code) |
Set a cheat code. More... | |
void | __declspec (dllexport) get_addon(void *ptr) |
Called by Kodi to assign the function pointers of this add-on to pClient. More... | |
__declspec | ( | dllexport | ) |
Called by Kodi to assign the function pointers of this add-on to pClient.
Note that get_addon() is defined here, so it will be available in all compiled game clients.
GAME_ERROR CheatReset | ( | void | ) |
Reset the cheat system.
bool ConnectController | ( | bool | connect, |
const char * | port_address, | ||
const char * | controller_id | ||
) |
Connect/disconnect a controller to a port on the virtual game console.
connect | True to connect a controller, false to disconnect |
port_address | The address of the port |
controller_id | The controller ID if connecting, or unused if disconnecting |
controller
was (dis-)connected to the port, false otherwiseThe address is a string that allows traversal of the controller topology. It is formed by alternating port IDs and controller IDs separated by "/".
For example, assume that the topology represented in XML for Snes9x is:
<logicaltopology> <port type="controller" id="1"> <accepts controller="game.controller.snes"/> <accepts controller="game.controller.snes.multitap"> <port type="controller" id="1"> <accepts controller="game.controller.snes"/> </port> <port type="controller" id="2"> <accepts controller="game.controller.snes"/> </port> ... </accepts> </port> </logicaltopology>
To connect a multitap to the console's first port, the multitap's controller info is set using the port address:
/1
To connect a SNES controller to the second port of the multitap, the controller info is next set using the address:
/1/game.controller.multitap/2
Any attempts to connect a controller to a port on a disconnected multitap will return false.
GAME_ERROR Deserialize | ( | const uint8_t * | data, |
size_t | size | ||
) |
Deserialize the game from the given state.
data | A buffer containing the game's new state |
size | The size of the buffer |
bool EnableKeyboard | ( | bool | enable, |
const char * | controller_id | ||
) |
Enable/disable keyboard input using the specified controller.
enable | True to enable input, false otherwise |
controller_id | The controller ID if enabling, or unused if disabling |
bool EnableMouse | ( | bool | enable, |
const char * | controller_id | ||
) |
Enable/disable mouse input using the specified controller.
enable | True to enable input, false otherwise |
controller_id | The controller ID if enabling, or unused if disabling |
void FreeTopology | ( | game_input_topology * | topology | ) |
Free the topology's resources.
topology | The topology returned by GetTopology() |
GAME_ERROR GetGameTiming | ( | game_system_timing * | timing_info | ) |
Get timing information about the loaded game.
[out] | timing_info | The info structure to fill |
GAME_ERROR GetMemory | ( | GAME_MEMORY | type, |
uint8_t ** | data, | ||
size_t * | size | ||
) |
Get a region of memory.
type | The type of memory to retrieve |
data | Set to the region of memory; must remain valid until UnloadGame() is called |
size | Set to the size of the region of memory |
GAME_REGION GetRegion | ( | void | ) |
Get region of the loaded game.
game_input_topology * GetTopology | ( | ) |
Get the input topology that specifies which controllers can be connected.
If this returns non-null, topology must be freed using FreeTopology().
If this returns null, the topology will default to a single port that can accept all controllers imported by addon.xml. The port ID is set to the DEFAULT_PORT_ID constant.
bool HasFeature | ( | const char * | controller_id, |
const char * | feature_name | ||
) |
Check if input is accepted for a feature on the controller.
If only a subset of the controller profile is used, this can return false for unsupported features to not absorb their input.
If the entire controller profile is used, this should always return true.
controller_id | The ID of the controller profile |
feature_name | The name of a feature in that profile |
GAME_ERROR HwContextDestroy | ( | void | ) |
Called before the context is destroyed.
Resources can be deinitialized at this step.
GAME_ERROR HwContextReset | ( | void | ) |
Invalidates the current HW context and reinitializes GPU resources.
Any GL state is lost, and must not be deinitialized explicitly.
bool InputEvent | ( | const game_input_event * | event | ) |
Notify the add-on of an input event.
event | The input event |
GAME_ERROR LoadGame | ( | const char * | url | ) |
Load a game.
url | The URL to load |
return the error, or GAME_ERROR_NO_ERROR if the game was loaded
GAME_ERROR LoadGameSpecial | ( | SPECIAL_GAME_TYPE | type, |
const char ** | urls, | ||
size_t | urlCount | ||
) |
Load a game that requires multiple files.
type | The game type |
urls | An array of urls |
urlCount | The number of urls in the array |
GAME_ERROR LoadStandalone | ( | void | ) |
Begin playing without a game file.
If the add-on supports standalone mode, it must add the <supports_standalone> tag to the extension point in addon.xml:
<supports_no_game>false</supports_no_game>
bool RequiresGameLoop | ( | void | ) |
Return true if the client requires the frontend to provide a game loop.
The game loop is a thread that calls RunFrame() in a loop at a rate determined by the playback speed and the client's FPS.
GAME_ERROR Reset | ( | void | ) |
Reset the current game.
GAME_ERROR RunFrame | ( | void | ) |
Run a single frame for add-ons that use a game loop.
GAME_ERROR Serialize | ( | uint8_t * | data, |
size_t | size | ||
) |
Serialize the state of the game.
data | The buffer receiving the serialized game data |
size | The size of the buffer |
size_t SerializeSize | ( | void | ) |
Get the number of bytes required to serialize the game.
GAME_ERROR SetCheat | ( | unsigned int | index, |
bool | enabled, | ||
const char * | code | ||
) |
Set a cheat code.
index | |
enabled | |
code |
void SetControllerLayouts | ( | const game_controller_layout * | controllers, |
unsigned int | controller_count | ||
) |
Set the layouts for known controllers.
controllers | The controller layouts |
controller_count | The number of items in the array |
After loading the input topology, the frontend will call this with controller layouts for all controllers discovered in the topology.
GAME_ERROR UnloadGame | ( | void | ) |
Unload the current game.
Unloads a currently loaded game