Kodi Documentation 23.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches

Game operations More...

Topics

 Class: CStream
 

Class: kodi::addon::CInstanceGame::CStream

Game stream handler
 

Classes

class  kodi::addon::CInstanceGame::CStream
 

Functions

virtual GAME_ERROR kodi::addon::CInstanceGame::LoadGame (const std::string &url)
 Load a game.
 
virtual GAME_ERROR kodi::addon::CInstanceGame::LoadGameSpecial (SPECIAL_GAME_TYPE type, const std::vector< std::string > &urls)
 Load a game that requires multiple files.
 
virtual GAME_ERROR kodi::addon::CInstanceGame::LoadStandalone ()
 Begin playing without a game file.
 
virtual GAME_ERROR kodi::addon::CInstanceGame::UnloadGame ()
 Unload the current game.
 
virtual GAME_ERROR kodi::addon::CInstanceGame::GetGameTiming (game_system_timing &timing_info)
 Get timing information about the loaded game.
 
virtual GAME_REGION kodi::addon::CInstanceGame::GetRegion ()
 Get region of the loaded game.
 
virtual bool kodi::addon::CInstanceGame::RequiresGameLoop ()
 Return true if the client requires the frontend to provide a game loop.
 
virtual GAME_ERROR kodi::addon::CInstanceGame::RunFrame ()
 Run a single frame for add-ons that use a game loop.
 
virtual GAME_ERROR kodi::addon::CInstanceGame::RunFrameSpeculative ()
 Run a frame that the frontend will roll back afterwards.
 
virtual GAME_ERROR kodi::addon::CInstanceGame::Reset ()
 Reset the current game.
 
void kodi::addon::CInstanceGame::CloseGame (void)
 Callback to Kodi Function
Requests the frontend to stop the current game
 
void kodi::addon::CInstanceGame::ReportMissingFile (const std::string &path)
 Callback to Kodi Function
Name a file the game client looked for and couldn't find, such as a BIOS file, so Kodi can tell the user which one is missing.
 
double kodi::addon::CInstanceGame::GetPlaybackSpeed ()
 Callback to Kodi Function
Get the speed the game is being played back at
 
void kodi::addon::CInstanceGame::SetGameTiming (const game_system_timing &timingInfo)
 Callback to Kodi Function
Update the video and audio timing of the running game
 
void kodi::addon::CInstanceGame::SetFastForwarding (bool fastForward, double ratio)
 Callback to Kodi Function
Ask Kodi to fast-forward the game, or to stop a fast-forward it asked for
 

Detailed Description

Game operations

These are mandatory functions for using this add-on for gameplay functionality.


Game operation parts in interface:
Copy this to your project and extend with your parts or leave functions complete away where not used or supported.

Function Documentation

◆ CloseGame()

void kodi::addon::CInstanceGame::CloseGame ( void )
inline

Callback to Kodi Function
Requests the frontend to stop the current game

Remarks
Only called from the add-on itself

◆ GetGameTiming()

virtual GAME_ERROR kodi::addon::CInstanceGame::GetGameTiming ( game_system_timing & timing_info)
inlinevirtual

Get timing information about the loaded game.

Parameters
[out]timing_infoThe info structure to fill
Returns
The error, or GAME_ERROR_NO_ERROR if info was filled

◆ GetPlaybackSpeed()

double kodi::addon::CInstanceGame::GetPlaybackSpeed ( )
inline

Callback to Kodi Function
Get the speed the game is being played back at

Returns
The speed as a multiple of normal speed

The value is the same one Kodi shows the user, so it follows the player's fast-forward and rewind semantics:

  • 1.0 is normal speed
  • 0.0 is paused
  • greater than 1.0 is fast-forward
  • between 0.0 and 1.0 is slow motion
  • less than 0.0 is rewind

Rewind is driven by Kodi replaying saved states, so a client is run forwards even while the speed is negative. A client that changes its behaviour with the speed should read the sign as "the user is going backwards", not as a direction to run in.

Remarks
Only called from the add-on itself

◆ GetRegion()

virtual GAME_REGION kodi::addon::CInstanceGame::GetRegion ( )
inlinevirtual

Get region of the loaded game.

Returns
The region, or GAME_REGION_UNKNOWN if unknown or no game is loaded

◆ LoadGame()

virtual GAME_ERROR kodi::addon::CInstanceGame::LoadGame ( const std::string & url)
inlinevirtual

Load a game.

Parameters
[in]urlThe URL to load
Returns
The error, or GAME_ERROR_NO_ERROR if the game was loaded

◆ LoadGameSpecial()

virtual GAME_ERROR kodi::addon::CInstanceGame::LoadGameSpecial ( SPECIAL_GAME_TYPE type,
const std::vector< std::string > & urls )
inlinevirtual

Load a game that requires multiple files.

Parameters
[in]typeThe game type
[in]urlsAn array of urls
Returns
The error, or GAME_ERROR_NO_ERROR if the game was loaded

◆ LoadStandalone()

virtual GAME_ERROR kodi::addon::CInstanceGame::LoadStandalone ( )
inlinevirtual

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>
Returns
The error, or GAME_ERROR_NO_ERROR if the game add-on was loaded

◆ ReportMissingFile()

void kodi::addon::CInstanceGame::ReportMissingFile ( const std::string & path)
inline

Callback to Kodi Function
Name a file the game client looked for and couldn't find, such as a BIOS file, so Kodi can tell the user which one is missing.

Parameters
[in]pathThe file's path, relative to the system directory
Remarks
Call it before returning GAME_ERROR_MISSING_FILES. It does nothing with a Kodi older than game API 8.3.0.

◆ RequiresGameLoop()

virtual bool kodi::addon::CInstanceGame::RequiresGameLoop ( )
inlinevirtual

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.

Returns
True if the frontend should provide a game loop, false otherwise

◆ Reset()

virtual GAME_ERROR kodi::addon::CInstanceGame::Reset ( )
inlinevirtual

Reset the current game.

Returns
The error, or GAME_ERROR_NO_ERROR if the game was reset

◆ RunFrame()

virtual GAME_ERROR kodi::addon::CInstanceGame::RunFrame ( )
inlinevirtual

Run a single frame for add-ons that use a game loop.

Returns
The error, or GAME_ERROR_NO_ERROR if there was no error

◆ RunFrameSpeculative()

virtual GAME_ERROR kodi::addon::CInstanceGame::RunFrameSpeculative ( )
inlinevirtual

Run a frame that the frontend will roll back afterwards.

Used for run-ahead. The emulator advances exactly as in RunFrame(), but anything that must only happen once per real frame, such as evaluating achievements, is skipped, because the frontend restores the emulator's state afterwards.

Returns
The error, or GAME_ERROR_NOT_IMPLEMENTED if the add-on can't run a frame without side effects

◆ SetFastForwarding()

void kodi::addon::CInstanceGame::SetFastForwarding ( bool fastForward,
double ratio )
inline

Callback to Kodi Function
Ask Kodi to fast-forward the game, or to stop a fast-forward it asked for

Parameters
[in]fastForwardTrue to fast-forward, false to return to normal speed
[in]ratioThe speed asked for if above 1, otherwise Kodi chooses

For a game that wants to pass over a wait of its own, such as loading from tape. Kodi leaves a speed the user chose alone: it only fast-forwards from normal speed, and only returns to normal speed from the one it set.

Remarks
Only called from the add-on itself. It does nothing with a Kodi older than game API 8.4.0.

◆ SetGameTiming()

void kodi::addon::CInstanceGame::SetGameTiming ( const game_system_timing & timingInfo)
inline

Callback to Kodi Function
Update the video and audio timing of the running game

Parameters
[in]timingInfoThe new video frame rate and audio sample rate

This updates timing reported by the add-on after gameplay has started. Add-ons should call this when the game changes its timing dynamically.

Remarks
Only called from the add-on itself

◆ UnloadGame()

virtual GAME_ERROR kodi::addon::CInstanceGame::UnloadGame ( )
inlinevirtual

Unload the current game.

Unloads a currently loaded game

Returns
The error, or GAME_ERROR_NO_ERROR if the game was unloaded