[retro-gtk/wip/aplazas/c-port: 10/36] Port InputDescriptor to C



commit 228254d202d53450e9db267ff450ad854cda82e7
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 |   36 ++++++++++++++++++++++++++++++
 retro-gtk/vapi/retro-gtk-c.vapi    |    9 +++++++
 6 files changed, 90 insertions(+), 19 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index 35ddbce..5184c8d 100644
--- a/retro-gtk/Makefile.am
+++ b/retro-gtk/Makefile.am
@@ -35,6 +35,7 @@ retro_gtk_public_h_sources = \
        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 \
@@ -61,7 +62,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 \
@@ -79,6 +79,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 \
diff --git a/retro-gtk/retro-gtk.h b/retro-gtk/retro-gtk.h
index dfb51db..1e4c59b 100644
--- a/retro-gtk/retro-gtk.h
+++ b/retro-gtk/retro-gtk.h
@@ -13,6 +13,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..66ee8c5
--- /dev/null
+++ b/retro-gtk/retro-input-descriptor.h
@@ -0,0 +1,36 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#ifndef RETRO_INPUT_DESCRIPTOR_H
+#define RETRO_INPUT_DESCRIPTOR_H
+
+#if !defined(__RETRO_GTK_INSIDE__) && !defined(RETRO_GTK_COMPILATION)
+# error "Only <retro-gtk.h> can be included directly."
+#endif
+
+#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]