[retro-gtk/wip/aplazas/master: 3/10] Port AnalogIndex to C



commit 329c056a05259e7c3945d36451b1b175c03788a8
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Tue Sep 5 14:37:31 2017 +0200

    Port AnalogIndex to C

 retro-gtk/Makefile.am          |    2 ++
 retro-gtk/input/device.vala    |    8 --------
 retro-gtk/retro-analog-index.c |   24 ++++++++++++++++++++++++
 retro-gtk/retro-analog-index.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 589dee8..3409f99 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-index.h \
        retro-device-type.h \
        retro-gtk.h \
        retro-gtk-vala.h \
@@ -68,6 +69,7 @@ libretro_gtk_la_SOURCES = \
        core-error.vala \
        memory.vala \
        retro.vala \
+       retro-analog-index.c \
        retro-core-descriptor.vala \
        retro-core-descriptor-error.vala \
        retro-core-view.vala \
diff --git a/retro-gtk/input/device.vala b/retro-gtk/input/device.vala
index 180630b..c94dac8 100644
--- a/retro-gtk/input/device.vala
+++ b/retro-gtk/input/device.vala
@@ -3,14 +3,6 @@
 namespace Retro {
 
 /**
- * The analog sticks of an analog joypad.
- */
-public enum AnalogIndex {
-       LEFT,
-       RIGHT
-}
-
-/**
  * The axes of an analog stick.
  */
 public enum AnalogId {
diff --git a/retro-gtk/retro-analog-index.c b/retro-gtk/retro-analog-index.c
new file mode 100644
index 0000000..42680ef
--- /dev/null
+++ b/retro-gtk/retro-analog-index.c
@@ -0,0 +1,24 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#include "retro-analog-index.h"
+
+GType
+retro_analog_index_get_type (void)
+{
+  static volatile gsize retro_analog_index_type = 0;
+
+  if (g_once_init_enter (&retro_analog_index_type)) {
+    static const GEnumValue values[] = {
+      { RETRO_ANALOG_INDEX_LEFT, "RETRO_ANALOG_INDEX_LEFT", "left" },
+      { RETRO_ANALOG_INDEX_RIGHT, "RETRO_ANALOG_INDEX_RIGHT", "right" },
+      { 0, NULL, NULL },
+    };
+    GType type;
+
+    type = g_enum_register_static ("RetroAnalogIndex", values);
+
+    g_once_init_leave (&retro_analog_index_type, type);
+  }
+
+  return retro_analog_index_type;
+}
diff --git a/retro-gtk/retro-analog-index.h b/retro-gtk/retro-analog-index.h
new file mode 100644
index 0000000..64f66ef
--- /dev/null
+++ b/retro-gtk/retro-analog-index.h
@@ -0,0 +1,33 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#ifndef RETRO_ANALOG_INDEX_H
+#define RETRO_ANALOG_INDEX_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_INDEX (retro_analog_index_get_type ())
+
+GType retro_analog_index_get_type (void) G_GNUC_CONST;
+
+/**
+ * RetroAnalogIndex:
+ * @RETRO_ANALOG_INDEX_LEFT: the left analog stick
+ * @RETRO_ANALOG_INDEX_RIGHT: the right analog stick
+ *
+ * Represents the analog sticks for the Libretro gamepad.
+ */
+typedef enum
+{
+  RETRO_ANALOG_INDEX_LEFT,
+  RETRO_ANALOG_INDEX_RIGHT,
+} RetroAnalogIndex;
+
+G_END_DECLS
+
+#endif /* RETRO_ANALOG_INDEX_H */
diff --git a/retro-gtk/retro-gtk.h b/retro-gtk/retro-gtk.h
index 2be93f4..970f1f2 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-index.h"
 #include "retro-device-type.h"
 #include "retro-gtk-vala.h"
 #include "retro-joypad-id.h"


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