[retro-gtk/wip/aplazas/options: 2/2] core: Add option accessors



commit 7e24f34e3ab722369781a5cdf3ef630e9c1a6113
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Wed Sep 20 13:32:40 2017 +0200

    core: Add option accessors

 retro-gtk/core.vala    |    7 ++++
 retro-gtk/retro-core.c |   84 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 91 insertions(+), 0 deletions(-)
---
diff --git a/retro-gtk/core.vala b/retro-gtk/core.vala
index 3778337..4ef3c84 100644
--- a/retro-gtk/core.vala
+++ b/retro-gtk/core.vala
@@ -224,6 +224,13 @@ public class Core : Object {
         */
        public extern void set_memory (MemoryType id, uint8[] data);
 
+       public extern bool contains_option (string key);
+       public extern string get_option_value (string key);
+       public extern void set_option_value (string key, string value);
+       public extern string get_option_description (string key);
+       public extern string[] get_option_values (string key);
+       public extern List<weak string> get_option_keys ();
+
        private extern void init_input ();
        private extern void on_input_controller_connected (uint port, InputDevice device);
        private extern void on_input_controller_disconnected (uint port);
diff --git a/retro-gtk/retro-core.c b/retro-gtk/retro-core.c
index 5ff2763..63fbaca 100644
--- a/retro-gtk/retro-core.c
+++ b/retro-gtk/retro-core.c
@@ -1057,3 +1057,87 @@ retro_core_set_memory (RetroCore       *self,
   memcpy (memory_region, data, length);
   memset (memory_region + length, 0, memory_region_size - length);
 }
+
+gboolean
+retro_core_contains_option (RetroCore   *self,
+                            const gchar *key)
+{
+  RetroCoreEnvironmentInternal *internal;
+
+  g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
+  g_return_val_if_fail (key != NULL, FALSE);
+
+  internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
+
+  return retro_options_contains (internal->options, key);
+}
+
+const gchar *
+retro_core_get_option_value (RetroCore   *self,
+                             const gchar *key)
+{
+  RetroCoreEnvironmentInternal *internal;
+
+  g_return_val_if_fail (RETRO_IS_CORE (self), NULL);
+  g_return_val_if_fail (key != NULL, NULL);
+
+  internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
+
+  return retro_options_get_option_value (internal->options, key);
+}
+
+void
+retro_core_set_option_value (RetroCore   *self,
+                             const gchar *key,
+                             const gchar *value)
+{
+  RetroCoreEnvironmentInternal *internal;
+
+  g_return_if_fail (RETRO_IS_CORE (self));
+  g_return_if_fail (key != NULL);
+  g_return_if_fail (value != NULL);
+
+  internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
+
+  retro_options_set_option_value(internal->options, key, value);
+}
+
+const gchar *
+retro_core_get_option_description (RetroCore   *self,
+                                   const gchar *key)
+{
+  RetroCoreEnvironmentInternal *internal;
+
+  g_return_val_if_fail (RETRO_IS_CORE (self), NULL);
+  g_return_val_if_fail (key != NULL, NULL);
+
+  internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
+
+  return retro_options_get_option_description (internal->options, key);
+}
+
+const gchar **
+retro_core_get_option_values (RetroCore   *self,
+                              const gchar *key)
+{
+  RetroCoreEnvironmentInternal *internal;
+
+  g_return_val_if_fail (RETRO_IS_CORE (self), NULL);
+  g_return_val_if_fail (key != NULL, NULL);
+
+  internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
+
+  return retro_options_get_option_values (internal->options, key);
+}
+
+GList *
+retro_core_get_option_keys (RetroCore *self)
+{
+  RetroCoreEnvironmentInternal *internal;
+
+  g_return_val_if_fail (RETRO_IS_CORE (self), NULL);
+
+  internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
+
+  return retro_options_get_keys (internal->options);
+}


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