[retro-gtk/wip/aplazas/0.13: 14/25] Port InputDescriptor to C



commit 8005a7d3bcb2dd8872badce4acfd11ac2176aee6
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Tue Sep 5 15:55:10 2017 +0200

    Port InputDescriptor to C

 retro-gtk/Makefile.am              |    3 +-
 retro-gtk/input/device.vala        |   18 ---------------
 retro-gtk/retro-gtk.h              |    1 +
 retro-gtk/retro-input-descriptor.c |   42 ++++++++++++++++++++++++++++++++++++
 retro-gtk/retro-input-descriptor.h |   32 +++++++++++++++++++++++++++
 retro-gtk/vapi/retro-gtk-c.vapi    |    9 +++++++
 6 files changed, 86 insertions(+), 19 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index f5e8f7e..77e845b 100644
--- a/retro-gtk/Makefile.am
+++ b/retro-gtk/Makefile.am
@@ -30,7 +30,6 @@ libretro_gtk_la_SOURCES = \
        audio/pa-player.vala \
        \
        input/controller.vala \
-       input/device.vala \
        input/input.vala \
        input/input-device.vala \
        input/input-device-manager.vala \
@@ -51,6 +50,7 @@ libretro_gtk_la_SOURCES = \
        retro-core-view-extern.c \
        retro-core-view-input-device.c \
        retro-game-info.c \
+       retro-input-descriptor.c \
        retro-log.c \
        retro-module.c \
        retro-module-query.vala \
@@ -111,6 +111,7 @@ retro_gtkinclude_HEADERS = \
        retro-device-type.h \
        retro-gtk.h \
        retro-gtk-vala.h \
+       retro-input-descriptor.h \
        retro-joypad-id.h \
        retro-lightgun-id.h \
        retro-mouse-id.h \
diff --git a/retro-gtk/retro-gtk.h b/retro-gtk/retro-gtk.h
index 1f44cb2..e0e7ed7 100644
--- a/retro-gtk/retro-gtk.h
+++ b/retro-gtk/retro-gtk.h
@@ -7,6 +7,7 @@
 #include "retro-analog-index.h"
 #include "retro-device-type.h"
 #include "retro-gtk-vala.h"
+#include "retro-input-descriptor.h"
 #include "retro-joypad-id.h"
 #include "retro-lightgun-id.h"
 #include "retro-mouse-id.h"
diff --git a/retro-gtk/retro-input-descriptor.c b/retro-gtk/retro-input-descriptor.c
new file mode 100644
index 0000000..0d1386a
--- /dev/null
+++ b/retro-gtk/retro-input-descriptor.c
@@ -0,0 +1,42 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#include "retro-input-descriptor.h"
+
+G_DEFINE_BOXED_TYPE (RetroInputDescriptor, retro_input_descriptor, retro_input_descriptor_copy, 
retro_input_descriptor_free)
+
+RetroInputDescriptor *
+retro_input_descriptor_new (void)
+{
+  RetroInputDescriptor *self;
+
+  self = g_slice_new0 (RetroInputDescriptor);
+
+  return self;
+}
+
+RetroInputDescriptor *
+retro_input_descriptor_copy (RetroInputDescriptor *self)
+{
+  RetroInputDescriptor *copy;
+
+  g_return_val_if_fail (self, NULL);
+
+  copy = retro_input_descriptor_new ();
+  copy->port = self->port;
+  copy->device = self->device;
+  copy->index = self->index;
+  copy->id = self->id;
+  copy->description = g_strdup (self->description);
+
+  return copy;
+}
+
+void
+retro_input_descriptor_free (RetroInputDescriptor *self)
+{
+  g_return_if_fail (self);
+
+  g_free (self->description);
+
+  g_slice_free (RetroInputDescriptor, self);
+}
diff --git a/retro-gtk/retro-input-descriptor.h b/retro-gtk/retro-input-descriptor.h
new file mode 100644
index 0000000..2f4ed00
--- /dev/null
+++ b/retro-gtk/retro-input-descriptor.h
@@ -0,0 +1,32 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#ifndef RETRO_INPUT_DESCRIPTOR_H
+#define RETRO_INPUT_DESCRIPTOR_H
+
+#include <glib-object.h>
+#include "retro-device-type.h"
+
+G_BEGIN_DECLS
+
+#define RETRO_TYPE_INPUT_DESCRIPTOR (retro_input_descriptor_get_type())
+
+typedef struct _RetroInputDescriptor RetroInputDescriptor;
+
+struct _RetroInputDescriptor
+{
+  guint port;
+  RetroDeviceType device;
+  guint index;
+  guint id;
+  gchar *description;
+};
+
+RetroInputDescriptor     *retro_input_descriptor_new   (void);
+RetroInputDescriptor     *retro_input_descriptor_copy  (RetroInputDescriptor *self);
+void                      retro_input_descriptor_free  (RetroInputDescriptor *self);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (RetroInputDescriptor, retro_input_descriptor_free)
+
+G_END_DECLS
+
+#endif /* RETRO_INPUT_DESCRIPTOR_H */
diff --git a/retro-gtk/vapi/retro-gtk-c.vapi b/retro-gtk/vapi/retro-gtk-c.vapi
index 208723a..ff5a3d5 100644
--- a/retro-gtk/vapi/retro-gtk-c.vapi
+++ b/retro-gtk/vapi/retro-gtk-c.vapi
@@ -11,3 +11,12 @@ public enum Retro.DeviceType {
        ANALOG = 5,
        POINTER = 6,
 }
+
+[CCode (cheader_filename = "retro-input-descriptor.h")]
+public struct Retro.InputDescriptor {
+       uint port;
+       DeviceType device;
+       uint index;
+       uint id;
+       string description;
+}


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