[retro-gtk] core: Move Core.init_input() to C
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk] core: Move Core.init_input() to C
- Date: Fri, 7 Jul 2017 09:06:22 +0000 (UTC)
commit 5541e583339c6eeb150de00c9ec71fba7da17fcd
Author: Adrien Plazas <kekun plazas laposte net>
Date: Thu Jul 6 10:36:22 2017 +0200
core: Move Core.init_input() to C
Also move Core.Core.init_controller_device() to C.
This help porting the library to C.
https://bugzilla.gnome.org/show_bug.cgi?id=777489
retro-gtk/core.vala | 13 +------------
retro-gtk/retro-core.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 12 deletions(-)
---
diff --git a/retro-gtk/core.vala b/retro-gtk/core.vala
index 8ecf4c0..c0b875b 100644
--- a/retro-gtk/core.vala
+++ b/retro-gtk/core.vala
@@ -375,18 +375,7 @@ public class Core : Object {
*/
public extern void set_memory (MemoryType id, uint8[] data);
- private void init_input () {
- if (input_interface == null)
- return;
-
- input_interface.foreach_controller (init_controller_device);
- }
-
- private void init_controller_device (uint port, InputDevice device) {
- var device_type = device.get_device_type ();
- set_controller_port_device (port, device_type);
- }
-
+ 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);
private extern void on_input_key_event (bool down, KeyboardKey keycode, uint32 character,
KeyboardModifierKey key_modifiers);
diff --git a/retro-gtk/retro-core.c b/retro-gtk/retro-core.c
index 392ea7d..ff691d2 100644
--- a/retro-gtk/retro-core.c
+++ b/retro-gtk/retro-core.c
@@ -6,6 +6,38 @@
/* Private */
+static void
+init_controller_device (guint port,
+ RetroInputDevice *device,
+ gpointer data)
+{
+ RetroCore *self;
+ RetroDeviceType device_type;
+
+ self = RETRO_CORE (data);
+
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (device != NULL);
+
+ device_type = retro_input_device_get_device_type (device);
+ retro_core_set_controller_port_device (self, port, device_type);
+}
+
+// FIXME Make static as soon as possible.
+void
+retro_core_init_input (RetroCore* self)
+{
+ RetroInput* input_interface;
+
+ g_return_if_fail (self != NULL);
+
+ input_interface = retro_core_get_input_interface (self);
+ if (input_interface == NULL)
+ return;
+
+ retro_input_foreach_controller (input_interface, init_controller_device, self);
+}
+
// FIXME Make static as soon as possible.
void
retro_core_on_input_controller_connected (RetroCore *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]