[retro-gtk/wip/aplazas/master: 6/10] Port LightgunId to C



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

    Port LightgunId to C

 retro-gtk/Makefile.am         |    2 +
 retro-gtk/input/device.vala   |   13 ------------
 retro-gtk/retro-gtk.h         |    1 +
 retro-gtk/retro-lightgun-id.c |   29 +++++++++++++++++++++++++++
 retro-gtk/retro-lightgun-id.h |   43 +++++++++++++++++++++++++++++++++++++++++
 5 files changed, 75 insertions(+), 13 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index aac475e..dbc8a58 100644
--- a/retro-gtk/Makefile.am
+++ b/retro-gtk/Makefile.am
@@ -36,6 +36,7 @@ retro_gtk_public_h_sources = \
        retro-gtk.h \
        retro-gtk-vala.h \
        retro-joypad-id.h \
+       retro-lightgun-id.h \
        retro-mouse-id.h \
        $(NULL)
 
@@ -81,6 +82,7 @@ libretro_gtk_la_SOURCES = \
        retro-device-type.c \
        retro-game-info.c \
        retro-joypad-id.c \
+       retro-lightgun-id.c \
        retro-log.c \
        retro-module.c \
        retro-module-query.vala \
diff --git a/retro-gtk/input/device.vala b/retro-gtk/input/device.vala
index a8165eb..04f6f3a 100644
--- a/retro-gtk/input/device.vala
+++ b/retro-gtk/input/device.vala
@@ -3,19 +3,6 @@
 namespace Retro {
 
 /**
- * The input types of a lightgun.
- */
-private enum LightgunId {
-       X,
-       Y,
-       TRIGGER,
-       CURSOR,
-       TURBO,
-       PAUSE,
-       START
-}
-
-/**
  * The input types of a pointer.
  */
 private enum PointerId {
diff --git a/retro-gtk/retro-gtk.h b/retro-gtk/retro-gtk.h
index 82b5ba9..78b13d2 100644
--- a/retro-gtk/retro-gtk.h
+++ b/retro-gtk/retro-gtk.h
@@ -14,6 +14,7 @@
 #include "retro-device-type.h"
 #include "retro-gtk-vala.h"
 #include "retro-joypad-id.h"
+#include "retro-lightgun-id.h"
 #include "retro-mouse-id.h"
 
 #undef __RETRO_GTK_INSIDE__
diff --git a/retro-gtk/retro-lightgun-id.c b/retro-gtk/retro-lightgun-id.c
new file mode 100644
index 0000000..8c3b48f
--- /dev/null
+++ b/retro-gtk/retro-lightgun-id.c
@@ -0,0 +1,29 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#include "retro-lightgun-id.h"
+
+GType
+retro_lightgun_id_get_type (void)
+{
+  static volatile gsize retro_lightgun_id_type = 0;
+
+  if (g_once_init_enter (&retro_lightgun_id_type)) {
+    static const GEnumValue values[] = {
+      { RETRO_LIGHTGUN_ID_X, "RETRO_LIGHTGUN_ID_X", "x" },
+      { RETRO_LIGHTGUN_ID_Y, "RETRO_LIGHTGUN_ID_Y", "y" },
+      { RETRO_LIGHTGUN_ID_TRIGGER, "RETRO_LIGHTGUN_ID_TRIGGER", "trigger" },
+      { RETRO_LIGHTGUN_ID_CURSOR, "RETRO_LIGHTGUN_ID_CURSOR", "cursor" },
+      { RETRO_LIGHTGUN_ID_TURBO, "RETRO_LIGHTGUN_ID_TURBO", "turbo" },
+      { RETRO_LIGHTGUN_ID_PAUSE, "RETRO_LIGHTGUN_ID_PAUSE", "pause" },
+      { RETRO_LIGHTGUN_ID_START, "RETRO_LIGHTGUN_ID_START", "start" },
+      { 0, NULL, NULL },
+    };
+    GType type;
+
+    type = g_enum_register_static ("RetroLightgunId", values);
+
+    g_once_init_leave (&retro_lightgun_id_type, type);
+  }
+
+  return retro_lightgun_id_type;
+}
diff --git a/retro-gtk/retro-lightgun-id.h b/retro-gtk/retro-lightgun-id.h
new file mode 100644
index 0000000..dea33c4
--- /dev/null
+++ b/retro-gtk/retro-lightgun-id.h
@@ -0,0 +1,43 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#ifndef RETRO_LIGHTGUN_ID_H
+#define RETRO_LIGHTGUN_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_LIGHTGUN_ID (retro_lightgun_id_get_type ())
+
+GType retro_lightgun_id_get_type (void) G_GNUC_CONST;
+
+/**
+ * RetroLightgunId:
+ * @RETRO_LIGHTGUN_ID_X: the X axis of a lightgun
+ * @RETRO_LIGHTGUN_ID_Y: the Y axis of a lightgun
+ * @RETRO_LIGHTGUN_ID_TRIGGER: the trigger of a lightgun
+ * @RETRO_LIGHTGUN_ID_CURSOR: the cursor of a lightgun
+ * @RETRO_LIGHTGUN_ID_TURBO: the turbo button of a lightgun
+ * @RETRO_LIGHTGUN_ID_PAUSE: the pause button of a lightgun
+ * @RETRO_LIGHTGUN_ID_START: the start button of a lightgun
+ *
+ * Represents the inputs for the Libretro lightgun.
+ */
+typedef enum
+{
+  RETRO_LIGHTGUN_ID_X,
+  RETRO_LIGHTGUN_ID_Y,
+  RETRO_LIGHTGUN_ID_TRIGGER,
+  RETRO_LIGHTGUN_ID_CURSOR,
+  RETRO_LIGHTGUN_ID_TURBO,
+  RETRO_LIGHTGUN_ID_PAUSE,
+  RETRO_LIGHTGUN_ID_START,
+} RetroLightgunId;
+
+G_END_DECLS
+
+#endif /* RETRO_LIGHTGUN_ID_H */


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