[retro-gtk] core: Drop the remove_controller() method
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk] core: Drop the remove_controller() method
- Date: Thu, 2 Nov 2017 11:04:18 +0000 (UTC)
commit e27c64c574cb678eb1f0fd8e21e5289b7ae75a5a
Author: Adrien Plazas <kekun plazas laposte net>
Date: Mon Oct 30 14:01:25 2017 +0100
core: Drop the remove_controller() method
Instead, NULL must be passed to set_controller() to remove it. This
makes the API smaller and simpler.
retro-gtk/retro-core.c | 75 ++++++++++++-----------------------------------
retro-gtk/retro-core.h | 2 -
2 files changed, 19 insertions(+), 58 deletions(-)
---
diff --git a/retro-gtk/retro-core.c b/retro-gtk/retro-core.c
index b9fdfc5..ac12e43 100644
--- a/retro-gtk/retro-core.c
+++ b/retro-gtk/retro-core.c
@@ -588,35 +588,6 @@ retro_core_get_name (RetroCore *self)
}
static void
-retro_core_controller_connected (RetroCore *self,
- guint port,
- RetroController *controller)
-{
- RetroControllerType controller_type;
-
- g_return_if_fail (RETRO_IS_CORE (self));
- g_return_if_fail (controller != NULL);
-
- if (!retro_core_get_is_initiated (self))
- return;
-
- controller_type = retro_controller_get_controller_type (controller);
- retro_core_set_controller_port_device (self, port, controller_type);
-}
-
-static void
-retro_core_controller_disconnected (RetroCore *self,
- guint port)
-{
- g_return_if_fail (RETRO_IS_CORE (self));
-
- if (!retro_core_get_is_initiated (self))
- return;
-
- retro_core_set_controller_port_device (self, port, RETRO_CONTROLLER_TYPE_NONE);
-}
-
-static void
retro_core_send_input_key_event (RetroCore *self,
gboolean down,
RetroKeyboardKey keycode,
@@ -1837,16 +1808,27 @@ retro_core_set_controller (RetroCore *self,
RetroController *controller)
{
guint *port_copy;
+ RetroControllerType controller_type;
g_return_if_fail (RETRO_IS_CORE (self));
- g_return_if_fail (RETRO_IS_CONTROLLER (controller));
-
- port_copy = g_new (guint, 1);
- *port_copy = port;
- g_hash_table_insert (self->controllers,
- port_copy,
- g_object_ref (controller));
- retro_core_controller_connected (self, port, controller);
+
+ if (RETRO_IS_CONTROLLER (controller)) {
+ port_copy = g_new (guint, 1);
+ *port_copy = port;
+ g_hash_table_insert (self->controllers,
+ port_copy,
+ g_object_ref (controller));
+ controller_type = retro_controller_get_controller_type (controller);
+ }
+ else {
+ g_hash_table_remove (self->controllers, &port);
+ controller_type = RETRO_CONTROLLER_TYPE_NONE;
+ }
+
+ if (!retro_core_get_is_initiated (self))
+ return;
+
+ retro_core_set_controller_port_device (self, port, controller_type);
}
/**
@@ -1886,25 +1868,6 @@ retro_core_set_keyboard (RetroCore *self,
}
/**
- * retro_core_remove_controller:
- * @self: a #RetroCore
- * @port: the port number
- *
- * Removes the controller plugged into @self at port @port, if any.
- */
-void
-retro_core_remove_controller (RetroCore *self,
- guint port)
-{
-
- g_return_if_fail (RETRO_IS_CORE (self));
-
- // FIXME Do that only if a controller is plugged into that port.
- g_hash_table_remove (self->controllers, &port);
- retro_core_controller_disconnected (self, port);
-}
-
-/**
* retro_core_iterate_controllers:
* @self: a #RetroCore
*
diff --git a/retro-gtk/retro-core.h b/retro-gtk/retro-core.h
index 215ac09..5dac16a 100644
--- a/retro-gtk/retro-core.h
+++ b/retro-gtk/retro-core.h
@@ -62,8 +62,6 @@ void retro_core_set_controller (RetroCore *self,
RetroController *controller);
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]