[retro-gtk] retro-gobject: Merge input commands into core commands



commit a067061775047a5261b639ac64e422c8cc50cb45
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Thu Jan 19 18:19:53 2017 +0100

    retro-gobject: Merge input commands into core commands
    
    This will help giving the core more power over how these commands are
    handled.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777489

 retro-gobject/retro-environment.c |   45 ++++++++++++++++++-------------------
 1 files changed, 22 insertions(+), 23 deletions(-)
---
diff --git a/retro-gobject/retro-environment.c b/retro-gobject/retro-environment.c
index 8702076..5b0a213 100644
--- a/retro-gobject/retro-environment.c
+++ b/retro-gobject/retro-environment.c
@@ -64,8 +64,14 @@ static gboolean get_content_directory (RetroCore *self, const gchar* *content_di
        return TRUE;
 }
 
-static gboolean get_input_device_capabilities (RetroInput *self, guint64 *capabilities) {
-       *capabilities = retro_input_get_device_capabilities (self);
+static gboolean get_input_device_capabilities (RetroCore *self, guint64 *capabilities) {
+       RetroInput *input;
+
+       input = retro_core_get_input_interface (self);
+
+       g_return_val_if_fail (input != NULL, FALSE);
+
+       *capabilities = retro_input_get_device_capabilities (input);
 
        return TRUE;
 }
@@ -139,10 +145,16 @@ static gboolean set_disk_control_interface (RetroCore *self, RetroDiskControlCal
        return TRUE;
 }
 
-static gboolean set_input_descriptors (RetroInput *self, RetroInputDescriptor *descriptors) {
+static gboolean set_input_descriptors (RetroCore *self, RetroInputDescriptor *descriptors) {
+       RetroInput *input;
        int length;
+
+       input = retro_core_get_input_interface (self);
+
+       g_return_val_if_fail (input != NULL, FALSE);
+
        for (length = 0 ; descriptors[length].description ; length++);
-       retro_input_set_descriptors (self, descriptors, length);
+       retro_input_set_descriptors (input, descriptors, length);
 
        return TRUE;
 }
@@ -216,6 +228,9 @@ static gboolean environment_core_command (RetroCore *self, unsigned cmd, gpointe
        case RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY:
                return get_content_directory (self, (const gchar* *) data);
 
+       case RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES:
+               return get_input_device_capabilities (self, (guint64 *) data);
+
        case RETRO_ENVIRONMENT_GET_LIBRETRO_PATH:
                return get_libretro_path (self, (const gchar* *) data);
 
@@ -231,6 +246,9 @@ static gboolean environment_core_command (RetroCore *self, unsigned cmd, gpointe
        case RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE:
                set_disk_control_interface (self, (RetroDiskControlCallback *) data);
 
+       case RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS:
+               return set_input_descriptors (self, (RetroInputDescriptor *) data);
+
        case RETRO_ENVIRONMENT_SET_MESSAGE:
                return set_message (self, (RetroMessage *) data);
 
@@ -266,22 +284,6 @@ static gboolean environment_core_command (RetroCore *self, unsigned cmd, gpointe
        }
 }
 
-static gboolean environment_input_command (RetroInput *self, unsigned cmd, gpointer data) {
-       if (!self)
-               return FALSE;
-
-       switch (cmd) {
-       case RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES:
-               return get_input_device_capabilities (self, (guint64 *) data);
-
-       case RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS:
-               return set_input_descriptors (self, (RetroInputDescriptor *) data);
-
-       default:
-               return FALSE;
-       }
-}
-
 static gboolean environment_variables_command (RetroVariables *self, unsigned cmd, gpointer data) {
        if (!self) return FALSE;
 
@@ -326,9 +328,6 @@ gpointer retro_core_get_module_environment_interface (RetroCore *self) {
 
                if (!cb_data) g_assert_not_reached ();
 
-               if (environment_input_command (retro_core_get_input_interface (cb_data), cmd, data))
-                       return TRUE;
-
                if (environment_variables_command (retro_core_get_variables_interface (cb_data), cmd, data))
                        return TRUE;
 


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