[retro-gtk/wip/aplazas/c-port: 6/34] Port AnalogId to C



commit cd5c65d3d6a3d5455455a8752b65c9d8bcf4f5d8
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Tue Sep 5 14:40:23 2017 +0200

    Port AnalogId to C

 retro-gtk/Makefile.am       |    2 ++
 retro-gtk/input/device.vala |    8 --------
 retro-gtk/retro-analog-id.c |   24 ++++++++++++++++++++++++
 retro-gtk/retro-analog-id.h |   33 +++++++++++++++++++++++++++++++++
 retro-gtk/retro-gtk.h       |    1 +
 5 files changed, 60 insertions(+), 8 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index 3409f99..cd9d251 100644
--- a/retro-gtk/Makefile.am
+++ b/retro-gtk/Makefile.am
@@ -30,6 +30,7 @@ dist_vapi_DATA = retro-gtk-0.12.deps
 BUILT_SOURCES = retro-gtk-internal.h
 
 retro_gtk_public_h_sources = \
+       retro-analog-id.h \
        retro-analog-index.h \
        retro-device-type.h \
        retro-gtk.h \
@@ -69,6 +70,7 @@ libretro_gtk_la_SOURCES = \
        core-error.vala \
        memory.vala \
        retro.vala \
+       retro-analog-id.c \
        retro-analog-index.c \
        retro-core-descriptor.vala \
        retro-core-descriptor-error.vala \
diff --git a/retro-gtk/input/device.vala b/retro-gtk/input/device.vala
index c94dac8..bc98db7 100644
--- a/retro-gtk/input/device.vala
+++ b/retro-gtk/input/device.vala
@@ -3,14 +3,6 @@
 namespace Retro {
 
 /**
- * The axes of an analog stick.
- */
-public enum AnalogId {
-       X,
-       Y
-}
-
-/**
  * The input types of a mouse.
  */
 private enum MouseId {
diff --git a/retro-gtk/retro-analog-id.c b/retro-gtk/retro-analog-id.c
new file mode 100644
index 0000000..283feee
--- /dev/null
+++ b/retro-gtk/retro-analog-id.c
@@ -0,0 +1,24 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#include "retro-analog-id.h"
+
+GType
+retro_analog_id_get_type (void)
+{
+  static volatile gsize retro_analog_id_type = 0;
+
+  if (g_once_init_enter (&retro_analog_id_type)) {
+    static const GEnumValue values[] = {
+      { RETRO_ANALOG_ID_X, "RETRO_ANALOG_ID_X", "x" },
+      { RETRO_ANALOG_ID_Y, "RETRO_ANALOG_ID_Y", "y" },
+      { 0, NULL, NULL },
+    };
+    GType type;
+
+    type = g_enum_register_static ("RetroAnalogId", values);
+
+    g_once_init_leave (&retro_analog_id_type, type);
+  }
+
+  return retro_analog_id_type;
+}
diff --git a/retro-gtk/retro-analog-id.h b/retro-gtk/retro-analog-id.h
new file mode 100644
index 0000000..a41e8cc
--- /dev/null
+++ b/retro-gtk/retro-analog-id.h
@@ -0,0 +1,33 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#ifndef RETRO_ANALOG_ID_H
+#define RETRO_ANALOG_ID_H
+
+#if !defined(__RETRO_GTK_INSIDE__) && !defined(RETRO_GTK_COMPILATION)
+# error "Only <retro-gtk.h> can be included directly."
+#endif
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define RETRO_TYPE_ANALOG_ID (retro_analog_id_get_type ())
+
+GType retro_analog_id_get_type (void) G_GNUC_CONST;
+
+/**
+ * RetroAnalogId:
+ * @RETRO_ANALOG_ID_X: the X axis of an analog stick
+ * @RETRO_ANALOG_ID_Y: the Y axis of an analog stick
+ *
+ * Represents the axes of the analog sticks for the Libretro gamepad.
+ */
+typedef enum
+{
+  RETRO_ANALOG_ID_X,
+  RETRO_ANALOG_ID_Y,
+} RetroAnalogId;
+
+G_END_DECLS
+
+#endif /* RETRO_ANALOG_ID_H */
diff --git a/retro-gtk/retro-gtk.h b/retro-gtk/retro-gtk.h
index 970f1f2..be8b24f 100644
--- a/retro-gtk/retro-gtk.h
+++ b/retro-gtk/retro-gtk.h
@@ -9,6 +9,7 @@
 #error    retro-gtk is unstable API. You must define RETRO_GTK_USE_UNSTABLE_API before including retro-gtk.h
 #endif
 
+#include "retro-analog-id.h"
 #include "retro-analog-index.h"
 #include "retro-device-type.h"
 #include "retro-gtk-vala.h"


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