[retro-gtk/wip/aplazas/c-port: 1/25] Port InputDescriptor to C
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk/wip/aplazas/c-port: 1/25] Port InputDescriptor to C
- Date: Tue, 10 Oct 2017 16:38:55 +0000 (UTC)
commit 4b8e8d7dbb11c2341c2b370db64cf1fe8db2284f
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-input-descriptor.c | 65 ++++++++++++++++++++++++++++++++++++
retro-gtk/retro-input-descriptor.h | 36 ++++++++++++++++++++
retro-gtk/vapi/retro-gtk-c.vapi | 9 +++++
5 files changed, 112 insertions(+), 19 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index cbdde48..2a50b6f 100644
--- a/retro-gtk/Makefile.am
+++ b/retro-gtk/Makefile.am
@@ -48,6 +48,7 @@ retro_gtk_private_h_sources = \
retro-core-view-input-device.h \
retro-disk-control-callback.h \
retro-game-info.h \
+ retro-input-descriptor.h \
retro-module.h \
retro-option.h \
retro-options.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 \
@@ -82,6 +82,7 @@ libretro_gtk_la_SOURCES = \
retro-core-view-input-device.c \
retro-device-type.c \
retro-game-info.c \
+ retro-input-descriptor.c \
retro-joypad-id.c \
retro-lightgun-id.c \
retro-log.c \
diff --git a/retro-gtk/retro-input-descriptor.c b/retro-gtk/retro-input-descriptor.c
new file mode 100644
index 0000000..f881fb8
--- /dev/null
+++ b/retro-gtk/retro-input-descriptor.c
@@ -0,0 +1,65 @@
+// 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)
+
+/**
+ * retro_input_descriptor_new:
+ *
+ * Creates a new #RetroInputDescriptor.
+ *
+ * Returns: (transfer full): a new #RetroInputDescriptor, use
+ * retro_input_descriptor_free() to free it
+ */
+RetroInputDescriptor *
+retro_input_descriptor_new (void)
+{
+ RetroInputDescriptor *self;
+
+ self = g_slice_new0 (RetroInputDescriptor);
+
+ return self;
+}
+
+/**
+ * retro_input_descriptor_copy:
+ * @self: a #RetroInputDescriptor
+ *
+ * Copies @self into a new #RetroInputDescriptor.
+ *
+ * Returns: (transfer full): a new #RetroInputDescriptor, use
+ * retro_input_descriptor_free() to free it
+ */
+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;
+}
+
+/**
+ * retro_input_descriptor_free:
+ * @self: a #RetroInputDescriptor
+ *
+ * Frees the given #RetroInputDescriptor object.
+ */
+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]