RetroCore

RetroCore — An object handling a Libretro core

Functions

Properties

guint api-version Read
gchar * content-directory Read / Write
gchar * filename Read / Write / Construct Only
gdouble frames-per-second Read
gboolean game-loaded Read
gboolean is-initiated Read
guint runahead Read / Write
gchar * save-directory Read / Write
gdouble speed-rate Read / Write
gboolean support-no-game Read
gchar * system-directory Read / Write

Signals

void crashed Run Last
void log Run Last
void message Run Last
void shutdown Run Last
void video-output Run Last

Types and Values

Object Hierarchy

    GObject
    ╰── RetroCore

Includes

#include <retro-gtk/retro-gtk.h>

Description

Functions

retro_core_new ()

RetroCore *
retro_core_new (const gchar *filename);

Creates a new RetroCore.

Parameters

filename

the filename of a Libretro core

 

Returns

a new RetroCore.

[transfer full]


retro_core_get_api_version ()

guint
retro_core_get_api_version (RetroCore *self);

Gets the Libretro API version implement by the core.

Parameters

self

a RetroCore

 

Returns

the API version


retro_core_get_filename ()

const gchar *
retro_core_get_filename (RetroCore *self);

Gets the filename of the core.

Parameters

self

a RetroCore

 

Returns

the filename of the core.

[transfer none]


retro_core_get_system_directory ()

const gchar *
retro_core_get_system_directory (RetroCore *self);

Gets the system directory of the core.

The core will look here for additional data, such as firmware ROMs or configuration files.

Parameters

self

a RetroCore

 

Returns

the system directory of the core


retro_core_set_system_directory ()

void
retro_core_set_system_directory (RetroCore *self,
                                 const gchar *system_directory);

Sets the system directory of the core.

The core will look here for additional data, such as firmware ROMs or configuration files.

Parameters

self

a RetroCore

 

system_directory

the system directory

 

retro_core_get_content_directory ()

const gchar *
retro_core_get_content_directory (RetroCore *self);

retro_core_set_content_directory ()

void
retro_core_set_content_directory (RetroCore *self,
                                  const gchar *content_directory);

retro_core_get_save_directory ()

const gchar *
retro_core_get_save_directory (RetroCore *self);

Gets the save directory of the core.

The core will save some data here.

Parameters

self

a RetroCore

 

Returns

the save directory of the core


retro_core_set_save_directory ()

void
retro_core_set_save_directory (RetroCore *self,
                               const gchar *save_directory);

Sets the save directory of the core.

The core will save some data here.

Parameters

self

a RetroCore

 

save_directory

the save directory

 

retro_core_get_is_initiated ()

gboolean
retro_core_get_is_initiated (RetroCore *self);

Gets whether the core has been initiated.

Parameters

self

a RetroCore

 

Returns

whether the core has been initiated


retro_core_get_game_loaded ()

gboolean
retro_core_get_game_loaded (RetroCore *self);

Gets whether a game has been loaded.

Parameters

self

a RetroCore

 

Returns

whether a game has been loaded


retro_core_get_support_no_game ()

gboolean
retro_core_get_support_no_game (RetroCore *self);

Gets whether the core supports running with no game.

Parameters

self

a RetroCore

 

Returns

whether the core supports running with no game


retro_core_get_frames_per_second ()

gdouble
retro_core_get_frames_per_second (RetroCore *self);

Gets the FPS rate for the core's video output.

Parameters

self

a RetroCore

 

Returns

the FPS rate for the core's video output


retro_core_boot ()

void
retro_core_boot (RetroCore *self,
                 GError **error);

This initializes self , loads its available options and loads the medias. You need to boot self before using some of its methods.

Parameters

self

a RetroCore

 

error

return location for a GError, or NULL

 

retro_core_set_medias ()

void
retro_core_set_medias (RetroCore *self,
                       const gchar * const *uris);

Sets the medias to load into the core.

You can use this before booting the core.

Parameters

self

a RetroCore

 

uris

(array zero-terminated=1) (element-type utf8) (transfer none): the URIs

 

retro_core_set_current_media ()

void
retro_core_set_current_media (RetroCore *self,
                              guint media_index,
                              GError **error);

Sets the current media index.

You can use this after booting the core.

Parameters

self

a RetroCore

 

media_index

the media index

 

error

return location for a GError, or NULL

 

retro_core_run ()

void
retro_core_run (RetroCore *self);

Starts running the core. If the core was stopped, it will restart from this moment.

Parameters

self

a RetroCore

 

retro_core_stop ()

void
retro_core_stop (RetroCore *self);

Stops running the core.

Parameters

self

a RetroCore

 

retro_core_reset ()

void
retro_core_reset (RetroCore *self);

Resets self .

Parameters

self

a RetroCore

 

retro_core_iteration ()

void
retro_core_iteration (RetroCore *self);

Iterate self for a frame.

Parameters

self

a RetroCore

 

retro_core_get_can_access_state ()

gboolean
retro_core_get_can_access_state (RetroCore *self);

Gets whether the state of self can be accessed.

Parameters

self

a RetroCore

 

Returns

whether the state of self can be accessed


retro_core_save_state ()

void
retro_core_save_state (RetroCore *self,
                       const gchar *filename,
                       GError **error);

Saves the state of self .

Parameters

self

a RetroCore

 

filename

the file to save the state to

 

error

return location for a GError, or NULL

 

retro_core_load_state ()

void
retro_core_load_state (RetroCore *self,
                       const gchar *filename,
                       GError **error);

Loads the state of the self .

Parameters

self

a RetroCore

 

filename

the file to load the state from

 

error

return location for a GError, or NULL

 

retro_core_get_memory_size ()

gsize
retro_core_get_memory_size (RetroCore *self,
                            RetroMemoryType memory_type);

Gets the size of a memory region of self .

Parameters

self

a RetroCore

 

memory_type

the type of memory

 

Returns

the size of a memory region


retro_core_save_memory ()

void
retro_core_save_memory (RetroCore *self,
                        RetroMemoryType memory_type,
                        const gchar *filename,
                        GError **error);

Saves a memory region of self .

Parameters

self

a RetroCore

 

memory_type

the type of memory

 

filename

a file to save the data to

 

error

return location for a GError, or NULL

 

retro_core_load_memory ()

void
retro_core_load_memory (RetroCore *self,
                        RetroMemoryType memory_type,
                        const gchar *filename,
                        GError **error);

Loads a memory region of self .

Parameters

self

a RetroCore

 

memory_type

the type of memory

 

filename

a file to load the data from

 

error

return location for a GError, or NULL

 

retro_core_set_default_controller ()

void
retro_core_set_default_controller (RetroCore *self,
                                   RetroControllerType controller_type,
                                   RetroController *controller);

Uses controller as the default controller for the given type. When a port has no controller plugged plugged into it, the core will use the default controllers instead.

Parameters

self

a RetroCore

 

controller_type

a RetroControllerType

 

controller

a RetroController.

[nullable]

retro_core_set_controller ()

void
retro_core_set_controller (RetroCore *self,
                           guint port,
                           RetroController *controller);

Plugs controller into the specified port number of self .

Parameters

self

a RetroCore

 

port

the port number

 

controller

a RetroController.

[nullable]

retro_core_set_keyboard ()

void
retro_core_set_keyboard (RetroCore *self,
                         GtkWidget *widget);

Sets the widget whose key events will be forwarded to self .

Parameters

self

a RetroCore

 

widget

a GtkWidget, or NULL.

[nullable]

retro_core_iterate_controllers ()

RetroControllerIterator *
retro_core_iterate_controllers (RetroCore *self);

Creates a new RetroControllerIterator which can be used to iterate through the controllers plugged into self .

Parameters

self

a RetroCore

 

Returns

a new RetroControllerIterator.

[transfer full]


retro_core_get_runahead ()

guint
retro_core_get_runahead (RetroCore *self);

retro_core_set_runahead ()

void
retro_core_set_runahead (RetroCore *self,
                         guint runahead);

retro_core_get_speed_rate ()

gdouble
retro_core_get_speed_rate (RetroCore *self);

Gets the speed rate at which to run the core.

Parameters

self

a RetroCore

 

Returns

the speed rate


retro_core_set_speed_rate ()

void
retro_core_set_speed_rate (RetroCore *self,
                           gdouble speed_rate);

Sets the speed rate at which to run the core.

Parameters

self

a RetroCore

 

speed_rate

a speed rate

 

retro_core_has_option ()

gboolean
retro_core_has_option (RetroCore *self,
                       const gchar *key);

Gets whether the core has an option for the given key.

Parameters

self

a RetroCore

 

key

the key of the option

 

Returns

whether the core has an option for the given key


retro_core_get_option ()

RetroOption *
retro_core_get_option (RetroCore *self,
                       const gchar *key);

Gets the option for the given key.

Parameters

self

a RetroCore

 

key

the key of the option

 

Returns

the option.

[transfer none]


retro_core_iterate_options ()

RetroOptionIterator *
retro_core_iterate_options (RetroCore *self);

Creates a new RetroOptionIterator which can be used to iterate through the options of self .

Parameters

self

a RetroCore

 

Returns

a new RetroOptionIterator.

[transfer full]


retro_core_override_option_default ()

void
retro_core_override_option_default (RetroCore *self,
                                    const gchar *key,
                                    const gchar *value);

Overrides default value for the option key . This can be used to set value for a startup-only option.

You can use this before booting the core.

Parameters

self

a RetroCore

 

key

the key of the option

 

value

the default value

 

Types and Values

RETRO_TYPE_CORE

#define RETRO_TYPE_CORE (retro_core_get_type())

RetroCore

typedef struct _RetroCore RetroCore;

Property Details

The “api-version” property

  “api-version”              guint

The Libretro API version implement by the core.

Flags: Read

Default value: 0


The “content-directory” property

  “content-directory”        gchar *

The content directory.

Flags: Read / Write

Default value: NULL


The “filename” property

  “filename”                 gchar *

The filename of the core.

Flags: Read / Write / Construct Only

Default value: NULL


The “frames-per-second” property

  “frames-per-second”        gdouble

The FPS rate for the core's video output.

Flags: Read

Default value: 0


The “game-loaded” property

  “game-loaded”              gboolean

Whether a game has been loaded.

Flags: Read

Default value: FALSE


The “is-initiated” property

  “is-initiated”             gboolean

Whether the core has been initiated.

Flags: Read

Default value: FALSE


The “runahead” property

  “runahead”                 guint

The number of frames to run ahead of time. This allows to know in advance what should happen in the given number of frames, allowing to react in advance.

Note that this is resource intensive as the core will be iterated over multiple times for each perceived iteration. In order to work, this requires the cores to properly support serialization, otherwise the behavior is undefined.

Flags: Read / Write

Default value: 0


The “save-directory” property

  “save-directory”           gchar *

The save directory of the core.

The core will save some data here.

Flags: Read / Write

Default value: NULL


The “speed-rate” property

  “speed-rate”               gdouble

The speed ratio at wich the core will run.

Flags: Read / Write

Allowed values: >= 0

Default value: 1


The “support-no-game” property

  “support-no-game”          gboolean

Whether the core supports running with no game.

Flags: Read

Default value: FALSE


The “system-directory” property

  “system-directory”         gchar *

The system directory of the core.

The core will look here for additional data, such as firmware ROMs or configuration files.

Flags: Read / Write

Default value: NULL

Signal Details

The “crashed” signal

void
user_function (RetroCore *self,
               gchar     *message,
               gpointer   user_data)

The ::crash signal is emitted when the core crashes.

Parameters

self

the RetroCore

 

message

the message to show to the user

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “log” signal

void
user_function (RetroCore *self,
               gchar     *log_domain,
               guint      log_level,
               gchar     *message,
               gpointer   user_data)

The ::log signal is emitted each time the core emits a message to log.

Parameters

self

the RetroCore

 

log_domain

the log domain

 

log_level

the log level.

[type GLogLevelFlags]

message

the message

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “message” signal

void
user_function (RetroCore *self,
               gchar     *message,
               guint      frames,
               gpointer   user_data)

The ::message signal is emitted each time the core emits a message to display during a given amount of frames.

Parameters

self

the RetroCore

 

message

the message

 

frames

the number of frames the message should be displayed

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “shutdown” signal

void
user_function (RetroCore *self,
               gpointer   user_data)

The ::shutdown signal is emitted when the core shut down.

The core must be released or re-started in order to function anew.

Parameters

self

the RetroCore

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “video-output” signal

void
user_function (RetroCore *self,
               gpointer   pixdata,
               gpointer   user_data)

The ::video-output signal is emitted each time a new video frame is emitted by the core.

pixdata will be invalid after the signal emission, copy it in some way if you want to keep it.

Parameters

self

the RetroCore

 

pixdata

the RetroPixdata.

[type RetroPixdata]

user_data

user data set when the signal handler was connected.

 

Flags: Run Last

See Also

RetroCoreView