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



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

    Port InputDescriptor to C

 retro-gtk/Makefile.am                              |    6 ++-
 retro-gtk/retro-input-descriptor.c                 |   42 ++++++++++++++++++++
 retro-gtk/retro-input-descriptor.h                 |   32 +++++++++++++++
 .../retro-input-descriptor.vapi}                   |   12 +-----
 4 files changed, 81 insertions(+), 11 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index fe13c6f..3bb6e6b 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 \
@@ -86,6 +86,7 @@ libretro_gtk_la_VALAFLAGS = \
        --pkg cairo \
        --pkg config \
        --pkg retro-device-type \
+       --pkg retro-input-descriptor \
        --pkg gio-2.0  \
        --pkg glib-2.0 \
        --pkg gmodule-2.0 \
@@ -110,6 +111,7 @@ retro_gtkinclude_HEADERS = \
        retro-analog-index.h \
        retro-device-type.h \
        retro-gtk.h \
+       retro-input-descriptor.h \
        retro-joypad-id.h \
        retro-lightgun-id.h \
        retro-mouse-id.h \
@@ -146,6 +148,7 @@ Retro_0_12_gir_SCANNERFLAGS = \
        --c-include=retro-analog-id.h \
        --c-include=retro-analog-index.h \
        --c-include=retro-device-type.h \
+       --c-include=retro-input-descriptor.h \
        --c-include=retro-joypad-id.h \
        --c-include=retro-lightgun-id.h \
        --c-include=retro-mouse-id.h \
@@ -196,6 +199,7 @@ EXTRA_DIST = \
        retro-gtk-0.12.pc.in \
        update-from-retroarch.sh \
        vapi/retro-device-type.vapi \
+       vapi/retro-input-descriptor.vapi \
        $(NULL)
 
 INPUTDIR=$(top_srcdir)/../RetroArch/libretro-common/include/
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/input/device.vala b/retro-gtk/vapi/retro-input-descriptor.vapi
similarity index 58%
rename from retro-gtk/input/device.vala
rename to retro-gtk/vapi/retro-input-descriptor.vapi
index 9bcf1bf..61c4365 100644
--- a/retro-gtk/input/device.vala
+++ b/retro-gtk/vapi/retro-input-descriptor.vapi
@@ -1,18 +1,10 @@
 // This file is part of retro-gtk. License: GPL-3.0+.
 
-namespace Retro {
-
-/**
- * Describes an input source.
- */
-public struct InputDescriptor {
+[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]