[retro-gtk/to-c: 3/15] core: Move Core.set_controller_port_device() to C



commit b34483b0acc388b46d62f7ed2fbcbcb921c98540
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Thu Jul 6 10:20:15 2017 +0200

    core: Move Core.set_controller_port_device() to C
    
    This help porting the library to C.

 retro-gtk/core.vala    |   12 +-----------
 retro-gtk/retro-core.c |   15 +++++++++++++++
 retro-gtk/retro-core.h |    4 ++++
 3 files changed, 20 insertions(+), 11 deletions(-)
---
diff --git a/retro-gtk/core.vala b/retro-gtk/core.vala
index f8c5f4b..79ac16e 100644
--- a/retro-gtk/core.vala
+++ b/retro-gtk/core.vala
@@ -266,17 +266,7 @@ public class Core : Object {
                is_initiated = true;
        }
 
-       /**
-        * Sets device to be used for player 'port'.
-        *
-        * @param port the port on wich to connect a device
-        * @param device the type of the device connected
-        */
-       public void set_controller_port_device (uint port, DeviceType device) {
-               push_cb_data ();
-               module.set_controller_port_device (port, device);
-               pop_cb_data ();
-       }
+       public extern void set_controller_port_device (uint port, DeviceType device);
 
        /**
         * Resets the current game.
diff --git a/retro-gtk/retro-core.c b/retro-gtk/retro-core.c
index 594f048..9bdf4a1 100644
--- a/retro-gtk/retro-core.c
+++ b/retro-gtk/retro-core.c
@@ -45,6 +45,21 @@ retro_core_on_input_key_event (RetroCore                *self,
 
 /* Public */
 
+void
+retro_core_set_controller_port_device (RetroCore       *self,
+                                       guint            port,
+                                       RetroDeviceType  device)
+{
+  RetroSetControllerPortDevice set_controller_port_device;
+
+  g_return_if_fail (self != NULL);
+
+  retro_core_push_cb_data (self);
+  set_controller_port_device = retro_module_get_set_controller_port_device (self->module);
+  set_controller_port_device (port, device);
+  retro_core_pop_cb_data ();
+}
+
 gboolean
 retro_core_supports_serialization (RetroCore *self)
 {
diff --git a/retro-gtk/retro-core.h b/retro-gtk/retro-core.h
index 5f92ebd..2d38266 100644
--- a/retro-gtk/retro-core.h
+++ b/retro-gtk/retro-core.h
@@ -25,6 +25,10 @@ struct _RetroCoreEnvironmentInternal {
   RetroKeyboardCallback keyboard_callback;
 };
 
+void retro_core_set_controller_port_device (RetroCore       *self,
+                                            guint            port,
+                                            RetroDeviceType  device);
+
 G_END_DECLS
 
 #endif /* RETRO_CORE_H */


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