[retro-gtk] controller: Make the set_rumble_state() method virtual



commit b25de20aa83868ba51ca75fdf8d38ede8d749d7c
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Sun Nov 19 14:46:25 2017 +0100

    controller: Make the set_rumble_state() method virtual
    
    Also implement it in RetroCoreViewController.
    
    This allows implementations of this interface to handle the rumble
    requests from the cores.

 retro-gtk/retro-controller.c           |    8 ++++++--
 retro-gtk/retro-controller.h           |    3 +++
 retro-gtk/retro-core-view-controller.c |    9 +++++++++
 3 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/retro-gtk/retro-controller.c b/retro-gtk/retro-controller.c
index 12dd597..bd1eeec 100644
--- a/retro-gtk/retro-controller.c
+++ b/retro-gtk/retro-controller.c
@@ -142,9 +142,13 @@ retro_controller_set_rumble_state (RetroController   *self,
                                    RetroRumbleEffect  effect,
                                    guint16            strength)
 {
+  RetroControllerInterface *iface;
+
   g_return_val_if_fail (RETRO_IS_CONTROLLER (self), FALSE);
 
-  // TODO
+  iface = RETRO_CONTROLLER_GET_IFACE (self);
+
+  g_return_val_if_fail (iface->set_rumble_state != NULL, FALSE);
 
-  return FALSE;
+  return iface->set_rumble_state (self, effect, strength);
 }
diff --git a/retro-gtk/retro-controller.h b/retro-gtk/retro-controller.h
index cd2a95f..1122a72 100644
--- a/retro-gtk/retro-controller.h
+++ b/retro-gtk/retro-controller.h
@@ -26,6 +26,9 @@ struct _RetroControllerInterface
                              RetroInput      *input);
   RetroControllerType (*get_controller_type) (RetroController *self);
   guint64 (*get_capabilities) (RetroController *self);
+  gboolean (*set_rumble_state) (RetroController   *self,
+                                RetroRumbleEffect  effect,
+                                guint16            strength);
 };
 
 void retro_controller_poll (RetroController *self);
diff --git a/retro-gtk/retro-core-view-controller.c b/retro-gtk/retro-core-view-controller.c
index 565da17..4abd3bd 100644
--- a/retro-gtk/retro-core-view-controller.c
+++ b/retro-gtk/retro-core-view-controller.c
@@ -80,6 +80,14 @@ retro_core_view_controller_get_capabilities (RetroController *base)
   return result;
 }
 
+static gboolean
+retro_core_view_controller_set_rumble_state (RetroController   *self,
+                                             RetroRumbleEffect  effect,
+                                             guint16            strength)
+{
+  return FALSE;
+}
+
 static void
 retro_core_view_controller_finalize (GObject *object)
 {
@@ -110,6 +118,7 @@ retro_controller_interface_init (RetroControllerInterface *iface)
   iface->get_input_state =  retro_core_view_controller_get_input_state;
   iface->get_controller_type = retro_core_view_controller_get_controller_type;
   iface->get_capabilities = retro_core_view_controller_get_capabilities;
+  iface->set_rumble_state = retro_core_view_controller_set_rumble_state;
 }
 
 /* Public */


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