[retro-gtk/c-port: 35/42] Port Core to C



commit 8271ffb636149b81225b5350d92abdec3fd2d7ba
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Mon Sep 25 13:52:36 2017 +0200

    Port Core to C

 retro-gtk/Makefile.am                 |    2 +-
 retro-gtk/core.vala                   |  200 ---------
 retro-gtk/retro-cairo-display.h       |    4 +-
 retro-gtk/retro-controller-iterator.h |    1 +
 retro-gtk/retro-core-private.h        |   27 +-
 retro-gtk/retro-core-view.h           |    4 +-
 retro-gtk/retro-core.c                |  749 ++++++++++++++++++++++++++++-----
 retro-gtk/retro-core.h                |   91 ++++
 retro-gtk/retro-environment.c         |    4 +-
 retro-gtk/retro-gtk.h                 |    1 +
 retro-gtk/retro-log.c                 |    2 +-
 retro-gtk/retro-log.h                 |    4 +-
 retro-gtk/retro-main-loop.h           |    5 +-
 retro-gtk/retro-module.h              |    3 +-
 retro-gtk/retro-rumble-effect.h       |    2 +-
 15 files changed, 774 insertions(+), 325 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index 366fd29..9c5ddfe 100644
--- a/retro-gtk/Makefile.am
+++ b/retro-gtk/Makefile.am
@@ -35,6 +35,7 @@ retro_gtk_public_h_sources = \
        retro-cairo-display.h \
        retro-controller-iterator.h \
        retro-core-descriptor.h \
+       retro-core.h \
        retro-core-view.h \
        retro-device-type.h \
        retro-gtk.h \
@@ -75,7 +76,6 @@ retro_gtk_private_h_sources = \
 libretro_gtk_la_SOURCES = \
        input/retro-keyboard-key.c \
        \
-       core.vala \
        retro.vala \
        retro-cairo-display.c \
        retro-controller-iterator.c \
diff --git a/retro-gtk/retro-cairo-display.h b/retro-gtk/retro-cairo-display.h
index 1a54c28..efa03c2 100644
--- a/retro-gtk/retro-cairo-display.h
+++ b/retro-gtk/retro-cairo-display.h
@@ -8,13 +8,11 @@
 #endif
 
 #include <gtk/gtk.h>
+#include "retro-core.h"
 #include "retro-video-filter.h"
 
 G_BEGIN_DECLS
 
-// FIXME Remove as soon as possible.
-typedef struct _RetroCore RetroCore;
-
 #define RETRO_TYPE_CAIRO_DISPLAY (retro_cairo_display_get_type())
 
 G_DECLARE_FINAL_TYPE (RetroCairoDisplay, retro_cairo_display, RETRO, CAIRO_DISPLAY, GtkDrawingArea)
diff --git a/retro-gtk/retro-controller-iterator.h b/retro-gtk/retro-controller-iterator.h
index 6c91dae..aad2505 100644
--- a/retro-gtk/retro-controller-iterator.h
+++ b/retro-gtk/retro-controller-iterator.h
@@ -8,6 +8,7 @@
 #endif
 
 #include <glib-object.h>
+#include "retro-input-device.h"
 
 G_BEGIN_DECLS
 
diff --git a/retro-gtk/retro-core-private.h b/retro-gtk/retro-core-private.h
index 31d260b..2525fe0 100644
--- a/retro-gtk/retro-core-private.h
+++ b/retro-gtk/retro-core-private.h
@@ -7,6 +7,7 @@
 # error "Only <retro-gtk.h> can be included directly."
 #endif
 
+#include "retro-core.h"
 #include "retro-disk-control-callback.h"
 #include "retro-gtk-internal.h"
 #include "retro-module.h"
@@ -20,11 +21,23 @@ typedef struct {
   void (*callback) (guchar down, guint keycode, guint32 character, guint16 key_modifiers);
 } RetroKeyboardCallback;
 
-#define RETRO_CORE_ENVIRONMENT_INTERNAL(core) ((RetroCoreEnvironmentInternal *) 
((core)->environment_internal))
+#define RETRO_CORE_ENVIRONMENT_INTERNAL(core) ((RetroCoreEnvironmentInternal *) (core))
 
-typedef struct _RetroCoreEnvironmentInternal RetroCoreEnvironmentInternal;
+typedef struct _RetroCore RetroCoreEnvironmentInternal;
+
+struct _RetroCore
+{
+  GObject parent_instance;
+  gchar *file_name;
+  gchar *system_directory;
+  gchar *libretro_path;
+  gchar *content_directory;
+  gchar *save_directory;
+  gboolean is_initiated;
+  gboolean game_loaded;
+  gboolean support_no_game;
+  gdouble frames_per_second;
 
-struct _RetroCoreEnvironmentInternal {
   RetroModule *module;
   RetroDiskControlCallback *disk_control_callback;
   gchar **media_uris;
@@ -37,9 +50,17 @@ struct _RetroCoreEnvironmentInternal {
 
   RetroKeyboardCallback keyboard_callback;
   GHashTable *controllers;
+  GtkWidget *keyboard_widget;
+  gulong key_press_event_id;
+  gulong key_release_event_id;
   RetroOptions *options;
 };
 
+void retro_core_push_cb_data (RetroCore *self);
+void retro_core_pop_cb_data (void);
+RetroCore *retro_core_get_cb_data (void);
+void retro_core_set_support_no_game (RetroCore *self,
+                                     gboolean   value);
 gchar *retro_core_get_name (RetroCore *self);
 void retro_core_set_system_av_info (RetroCore         *self,
                                     RetroSystemAvInfo *system_av_info);
diff --git a/retro-gtk/retro-core-view.h b/retro-gtk/retro-core-view.h
index 6636442..4b9551e 100644
--- a/retro-gtk/retro-core-view.h
+++ b/retro-gtk/retro-core-view.h
@@ -6,15 +6,13 @@
 #endif
 
 #include <gtk/gtk.h>
+#include "retro-core.h"
 #include "retro-device-type.h"
 #include "retro-input-device.h"
 #include "retro-video-filter.h"
 
 G_BEGIN_DECLS
 
-// FIXME Remove as soon as possible.
-typedef struct _RetroCore RetroCore;
-
 #define RETRO_TYPE_CORE_VIEW (retro_core_view_get_type())
 
 G_DECLARE_FINAL_TYPE (RetroCoreView, retro_core_view, RETRO, CORE_VIEW, GtkEventBox)
diff --git a/retro-gtk/retro-core.c b/retro-gtk/retro-core.c
index d14c87e..78427c9 100644
--- a/retro-gtk/retro-core.c
+++ b/retro-gtk/retro-core.c
@@ -2,8 +2,8 @@
 
 #include "retro-core-private.h"
 
+#include <string.h>
 #include "retro-controller-iterator-private.h"
-#include "retro-gtk-internal.h"
 #include "input/retro-keyboard-key.h"
 
 #define RETRO_CORE_ERROR (retro_core_error_quark ())
@@ -15,7 +15,36 @@ enum {
   RETRO_CORE_ERROR_NO_CALLBACK,
 };
 
-/* Private */
+G_DEFINE_TYPE (RetroCore, retro_core, G_TYPE_OBJECT)
+
+enum {
+  SIG_VIDEO_OUTPUT_SIGNAL,
+  SIG_AUDIO_OUTPUT_SIGNAL,
+  SIG_LOG_SIGNAL,
+  SIG_SHUTDOWN_SIGNAL,
+  SIG_MESSAGE_SIGNAL,
+  N_SIGNALS,
+};
+
+static guint signals[N_SIGNALS];
+
+enum {
+  PROP_0,
+  PROP_API_VERSION,
+  PROP_FILE_NAME,
+  PROP_SYSTEM_DIRECTORY,
+  PROP_LIBRETRO_PATH,
+  PROP_CONTENT_DIRECTORY,
+  PROP_SAVE_DIRECTORY,
+  PROP_IS_INITIATED,
+  PROP_GAME_LOADED,
+  PROP_SUPPORT_NO_GAME,
+  PROP_FRAMES_PER_SECOND,
+  PROP_RUMBLE_INTERFACE,
+  N_PROPS
+};
+
+static GParamSpec *properties [N_PROPS];
 
 #define RETRO_CORE_OBJECTS_LENGTH 32
 
@@ -24,17 +53,25 @@ static GRecMutex retro_core_w_mutex = { 0 };
 static RetroCore *retro_core_objects[32];
 static gint retro_core_i = 0;
 
+static void retro_core_set_file_name (RetroCore   *self,
+                                      const gchar *value);
+static void retro_core_set_is_initiated (RetroCore *self,
+                                         gboolean   value);
+static void retro_core_set_game_loaded (RetroCore *self,
+                                        gboolean   value);
+
+/* Private */
+
 static GQuark
 retro_core_error_quark (void)
 {
   return g_quark_from_static_string ("retro-core-error-quark");
 }
 
-// FIXME Make static as soon as possible.
 void
 retro_core_push_cb_data (RetroCore *self)
 {
-  g_return_if_fail (self != NULL);
+  g_return_if_fail (RETRO_IS_CORE (self));
 
   g_rec_mutex_lock (&retro_core_w_mutex);
   g_rec_mutex_lock (&retro_core_r_mutex);
@@ -52,7 +89,6 @@ retro_core_push_cb_data (RetroCore *self)
   g_rec_mutex_unlock (&retro_core_r_mutex);
 }
 
-// FIXME Make static as soon as possible.
 void
 retro_core_pop_cb_data (void)
 {
@@ -73,7 +109,6 @@ retro_core_pop_cb_data (void)
   g_rec_mutex_unlock (&retro_core_w_mutex);
 }
 
-// FIXME Make static as soon as possible.
 RetroCore *
 retro_core_get_cb_data (void)
 {
@@ -94,6 +129,399 @@ retro_core_get_cb_data (void)
   return result;
 }
 
+static void
+retro_core_finalize (GObject *object)
+{
+  RetroCore *self = RETRO_CORE (object);
+  RetroCoreEnvironmentInternal *internal;
+  RetroUnloadGame unload_game;
+  RetroDeinit deinit;
+
+  g_return_if_fail (RETRO_IS_CORE (self));
+
+  internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
+
+  retro_core_push_cb_data (self);
+  if (retro_core_get_game_loaded (self)) {
+    unload_game = retro_module_get_unload_game (internal->module);
+    unload_game ();
+  }
+  deinit = retro_module_get_deinit (internal->module);
+  deinit ();
+  retro_core_pop_cb_data ();
+
+  if (internal->media_uris != NULL)
+    g_strfreev (internal->media_uris);
+
+  g_object_unref (internal->module);
+  g_hash_table_unref (internal->controllers);
+  g_object_unref (internal->options);
+
+  g_free (self->file_name);
+  g_free (self->system_directory);
+  g_free (self->libretro_path);
+  g_free (self->content_directory);
+  g_free (self->save_directory);
+  g_object_unref (self->keyboard_widget);
+
+  G_OBJECT_CLASS (retro_core_parent_class)->finalize (object);
+}
+
+static void
+retro_core_get_property (GObject    *object,
+                         guint       prop_id,
+                         GValue     *value,
+                         GParamSpec *pspec)
+{
+  RetroCore *self = RETRO_CORE (object);
+
+  switch (prop_id) {
+  case PROP_API_VERSION:
+    g_value_set_uint (value, retro_core_get_api_version (self));
+
+    break;
+  case PROP_FILE_NAME:
+    g_value_set_string (value, retro_core_get_file_name (self));
+
+    break;
+  case PROP_SYSTEM_DIRECTORY:
+    g_value_set_string (value, retro_core_get_system_directory (self));
+
+    break;
+  case PROP_LIBRETRO_PATH:
+    g_value_set_string (value, retro_core_get_libretro_path (self));
+
+    break;
+  case PROP_CONTENT_DIRECTORY:
+    g_value_set_string (value, retro_core_get_content_directory (self));
+
+    break;
+  case PROP_SAVE_DIRECTORY:
+    g_value_set_string (value, retro_core_get_save_directory (self));
+
+    break;
+  case PROP_IS_INITIATED:
+    g_value_set_boolean (value, retro_core_get_is_initiated (self));
+
+    break;
+  case PROP_GAME_LOADED:
+    g_value_set_boolean (value, retro_core_get_game_loaded (self));
+
+    break;
+  case PROP_SUPPORT_NO_GAME:
+    g_value_set_boolean (value, retro_core_get_support_no_game (self));
+
+    break;
+  case PROP_FRAMES_PER_SECOND:
+    g_value_set_double (value, retro_core_get_frames_per_second (self));
+
+    break;
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+
+    break;
+  }
+}
+
+static void
+retro_core_set_property (GObject      *object,
+                         guint         prop_id,
+                         const GValue *value,
+                         GParamSpec   *pspec)
+{
+  RetroCore *self = RETRO_CORE (object);
+
+  // TODO
+  switch (prop_id) {
+  case PROP_FILE_NAME:
+    retro_core_set_file_name (self, g_value_get_string (value));
+
+    break;
+  case PROP_SYSTEM_DIRECTORY:
+    retro_core_set_system_directory (self, g_value_get_string (value));
+
+    break;
+  case PROP_LIBRETRO_PATH:
+    retro_core_set_libretro_path (self, g_value_get_string (value));
+
+    break;
+  case PROP_CONTENT_DIRECTORY:
+    retro_core_set_content_directory (self, g_value_get_string (value));
+
+    break;
+  case PROP_SAVE_DIRECTORY:
+    retro_core_set_save_directory (self, g_value_get_string (value));
+
+    break;
+  case PROP_IS_INITIATED:
+    retro_core_set_is_initiated (self, g_value_get_boolean (value));
+
+    break;
+  case PROP_GAME_LOADED:
+    retro_core_set_game_loaded (self, g_value_get_boolean (value));
+
+    break;
+  case PROP_SUPPORT_NO_GAME:
+    retro_core_set_support_no_game (self, g_value_get_boolean (value));
+
+    break;
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+
+    break;
+  }
+}
+
+static void
+retro_core_class_init (RetroCoreClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = retro_core_finalize;
+  object_class->get_property = retro_core_get_property;
+  object_class->set_property = retro_core_set_property;
+
+  properties[PROP_API_VERSION] =
+    g_param_spec_uint ("api-version",
+                       "API version",
+                       "The API version",
+                       0,
+                       G_MAXUINT,
+                       0U,
+                       G_PARAM_READABLE |
+                       G_PARAM_STATIC_NAME |
+                       G_PARAM_STATIC_NICK |
+                       G_PARAM_STATIC_BLURB);
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_API_VERSION, properties[PROP_API_VERSION]);
+
+  properties[PROP_FILE_NAME] =
+    g_param_spec_string ("file-name",
+                         "File name",
+                         "The module file name",
+                         NULL,
+                         G_PARAM_READWRITE |
+                         G_PARAM_STATIC_NAME |
+                         G_PARAM_STATIC_NICK |
+                         G_PARAM_STATIC_BLURB);
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_FILE_NAME, properties[PROP_FILE_NAME]);
+
+  properties[PROP_SYSTEM_DIRECTORY] =
+    g_param_spec_string ("system-directory",
+                         "System directory",
+                         "The system directory",
+                         NULL,
+                         G_PARAM_READWRITE |
+                         G_PARAM_STATIC_NAME |
+                         G_PARAM_STATIC_NICK |
+                         G_PARAM_STATIC_BLURB);
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SYSTEM_DIRECTORY, 
properties[PROP_SYSTEM_DIRECTORY]);
+
+  properties[PROP_LIBRETRO_PATH] =
+    g_param_spec_string ("libretro-path",
+                         "Libretro path",
+                         "The Libretro path",
+                         NULL,
+                         G_PARAM_READWRITE |
+                         G_PARAM_STATIC_NAME |
+                         G_PARAM_STATIC_NICK |
+                         G_PARAM_STATIC_BLURB);
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_LIBRETRO_PATH, 
properties[PROP_LIBRETRO_PATH]);
+
+  properties[PROP_CONTENT_DIRECTORY] =
+    g_param_spec_string ("content-directory",
+                         "Content directory",
+                         "The content directory",
+                         NULL,
+                         G_PARAM_READWRITE |
+                         G_PARAM_STATIC_NAME |
+                         G_PARAM_STATIC_NICK |
+                         G_PARAM_STATIC_BLURB);
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_CONTENT_DIRECTORY, 
properties[PROP_CONTENT_DIRECTORY]);
+
+  properties[PROP_SAVE_DIRECTORY] =
+    g_param_spec_string ("save-directory",
+                         "Save directory",
+                         "The save directory",
+                         NULL,
+                         G_PARAM_READWRITE |
+                         G_PARAM_STATIC_NAME |
+                         G_PARAM_STATIC_NICK |
+                         G_PARAM_STATIC_BLURB);
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SAVE_DIRECTORY, 
properties[PROP_SAVE_DIRECTORY]);
+
+  properties[PROP_IS_INITIATED] =
+    g_param_spec_boolean ("is-initiated",
+                          "Is initiated",
+                          "Whether the core has been booted",
+                          FALSE,
+                          G_PARAM_READWRITE |
+                          G_PARAM_STATIC_NAME |
+                          G_PARAM_STATIC_NICK |
+                          G_PARAM_STATIC_BLURB);
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_IS_INITIATED, properties[PROP_IS_INITIATED]);
+
+  properties[PROP_GAME_LOADED] =
+    g_param_spec_boolean ("game-loaded",
+                          "Game loaded",
+                          "Whether the game has been loaded",
+                          FALSE,
+                          G_PARAM_READWRITE |
+                          G_PARAM_STATIC_NAME |
+                          G_PARAM_STATIC_NICK |
+                          G_PARAM_STATIC_BLURB);
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_GAME_LOADED, properties[PROP_GAME_LOADED]);
+
+  properties[PROP_SUPPORT_NO_GAME] =
+    g_param_spec_boolean ("support-no-game",
+                          "Support no game",
+                          "Whether the core supports no game",
+                          FALSE,
+                          G_PARAM_READWRITE |
+                          G_PARAM_STATIC_NAME |
+                          G_PARAM_STATIC_NICK |
+                          G_PARAM_STATIC_BLURB);
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SUPPORT_NO_GAME, 
properties[PROP_SUPPORT_NO_GAME]);
+
+  properties[PROP_FRAMES_PER_SECOND] =
+    g_param_spec_double ("frames-per-second",
+                         "Frames per second",
+                         "The FPS rate for the core's video output",
+                         -G_MAXDOUBLE,
+                         G_MAXDOUBLE,
+                         0.0,
+                         G_PARAM_READABLE |
+                         G_PARAM_STATIC_NAME |
+                         G_PARAM_STATIC_NICK |
+                         G_PARAM_STATIC_BLURB);
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_FRAMES_PER_SECOND, 
properties[PROP_FRAMES_PER_SECOND]);
+
+  signals[SIG_VIDEO_OUTPUT_SIGNAL] =
+    g_signal_new ("video-output", RETRO_TYPE_CORE, G_SIGNAL_RUN_LAST,
+                  0, NULL, NULL,
+                  NULL,
+                  G_TYPE_NONE,
+                  7,
+                  G_TYPE_POINTER,
+                  G_TYPE_INT,
+                  G_TYPE_UINT,
+                  G_TYPE_UINT,
+                  G_TYPE_ULONG,
+                  RETRO_TYPE_PIXEL_FORMAT,
+                  G_TYPE_FLOAT);
+
+  signals[SIG_AUDIO_OUTPUT_SIGNAL] =
+    g_signal_new ("audio-output", RETRO_TYPE_CORE, G_SIGNAL_RUN_LAST,
+                  0, NULL, NULL,
+                  NULL,
+                  G_TYPE_NONE,
+                  3,
+                  G_TYPE_POINTER,
+                  G_TYPE_INT,
+                  G_TYPE_DOUBLE);
+
+  signals[SIG_LOG_SIGNAL] =
+    g_signal_new ("log", RETRO_TYPE_CORE, G_SIGNAL_RUN_LAST,
+                  0, NULL, NULL,
+                  NULL,
+                  G_TYPE_NONE,
+                  3,
+                  G_TYPE_STRING,
+                  G_TYPE_UINT,
+                  G_TYPE_STRING);
+
+  signals[SIG_SHUTDOWN_SIGNAL] =
+    g_signal_new ("shutdown", RETRO_TYPE_CORE, G_SIGNAL_RUN_LAST,
+                  0, NULL, NULL,
+                  NULL,
+                  G_TYPE_BOOLEAN,
+                  0);
+
+  signals[SIG_MESSAGE_SIGNAL] =
+    g_signal_new ("message", RETRO_TYPE_CORE, G_SIGNAL_RUN_LAST,
+                  0, NULL, NULL,
+                  NULL,
+                  G_TYPE_BOOLEAN,
+                  2,
+                  G_TYPE_STRING,
+                  G_TYPE_UINT);
+}
+
+static void
+retro_core_init (RetroCore *self)
+{
+}
+
+static void
+retro_controller_iterator_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (retro_controller_iterator_parent_class)->finalize (object);
+}
+
+static void
+retro_controller_iterator_class_init (RetroControllerIteratorClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = retro_controller_iterator_finalize;
+}
+
+static void
+retro_controller_iterator_init (RetroControllerIterator *self)
+{
+}
+
+static RetroControllerIterator *
+retro_controller_iterator_new (GHashTable *controllers)
+{
+  RetroControllerIterator *self;
+  g_return_val_if_fail (controllers != NULL, NULL);
+
+  self = g_object_new (RETRO_TYPE_CORE, NULL);
+  g_hash_table_iter_init (&self->iterator, controllers);
+
+  return self;
+}
+
+static void
+retro_core_set_file_name (RetroCore   *self,
+                          const gchar *value)
+{
+  g_return_if_fail (RETRO_IS_CORE (self));
+
+  if (g_strcmp0 (value, retro_core_get_file_name (self)) == 0)
+    return;
+
+  g_free (self->file_name);
+  self->file_name = g_strdup (value);;
+  g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FILE_NAME]);
+}
+
+static void
+retro_core_set_is_initiated (RetroCore *self,
+                             gboolean   value)
+{
+  g_return_if_fail (RETRO_IS_CORE (self));
+
+  if (retro_core_get_is_initiated (self) == value)
+    return;
+
+  self->is_initiated = value;
+  g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_IS_INITIATED]);
+}
+
+static void
+retro_core_set_game_loaded (RetroCore *self,
+                            gboolean   value)
+{
+  g_return_if_fail (RETRO_IS_CORE (self));
+
+  if (retro_core_get_game_loaded (self) == value)
+    return;
+
+  self->game_loaded = value;
+  g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_GAME_LOADED]);
+}
+
 /**
  * retro_core_get_system_info:
  * @self: A #RetroCore
@@ -108,7 +536,7 @@ retro_core_get_system_info (RetroCore       *self,
   RetroCoreEnvironmentInternal *internal;
   RetroGetSystemInfo get_system_info;
 
-  g_return_if_fail (self != NULL);
+  g_return_if_fail (RETRO_IS_CORE (self));
   g_return_if_fail (system_info != NULL);
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
@@ -154,7 +582,7 @@ retro_core_controller_connected (RetroCore        *self,
 {
   RetroDeviceType device_type;
 
-  g_return_if_fail (self != NULL);
+  g_return_if_fail (RETRO_IS_CORE (self));
   g_return_if_fail (device != NULL);
 
   if (!retro_core_get_is_initiated (self))
@@ -169,7 +597,7 @@ void
 retro_core_controller_disconnected (RetroCore *self,
                                     guint      port)
 {
-  g_return_if_fail (self != NULL);
+  g_return_if_fail (RETRO_IS_CORE (self));
 
   if (!retro_core_get_is_initiated (self))
     return;
@@ -186,7 +614,7 @@ retro_core_send_input_key_event (RetroCore                *self,
 {
   RetroCoreEnvironmentInternal *environment_internal;
 
-  g_return_if_fail (self != NULL);
+  g_return_if_fail (RETRO_IS_CORE (self));
 
   environment_internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
 
@@ -206,7 +634,7 @@ retro_core_key_event (RetroCore   *self,
   RetroKeyboardModifierKey retro_modifier_key;
   guint32 character;
 
-  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
   g_return_val_if_fail (event != NULL, FALSE);
 
   if (!retro_core_get_is_initiated (self))
@@ -237,7 +665,7 @@ retro_core_set_disk_ejected (RetroCore  *self,
   RetroDiskControlCallbackSetEjectState set_eject_state;
   gboolean result;
 
-  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
 
@@ -268,7 +696,7 @@ retro_core_set_disk_image_index (RetroCore  *self,
   RetroDiskControlCallbackSetImageIndex set_image_index;
   gboolean result;
 
-  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
 
@@ -298,7 +726,7 @@ retro_core_get_disk_images_number (RetroCore  *self,
   RetroDiskControlCallbackGetNumImages get_num_images;
   guint result;
 
-  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
 
@@ -330,7 +758,7 @@ retro_core_replace_disk_image_index (RetroCore     *self,
   RetroDiskControlCallbackReplaceImageIndex replace_image_index;
   gboolean result;
 
-  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
 
@@ -360,7 +788,7 @@ retro_core_add_disk_image_index (RetroCore  *self,
   RetroDiskControlCallbackAddImageIndex add_image_index;
   gboolean result;
 
-  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
 
@@ -395,7 +823,7 @@ retro_core_load_discs (RetroCore  *self,
   RetroGameInfo *game_info = NULL;
   GError *tmp_error = NULL;
 
-  g_return_if_fail (self != NULL);
+  g_return_if_fail (RETRO_IS_CORE (self));
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
 
@@ -480,7 +908,7 @@ retro_core_load_game (RetroCore     *self,
   gboolean game_loaded;
   RetroSystemAvInfo info = {{ 0 }};
 
-  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
   g_return_val_if_fail (game != NULL, FALSE);
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
@@ -505,14 +933,14 @@ retro_core_load_game (RetroCore     *self,
 }
 
 static gboolean
-retro_core_prepare (RetroCore* self) {
+retro_core_prepare (RetroCore *self) {
   RetroCoreEnvironmentInternal *internal;
   RetroLoadGame load_game;
   RetroGetSystemAvInfo get_system_av_info;
   gboolean game_loaded;
   RetroSystemAvInfo info = {{ 0 }};
 
-  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
 
@@ -529,7 +957,7 @@ retro_core_prepare (RetroCore* self) {
 }
 
 static void
-retro_core_load_medias (RetroCore* self,
+retro_core_load_medias (RetroCore *self,
                         GError** error)
 {
   RetroCoreEnvironmentInternal *internal;
@@ -541,7 +969,7 @@ retro_core_load_medias (RetroCore* self,
   RetroGameInfo *game_info = NULL;
   GError *tmp_error = NULL;
 
-  g_return_if_fail (self != NULL);
+  g_return_if_fail (RETRO_IS_CORE (self));
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
   length = g_strv_length (internal->media_uris);
@@ -597,15 +1025,37 @@ retro_core_load_medias (RetroCore* self,
   g_free (uri);
 }
 
+void retro_core_set_environment_interface (RetroCore *self);
+void retro_core_set_callbacks (RetroCore *self);
+
 // FIXME Make static as soon as possible.
-guint
-retro_core_get_api_version_real (RetroCore *self)
+void
+retro_core_constructor (RetroCore   *self,
+                        const gchar *file_name)
+{
+
+}
+
+static gboolean
+on_key_event (GtkWidget   *widget,
+              GdkEventKey *event,
+              gpointer     self)
 {
+  g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+  g_return_val_if_fail (event != NULL, FALSE);
+
+  return retro_core_key_event (RETRO_CORE (self), event);
+}
+
+/* Public */
+
+guint retro_core_get_api_version (RetroCore *self) {
   RetroCoreEnvironmentInternal *internal;
   guint result;
   RetroApiVersion api_version;
 
-  g_return_val_if_fail (self != NULL, 0U);
+  g_return_val_if_fail (RETRO_IS_CORE (self), 0U);
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
 
@@ -617,90 +1067,143 @@ retro_core_get_api_version_real (RetroCore *self)
   return result;
 }
 
-void retro_core_set_environment_interface (RetroCore *self);
-void retro_core_set_callbacks (RetroCore *self);
+const gchar *
+retro_core_get_file_name (RetroCore *self)
+{
+  g_return_val_if_fail (RETRO_IS_CORE (self), NULL);
 
-// FIXME Make static as soon as possible.
-void
-retro_core_constructor (RetroCore   *self,
-                        const gchar *file_name)
+  return self->file_name;
+}
+
+const gchar *
+retro_core_get_system_directory (RetroCore *self)
 {
-  RetroCoreEnvironmentInternal *internal;
-  GFile *file;
-  GFile *relative_path_file;
-  gchar *libretro_path;
+  g_return_val_if_fail (RETRO_IS_CORE (self), NULL);
 
-  g_return_if_fail (file_name != NULL);
+  return self->system_directory;
+}
 
-  retro_core_set_file_name (self, file_name);
+void retro_core_set_system_directory (RetroCore *self, const gchar* value) {
+  g_return_if_fail (RETRO_IS_CORE (self));
 
-  internal = g_new0 (RetroCoreEnvironmentInternal, 1);
-  self->environment_internal = internal;
+  if (g_strcmp0 (value, retro_core_get_system_directory (self)) == 0)
+    return;
 
-  file = g_file_new_for_path (file_name);
-  relative_path_file = g_file_resolve_relative_path (file, "");
+  g_free (self->system_directory);
+  self->system_directory = g_strdup (value);
+  g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SYSTEM_DIRECTORY]);
+}
 
-  g_object_unref (file);
+const gchar *
+retro_core_get_libretro_path (RetroCore *self)
+{
+  g_return_val_if_fail (RETRO_IS_CORE (self), NULL);
 
-  libretro_path = g_file_get_path (relative_path_file);
+  return self->libretro_path;
+}
 
-  g_object_unref (relative_path_file);
+void
+retro_core_set_libretro_path (RetroCore   *self,
+                              const gchar *value)
+{
+  g_return_if_fail (RETRO_IS_CORE (self));
 
-  retro_core_set_libretro_path (self, libretro_path);
-  internal->module = retro_module_new (libretro_path);
+  if (g_strcmp0 (value, retro_core_get_libretro_path (self)) == 0)
+    return;
 
-  g_free (libretro_path);
+  g_free (self->libretro_path);
+  self->libretro_path = g_strdup (value);
+  g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_LIBRETRO_PATH]);
+}
 
-  retro_core_set_callbacks (self);
-  internal->controllers = g_hash_table_new_full (g_int_hash, g_int_equal,
-                                                        g_free, g_object_unref);
-  internal->options = retro_options_new ();
+const gchar *
+retro_core_get_content_directory (RetroCore *self)
+{
+  g_return_val_if_fail (RETRO_IS_CORE (self), NULL);
+
+  return self->content_directory;
 }
 
-// FIXME Make static as soon as possible.
 void
-retro_core_destructor (RetroCore *self)
+retro_core_set_content_directory (RetroCore   *self,
+                                  const gchar *value)
 {
-  RetroCoreEnvironmentInternal *internal;
-  RetroUnloadGame unload_game;
-  RetroDeinit deinit;
+  g_return_if_fail (RETRO_IS_CORE (self));
 
-  g_return_if_fail (self != NULL);
+  if (g_strcmp0 (value, retro_core_get_content_directory (self)) == 0)
+    return;
 
-  internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
+  g_free (self->content_directory);
+  self->content_directory = g_strdup (value);
+  g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_CONTENT_DIRECTORY]);
+}
 
-  retro_core_push_cb_data (self);
-  if (retro_core_get_game_loaded (self)) {
-    unload_game = retro_module_get_unload_game (internal->module);
-    unload_game ();
-  }
-  deinit = retro_module_get_deinit (internal->module);
-  deinit ();
-  retro_core_pop_cb_data ();
+const gchar *
+retro_core_get_save_directory (RetroCore *self)
+{
+  g_return_val_if_fail (RETRO_IS_CORE (self), NULL);
 
-  if (internal->media_uris != NULL)
-    g_strfreev (internal->media_uris);
+  return self->save_directory;
+}
 
-  g_object_unref (internal->module);
-  g_hash_table_unref (internal->controllers);
-  g_object_unref (internal->options);
+void
+retro_core_set_save_directory (RetroCore   *self,
+                               const gchar *value)
+{
+  g_return_if_fail (RETRO_IS_CORE (self));
+
+  if (g_strcmp0 (value, retro_core_get_save_directory (self)) == 0)
+    return;
 
-  g_free (self->environment_internal);
+  g_free (self->save_directory);
+  self->save_directory = g_strdup (value);
+  g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SAVE_DIRECTORY]);
 }
 
-static gboolean
-on_key_event (GtkWidget   *widget,
-              GdkEventKey *event,
-              gpointer     self)
+gboolean
+retro_core_get_is_initiated (RetroCore *self)
 {
   g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
-  g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
-  g_return_val_if_fail (event != NULL, FALSE);
 
-  return retro_core_key_event (RETRO_CORE (self), event);
+  return self->is_initiated;
 }
 
-/* Public */
+gboolean
+retro_core_get_game_loaded (RetroCore *self)
+{
+  g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
+
+  return self->game_loaded;
+}
+
+gboolean
+retro_core_get_support_no_game (RetroCore *self)
+{
+  g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
+
+  return self->support_no_game;
+}
+
+void
+retro_core_set_support_no_game (RetroCore *self,
+                                gboolean   value)
+{
+  g_return_if_fail (RETRO_IS_CORE (self));
+
+  if (retro_core_get_support_no_game (self) == value)
+    return;
+
+  self->support_no_game = value;
+  g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SUPPORT_NO_GAME]);
+}
+
+gdouble
+retro_core_get_frames_per_second (RetroCore *self)
+{
+  g_return_val_if_fail (RETRO_IS_CORE (self), 0.0);
+
+  return self->frames_per_second;
+}
 
 void
 retro_core_boot (RetroCore  *self,
@@ -714,7 +1217,7 @@ retro_core_boot (RetroCore  *self,
   RetroDeviceType device_type;
   GError *tmp_error = NULL;
 
-  g_return_if_fail (self != NULL);
+  g_return_if_fail (RETRO_IS_CORE (self));
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
 
@@ -745,12 +1248,12 @@ retro_core_boot (RetroCore  *self,
 }
 
 void
-retro_core_set_medias (RetroCore  *self,
-                       gchar     **uris)
+retro_core_set_medias (RetroCore    *self,
+                       const gchar **uris)
 {
   RetroCoreEnvironmentInternal *internal;
 
-  g_return_if_fail (self != NULL);
+  g_return_if_fail (RETRO_IS_CORE (self));
   g_return_if_fail (!retro_core_get_is_initiated (self));
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
@@ -758,7 +1261,7 @@ retro_core_set_medias (RetroCore  *self,
   if (internal->media_uris != NULL)
     g_strfreev (internal->media_uris);
 
-  internal->media_uris = g_strdupv (uris);
+  internal->media_uris = g_strdupv ((gchar **) uris);
 }
 
 void
@@ -770,7 +1273,7 @@ retro_core_set_current_media (RetroCore  *self,
   guint length;
   GError *tmp_error = NULL;
 
-  g_return_if_fail (self != NULL);
+  g_return_if_fail (RETRO_IS_CORE (self));
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
   length = g_strv_length (internal->media_uris);
@@ -810,7 +1313,7 @@ retro_core_set_controller_port_device (RetroCore       *self,
   RetroCoreEnvironmentInternal *internal;
   RetroSetControllerPortDevice set_controller_port_device;
 
-  g_return_if_fail (self != NULL);
+  g_return_if_fail (RETRO_IS_CORE (self));
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
 
@@ -821,12 +1324,12 @@ retro_core_set_controller_port_device (RetroCore       *self,
 }
 
 void
-retro_core_reset (RetroCore* self)
+retro_core_reset (RetroCore *self)
 {
   RetroCoreEnvironmentInternal *internal;
   RetroReset reset;
 
-  g_return_if_fail (self != NULL);
+  g_return_if_fail (RETRO_IS_CORE (self));
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
 
@@ -837,12 +1340,12 @@ retro_core_reset (RetroCore* self)
 }
 
 void
-retro_core_run (RetroCore* self)
+retro_core_run (RetroCore *self)
 {
   RetroCoreEnvironmentInternal *internal;
   RetroRun run;
 
-  g_return_if_fail (self != NULL);
+  g_return_if_fail (RETRO_IS_CORE (self));
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
 
@@ -859,7 +1362,7 @@ retro_core_supports_serialization (RetroCore *self)
   RetroSerializeSize serialize_size = NULL;
   gsize size;
 
-  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
 
@@ -883,7 +1386,7 @@ retro_core_serialize_state (RetroCore  *self,
   gsize size;
   gboolean success;
 
-  g_return_val_if_fail (self != NULL, NULL);
+  g_return_val_if_fail (RETRO_IS_CORE (self), NULL);
   g_return_val_if_fail (length != NULL, NULL);
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
@@ -937,7 +1440,7 @@ retro_core_deserialize_state (RetroCore  *self,
   gsize size;
   gboolean success;
 
-  g_return_if_fail (self != NULL);
+  g_return_if_fail (RETRO_IS_CORE (self));
   g_return_if_fail (data != NULL);
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
@@ -961,7 +1464,10 @@ retro_core_deserialize_state (RetroCore  *self,
     g_set_error (error,
                  RETRO_CORE_ERROR,
                  RETRO_CORE_ERROR_COULDNT_DESERIALIZE,
-                 "Couldn't deserialize the internal state: expected at most %"G_GSIZE_FORMAT" bytes, got 
%"G_GSIZE_FORMAT".", size, length);
+                 "Couldn't deserialize the internal state: expected at most %"
+                 G_GSIZE_FORMAT" bytes, got %"G_GSIZE_FORMAT".",
+                 size,
+                 length);
 
     return;
   }
@@ -988,7 +1494,7 @@ retro_core_get_memory_size (RetroCore       *self,
   gsize size;
   RetroGetMemorySize get_memory_size;
 
-  g_return_val_if_fail (self != NULL, 0UL);
+  g_return_val_if_fail (RETRO_IS_CORE (self), 0UL);
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
 
@@ -1003,7 +1509,7 @@ retro_core_get_memory_size (RetroCore       *self,
 guint8 *
 retro_core_get_memory (RetroCore       *self,
                        RetroMemoryType  id,
-                       gint            *length)
+                       gsize           *length)
 {
   RetroCoreEnvironmentInternal *internal;
   RetroGetMemoryData get_mem_data;
@@ -1011,7 +1517,7 @@ retro_core_get_memory (RetroCore       *self,
   guint8 *data;
   gsize size;
 
-  g_return_val_if_fail (self != NULL, NULL);
+  g_return_val_if_fail (RETRO_IS_CORE (self), NULL);
   g_return_val_if_fail (length != NULL, NULL);
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
@@ -1034,7 +1540,7 @@ void
 retro_core_set_memory (RetroCore       *self,
                        RetroMemoryType  id,
                        guint8          *data,
-                       gint             length)
+                       gsize            length)
 {
   RetroCoreEnvironmentInternal *internal;
   RetroGetMemoryData get_mem_region;
@@ -1042,7 +1548,7 @@ retro_core_set_memory (RetroCore       *self,
   guint8 *memory_region;
   gsize memory_region_size;
 
-  g_return_if_fail (self != NULL);
+  g_return_if_fail (RETRO_IS_CORE (self));
   g_return_if_fail (data != NULL);
   g_return_if_fail (length > 0);
 
@@ -1060,8 +1566,9 @@ retro_core_set_memory (RetroCore       *self,
   g_return_if_fail (memory_region_size >= length);
 
   if (memory_region_size != length)
-    g_debug ("%s expects %"G_GSIZE_FORMAT" bytes for memory region %d: %d bytes"
-             " were passed. The excess will be filled with zeros.",
+    g_debug ("%s expects %"G_GSIZE_FORMAT" bytes for memory region %d: %"
+             G_GSIZE_FORMAT" bytes were passed. The excess will be filled with"
+             "zeros.",
              retro_core_get_name (self),
              memory_region_size,
              id,
@@ -1163,7 +1670,7 @@ void
 retro_core_set_keyboard (RetroCore *self,
                          GtkWidget *widget)
 {
-  g_return_if_fail (self != NULL);
+  g_return_if_fail (RETRO_IS_CORE (self));
 
   if (self->keyboard_widget != NULL) {
     g_signal_handler_disconnect (G_OBJECT (self->keyboard_widget), self->key_press_event_id);
@@ -1213,3 +1720,39 @@ retro_core_iterate_controllers (RetroCore *self)
 
   return retro_controller_iterator_new (internal->controllers);
 }
+
+RetroCore *
+retro_core_new (const gchar *file_name)
+{
+  RetroCore *self;
+  GFile *file;
+  GFile *relative_path_file;
+  gchar *libretro_path;
+
+  g_return_val_if_fail (file_name != NULL, NULL);
+
+  self = g_object_new (RETRO_TYPE_CORE, NULL);
+
+  retro_core_set_file_name (self, file_name);
+
+  file = g_file_new_for_path (file_name);
+  relative_path_file = g_file_resolve_relative_path (file, "");
+
+  g_object_unref (file);
+
+  libretro_path = g_file_get_path (relative_path_file);
+
+  g_object_unref (relative_path_file);
+
+  retro_core_set_libretro_path (self, libretro_path);
+  self->module = retro_module_new (libretro_path);
+
+  g_free (libretro_path);
+
+  retro_core_set_callbacks (self);
+  self->controllers = g_hash_table_new_full (g_int_hash, g_int_equal,
+                                             g_free, g_object_unref);
+  self->options = retro_options_new ();
+
+  return self;
+}
diff --git a/retro-gtk/retro-core.h b/retro-gtk/retro-core.h
new file mode 100644
index 0000000..98bb1b0
--- /dev/null
+++ b/retro-gtk/retro-core.h
@@ -0,0 +1,91 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#ifndef RETRO_CORE_H
+#define RETRO_CORE_H
+
+#if !defined(__RETRO_GTK_INSIDE__) && !defined(RETRO_GTK_COMPILATION)
+# error "Only <retro-gtk.h> can be included directly."
+#endif
+
+#include <gtk/gtk.h>
+#include "retro-controller-iterator.h"
+#include "retro-device-type.h"
+#include "retro-input-descriptor.h"
+#include "retro-input-device.h"
+#include "retro-memory-type.h"
+
+G_BEGIN_DECLS
+
+#define RETRO_TYPE_CORE (retro_core_get_type())
+
+G_DECLARE_FINAL_TYPE (RetroCore, retro_core, RETRO, CORE, GObject)
+
+RetroCore *retro_core_new (const gchar *file_name);
+guint retro_core_get_api_version (RetroCore *self);
+const gchar *retro_core_get_file_name (RetroCore *self);
+const gchar *retro_core_get_system_directory (RetroCore *self);
+void retro_core_set_system_directory (RetroCore *self, const gchar* value);
+const gchar *retro_core_get_libretro_path (RetroCore *self);
+void retro_core_set_libretro_path (RetroCore   *self,
+                                   const gchar *value);
+const gchar *retro_core_get_content_directory (RetroCore *self);
+void retro_core_set_content_directory (RetroCore   *self,
+                                       const gchar *value);
+const gchar *retro_core_get_save_directory (RetroCore *self);
+void retro_core_set_save_directory (RetroCore   *self,
+                                    const gchar *value);
+gboolean retro_core_get_is_initiated (RetroCore *self);
+gboolean retro_core_get_game_loaded (RetroCore *self);
+gboolean retro_core_get_support_no_game (RetroCore *self);
+gdouble retro_core_get_frames_per_second (RetroCore *self);
+void retro_core_boot (RetroCore  *self,
+                      GError    **error);
+void retro_core_set_medias (RetroCore    *self,
+                            const gchar **uris);
+void retro_core_set_current_media (RetroCore  *self,
+                                   guint       media_index,
+                                   GError    **error);
+void retro_core_set_controller_port_device (RetroCore       *self,
+                                            guint            port,
+                                            RetroDeviceType  device);
+void retro_core_reset (RetroCore *self);
+void retro_core_run (RetroCore *self);
+gboolean retro_core_supports_serialization (RetroCore *self);
+guint8 *retro_core_serialize_state (RetroCore  *self,
+                                    gsize      *length,
+                                    GError    **error);
+void retro_core_deserialize_state (RetroCore  *self,
+                                   guint8     *data,
+                                   gsize       length,
+                                   GError    **error);
+gsize retro_core_get_memory_size (RetroCore       *self,
+                                  RetroMemoryType  id);
+guint8 *retro_core_get_memory (RetroCore       *self,
+                              RetroMemoryType  id,
+                              gsize           *length);
+void retro_core_set_memory (RetroCore       *self,
+                            RetroMemoryType  id,
+                            guint8          *data,
+                            gsize            length);
+void retro_core_poll_controllers (RetroCore *self);
+gint16 retro_core_get_controller_input_state (RetroCore       *self,
+                                              uint             port,
+                                              RetroDeviceType  device,
+                                              guint            index,
+                                              guint            id);
+void retro_core_set_controller_descriptors (RetroCore            *self,
+                                            RetroInputDescriptor *input_descriptors,
+                                            gsize                 length);
+guint64 retro_core_get_controller_capabilities (RetroCore *self);
+void retro_core_set_controller (RetroCore        *self,
+                                guint             port,
+                                RetroInputDevice *device);
+void retro_core_set_keyboard (RetroCore *self,
+                              GtkWidget *widget);
+void retro_core_remove_controller (RetroCore *self,
+                                   guint      port);
+RetroControllerIterator *retro_core_iterate_controllers (RetroCore *self);
+
+G_END_DECLS
+
+#endif /* RETRO_CORE_H */
diff --git a/retro-gtk/retro-environment.c b/retro-gtk/retro-environment.c
index 0cf5a98..8572480 100644
--- a/retro-gtk/retro-environment.c
+++ b/retro-gtk/retro-environment.c
@@ -586,8 +586,8 @@ retro_core_set_system_av_info (RetroCore         *self,
 
   internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
 
-  if (self->_frames_per_second != system_av_info->timing.fps) {
-    self->_frames_per_second = system_av_info->timing.fps;
+  if (self->frames_per_second != system_av_info->timing.fps) {
+    self->frames_per_second = system_av_info->timing.fps;
     g_object_notify (G_OBJECT (self), "frames-per-second");
   }
   if (system_av_info->geometry.aspect_ratio > 0.f)
diff --git a/retro-gtk/retro-gtk.h b/retro-gtk/retro-gtk.h
index c16e249..ff88830 100644
--- a/retro-gtk/retro-gtk.h
+++ b/retro-gtk/retro-gtk.h
@@ -11,6 +11,7 @@
 
 #include "retro-analog-id.h"
 #include "retro-analog-index.h"
+#include "retro-core.h"
 #include "retro-core-view.h"
 #include "retro-device-type.h"
 #include "retro-gtk-vala.h"
diff --git a/retro-gtk/retro-log.c b/retro-gtk/retro-log.c
index 3b14fef..53043a3 100644
--- a/retro-gtk/retro-log.c
+++ b/retro-gtk/retro-log.c
@@ -1,6 +1,6 @@
 // This file is part of retro-gtk. License: GPL-3.0+.
 
-#include "retro-gtk-internal.h"
+#include "retro-core.h"
 
 void
 retro_g_log (RetroCore      *self,
diff --git a/retro-gtk/retro-log.h b/retro-gtk/retro-log.h
index 69b2377..d96465d 100644
--- a/retro-gtk/retro-log.h
+++ b/retro-gtk/retro-log.h
@@ -8,12 +8,10 @@
 #endif
 
 #include <glib-object.h>
+#include "retro-core.h"
 
 G_BEGIN_DECLS
 
-// FIXME Remove as soon as possible.
-typedef struct _RetroCore RetroCore;
-
 void retro_g_log (RetroCore      *self,
                   const gchar    *log_domain,
                   GLogLevelFlags  log_level,
diff --git a/retro-gtk/retro-main-loop.h b/retro-gtk/retro-main-loop.h
index ccf858f..4418adb 100644
--- a/retro-gtk/retro-main-loop.h
+++ b/retro-gtk/retro-main-loop.h
@@ -7,13 +7,10 @@
 # error "Only <retro-gtk.h> can be included directly."
 #endif
 
-#include <glib-object.h>
+#include "retro-core.h"
 
 G_BEGIN_DECLS
 
-// FIXME Remove as soon as possible.
-typedef struct _RetroCore RetroCore;
-
 #define RETRO_TYPE_MAIN_LOOP (retro_main_loop_get_type())
 
 G_DECLARE_FINAL_TYPE (RetroMainLoop, retro_main_loop, RETRO, MAIN_LOOP, GObject)
diff --git a/retro-gtk/retro-module.h b/retro-gtk/retro-module.h
index e148890..8c9ba26 100644
--- a/retro-gtk/retro-module.h
+++ b/retro-gtk/retro-module.h
@@ -8,8 +8,9 @@
 #endif
 
 #include <glib-object.h>
-#include "retro-gtk-internal.h"
+#include "retro-device-type.h"
 #include "retro-game-info.h"
+#include "retro-memory-type.h"
 #include "retro-system-av-info.h"
 #include "retro-system-info.h"
 
diff --git a/retro-gtk/retro-rumble-effect.h b/retro-gtk/retro-rumble-effect.h
index 21a29a4..9df4dbc 100644
--- a/retro-gtk/retro-rumble-effect.h
+++ b/retro-gtk/retro-rumble-effect.h
@@ -12,7 +12,7 @@
 G_BEGIN_DECLS
 
 /**
- * RetroAnalogIndex:
+ * RetroRumbleEffect:
  * @RETRO_RUMBLE_EFFECT_STRONG: The strong rumble effect.
  * @RETRO_RUMBLE_EFFECT_WEAK: The weak rumble effect.
  *



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]