[retro-gtk] Merge controller ID and index files into one



commit 04e10399984bffd729d2fde1974b9754cc6076e0
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Sun Oct 29 19:50:52 2017 +0100

    Merge controller ID and index files into one
    
    This makes the code simpler by avoiding spreading similar small concepts
    into multiple small files.

 retro-gtk/Makefile.am              |   14 +---
 retro-gtk/retro-analog-id.c        |   24 -----
 retro-gtk/retro-analog-id.h        |   33 -------
 retro-gtk/retro-analog-index.c     |   24 -----
 retro-gtk/retro-analog-index.h     |   33 -------
 retro-gtk/retro-controller-codes.c |  157 +++++++++++++++++++++++++++++++
 retro-gtk/retro-controller-codes.h |  179 ++++++++++++++++++++++++++++++++++++
 retro-gtk/retro-core-view.c        |    4 +-
 retro-gtk/retro-gtk.h              |    7 +-
 retro-gtk/retro-joypad-id.c        |   39 --------
 retro-gtk/retro-joypad-id.h        |   68 --------------
 retro-gtk/retro-lightgun-id.c      |   29 ------
 retro-gtk/retro-lightgun-id.h      |   43 ---------
 retro-gtk/retro-mouse-id.c         |   31 ------
 retro-gtk/retro-mouse-id.h         |   47 ----------
 retro-gtk/retro-pointer-id.c       |   25 -----
 retro-gtk/retro-pointer-id.h       |   35 -------
 17 files changed, 340 insertions(+), 452 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index 18da904..b07636e 100644
--- a/retro-gtk/Makefile.am
+++ b/retro-gtk/Makefile.am
@@ -28,25 +28,20 @@ vapi_DATA = retro-gtk-0.14.vapi
 dist_vapi_DATA = retro-gtk-0.14.deps
 
 retro_gtk_public_h_sources = \
-       retro-analog-id.h \
-       retro-analog-index.h \
        retro-controller.h \
+       retro-controller-codes.h \
        retro-controller-iterator.h \
        retro-controller-type.h \
        retro-core-descriptor.h \
        retro-core.h \
        retro-core-view.h \
        retro-gtk.h \
-       retro-joypad-id.h \
-       retro-lightgun-id.h \
        retro-log.h \
        retro-main-loop.h \
        retro-memory-type.h \
        retro-module-iterator.h \
        retro-module-query.h \
-       retro-mouse-id.h \
        retro-pixdata.h \
-       retro-pointer-id.h \
        retro-rumble-effect.h \
        retro-video-filter.h \
        $(NULL)
@@ -74,10 +69,9 @@ retro_gtk_private_h_sources = \
        $(NULL)
 
 libretro_gtk_la_SOURCES = \
-       retro-analog-id.c \
-       retro-analog-index.c \
        retro-cairo-display.c \
        retro-controller.c \
+       retro-controller-codes.c \
        retro-controller-iterator.c \
        retro-controller-type.c \
        retro-core-descriptor.c \
@@ -85,22 +79,18 @@ libretro_gtk_la_SOURCES = \
        retro-core-view-controller.c \
        retro-game-info.c \
        retro-input-descriptor.c \
-       retro-joypad-id.c \
        retro-keyboard-key.c \
-       retro-lightgun-id.c \
        retro-log.c \
        retro-main-loop.c \
        retro-memory-type.c \
        retro-module.c \
        retro-module-iterator.c \
        retro-module-query.c \
-       retro-mouse-id.c \
        retro-option.c \
        retro-options.c \
        retro-pa-player.c \
        retro-pixdata.c \
        retro-pixel-format.c \
-       retro-pointer-id.c \
        retro-rumble-effect.c \
        retro-video-filter.c \
        retro-core.c \
diff --git a/retro-gtk/retro-controller-codes.c b/retro-gtk/retro-controller-codes.c
new file mode 100644
index 0000000..425fc05
--- /dev/null
+++ b/retro-gtk/retro-controller-codes.c
@@ -0,0 +1,157 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#include "retro-controller-codes.h"
+
+GType
+retro_joypad_id_get_type (void)
+{
+  static volatile gsize retro_joypad_id_type = 0;
+
+  if (g_once_init_enter (&retro_joypad_id_type)) {
+    static const GEnumValue values[] = {
+      { RETRO_JOYPAD_ID_B, "RETRO_JOYPAD_ID_B", "b" },
+      { RETRO_JOYPAD_ID_Y, "RETRO_JOYPAD_ID_Y", "y" },
+      { RETRO_JOYPAD_ID_SELECT, "RETRO_JOYPAD_ID_SELECT", "select" },
+      { RETRO_JOYPAD_ID_START, "RETRO_JOYPAD_ID_START", "start" },
+      { RETRO_JOYPAD_ID_UP, "RETRO_JOYPAD_ID_UP", "up" },
+      { RETRO_JOYPAD_ID_DOWN, "RETRO_JOYPAD_ID_DOWN", "down" },
+      { RETRO_JOYPAD_ID_LEFT, "RETRO_JOYPAD_ID_LEFT", "left" },
+      { RETRO_JOYPAD_ID_RIGHT, "RETRO_JOYPAD_ID_RIGHT", "right" },
+      { RETRO_JOYPAD_ID_A, "RETRO_JOYPAD_ID_A", "a" },
+      { RETRO_JOYPAD_ID_X, "RETRO_JOYPAD_ID_X", "x" },
+      { RETRO_JOYPAD_ID_L, "RETRO_JOYPAD_ID_L", "l" },
+      { RETRO_JOYPAD_ID_R, "RETRO_JOYPAD_ID_R", "r" },
+      { RETRO_JOYPAD_ID_L2, "RETRO_JOYPAD_ID_L2", "l2" },
+      { RETRO_JOYPAD_ID_R2, "RETRO_JOYPAD_ID_R2", "r2" },
+      { RETRO_JOYPAD_ID_L3, "RETRO_JOYPAD_ID_L3", "l3" },
+      { RETRO_JOYPAD_ID_R3, "RETRO_JOYPAD_ID_R3", "r3" },
+      { RETRO_JOYPAD_ID_COUNT, "RETRO_JOYPAD_ID_COUNT", "count" },
+      { 0, NULL, NULL },
+    };
+    GType type;
+
+    type = g_enum_register_static ("RetroJoypadId", values);
+
+    g_once_init_leave (&retro_joypad_id_type, type);
+  }
+
+  return retro_joypad_id_type;
+}
+
+GType
+retro_mouse_id_get_type (void)
+{
+  static volatile gsize retro_mouse_id_type = 0;
+
+  if (g_once_init_enter (&retro_mouse_id_type)) {
+    static const GEnumValue values[] = {
+      { RETRO_MOUSE_ID_X, "RETRO_MOUSE_ID_X", "x" },
+      { RETRO_MOUSE_ID_Y, "RETRO_MOUSE_ID_Y", "y" },
+      { RETRO_MOUSE_ID_LEFT, "RETRO_MOUSE_ID_LEFT", "left" },
+      { RETRO_MOUSE_ID_RIGHT, "RETRO_MOUSE_ID_RIGHT", "right" },
+      { RETRO_MOUSE_ID_WHEELUP, "RETRO_MOUSE_ID_WHEELUP", "wheelup" },
+      { RETRO_MOUSE_ID_WHEELDOWN, "RETRO_MOUSE_ID_WHEELDOWN", "wheeldown" },
+      { RETRO_MOUSE_ID_MIDDLE, "RETRO_MOUSE_ID_MIDDLE", "middle" },
+      { RETRO_MOUSE_ID_HORIZ_WHEELUP, "RETRO_MOUSE_ID_HORIZ_WHEELUP", "horiz-wheelup" },
+      { RETRO_MOUSE_ID_HORIZ_WHEELDOWN, "RETRO_MOUSE_ID_HORIZ_WHEELDOWN", "horiz-wheeldown" },
+      { 0, NULL, NULL },
+    };
+    GType type;
+
+    type = g_enum_register_static ("RetroMouseId", values);
+
+    g_once_init_leave (&retro_mouse_id_type, type);
+  }
+
+  return retro_mouse_id_type;
+}
+
+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;
+}
+
+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;
+}
+
+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;
+}
+
+GType
+retro_pointer_id_get_type (void)
+{
+  static volatile gsize retro_pointer_id_type = 0;
+
+  if (g_once_init_enter (&retro_pointer_id_type)) {
+    static const GEnumValue values[] = {
+      { RETRO_POINTER_ID_X, "RETRO_POINTER_ID_X", "x" },
+      { RETRO_POINTER_ID_Y, "RETRO_POINTER_ID_Y", "y" },
+      { RETRO_POINTER_ID_PRESSED, "RETRO_POINTER_ID_PRESSED", "pressed" },
+      { 0, NULL, NULL },
+    };
+    GType type;
+
+    type = g_enum_register_static ("RetroPointerId", values);
+
+    g_once_init_leave (&retro_pointer_id_type, type);
+  }
+
+  return retro_pointer_id_type;
+}
diff --git a/retro-gtk/retro-controller-codes.h b/retro-gtk/retro-controller-codes.h
new file mode 100644
index 0000000..b66a777
--- /dev/null
+++ b/retro-gtk/retro-controller-codes.h
@@ -0,0 +1,179 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#ifndef RETRO_CONTROLLER_CODES_H
+#define RETRO_CONTROLLER_CODES_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_JOYPAD_ID (retro_joypad_id_get_type ())
+
+GType retro_joypad_id_get_type (void) G_GNUC_CONST;
+
+/**
+ * RetroJoypadId:
+ * @RETRO_JOYPAD_ID_B: the bottom action button
+ * @RETRO_JOYPAD_ID_Y: the left action button
+ * @RETRO_JOYPAD_ID_SELECT: the Select button
+ * @RETRO_JOYPAD_ID_START: the Start button
+ * @RETRO_JOYPAD_ID_UP: the up directional button
+ * @RETRO_JOYPAD_ID_DOWN: the down directional button
+ * @RETRO_JOYPAD_ID_LEFT: the left directional button
+ * @RETRO_JOYPAD_ID_RIGHT: the right directional button
+ * @RETRO_JOYPAD_ID_A: the right action button
+ * @RETRO_JOYPAD_ID_X: the top action button
+ * @RETRO_JOYPAD_ID_L: the first left shoulder button
+ * @RETRO_JOYPAD_ID_R: the first right shoulder button
+ * @RETRO_JOYPAD_ID_L2: the second left shoulder button
+ * @RETRO_JOYPAD_ID_R2: the second right shoulder button
+ * @RETRO_JOYPAD_ID_L3: the left thumb button
+ * @RETRO_JOYPAD_ID_R3: the right thumb button
+ * @RETRO_JOYPAD_ID_COUNT: the number of buttons
+ *
+ * Represents the buttons for the Libretro gamepad. The available buttons are
+ * the same as the W3C Standard Gamepad, the SDL GameController and many other
+ * modern standard gamepads, but the name of the buttons may differ. See the
+ * <ulink url="https://w3c.github.io/gamepad/";>W3C Gamepad Specification</ulink>
+ * and the <ulink url="https://wiki.libsdl.org/CategoryGameController";>SDL
+ * GamepadController definition</ulink> for more information.
+ */
+typedef enum
+{
+  RETRO_JOYPAD_ID_B,
+  RETRO_JOYPAD_ID_Y,
+  RETRO_JOYPAD_ID_SELECT,
+  RETRO_JOYPAD_ID_START,
+  RETRO_JOYPAD_ID_UP,
+  RETRO_JOYPAD_ID_DOWN,
+  RETRO_JOYPAD_ID_LEFT,
+  RETRO_JOYPAD_ID_RIGHT,
+  RETRO_JOYPAD_ID_A,
+  RETRO_JOYPAD_ID_X,
+  RETRO_JOYPAD_ID_L,
+  RETRO_JOYPAD_ID_R,
+  RETRO_JOYPAD_ID_L2,
+  RETRO_JOYPAD_ID_R2,
+  RETRO_JOYPAD_ID_L3,
+  RETRO_JOYPAD_ID_R3,
+  RETRO_JOYPAD_ID_COUNT,
+} RetroJoypadId;
+
+#define RETRO_TYPE_MOUSE_ID (retro_mouse_id_get_type ())
+
+GType retro_mouse_id_get_type (void) G_GNUC_CONST;
+
+/**
+ * RetroMouseId:
+ * @RETRO_MOUSE_ID_X: the X axis of a mouse
+ * @RETRO_MOUSE_ID_Y: the Y axis of a mouse
+ * @RETRO_MOUSE_ID_LEFT: the left button of a mouse
+ * @RETRO_MOUSE_ID_RIGHT: the right button of a mouse
+ * @RETRO_MOUSE_ID_WHEELUP: the up direction of a mouse wheel
+ * @RETRO_MOUSE_ID_WHEELDOWN: the down direction of a mouse wheel
+ * @RETRO_MOUSE_ID_MIDDLE: the middle button of a mouse
+ * @RETRO_MOUSE_ID_HORIZ_WHEELUP: the horizontal up direction of a mouse wheel
+ * @RETRO_MOUSE_ID_HORIZ_WHEELDOWN: the horizontal down direction of a mouse wheel
+ *
+ * Represents the inputs for the Libretro mouse.
+ */
+typedef enum
+{
+  RETRO_MOUSE_ID_X,
+  RETRO_MOUSE_ID_Y,
+  RETRO_MOUSE_ID_LEFT,
+  RETRO_MOUSE_ID_RIGHT,
+  RETRO_MOUSE_ID_WHEELUP,
+  RETRO_MOUSE_ID_WHEELDOWN,
+  RETRO_MOUSE_ID_MIDDLE,
+  RETRO_MOUSE_ID_HORIZ_WHEELUP,
+  RETRO_MOUSE_ID_HORIZ_WHEELDOWN,
+} RetroMouseId;
+
+#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;
+
+#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;
+
+#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;
+
+#define RETRO_TYPE_POINTER_ID (retro_pointer_id_get_type ())
+
+GType retro_pointer_id_get_type (void) G_GNUC_CONST;
+
+/**
+ * RetroPointerId:
+ * @RETRO_POINTER_ID_X: the X axis of a pointer
+ * @RETRO_POINTER_ID_Y: the Y axis of a pointer
+ * @RETRO_POINTER_ID_PRESSED: the pression of a pointer
+ *
+ * Represents the inputs for the Libretro pointer.
+ */
+typedef enum
+{
+  RETRO_POINTER_ID_X,
+  RETRO_POINTER_ID_Y,
+  RETRO_POINTER_ID_PRESSED,
+} RetroPointerId;
+
+G_END_DECLS
+
+#endif /* RETRO_CONTROLLER_CODES_H */
diff --git a/retro-gtk/retro-core-view.c b/retro-gtk/retro-core-view.c
index f285db6..935a1e3 100644
--- a/retro-gtk/retro-core-view.c
+++ b/retro-gtk/retro-core-view.c
@@ -4,11 +4,9 @@
 
 #include <linux/input-event-codes.h>
 #include "retro-cairo-display.h"
+#include "retro-controller-codes.h"
 #include "retro-core-view-controller.h"
-#include "retro-joypad-id.h"
-#include "retro-mouse-id.h"
 #include "retro-pa-player.h"
-#include "retro-pointer-id.h"
 
 static guint16 DEFAULT_KEY_JOYPAD_BUTTON_MAPPING[RETRO_JOYPAD_ID_COUNT] = {
   KEY_S,
diff --git a/retro-gtk/retro-gtk.h b/retro-gtk/retro-gtk.h
index 9d0266a..58204e1 100644
--- a/retro-gtk/retro-gtk.h
+++ b/retro-gtk/retro-gtk.h
@@ -9,23 +9,18 @@
 #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-controller.h"
+#include "retro-controller-codes.h"
 #include "retro-controller-type.h"
 #include "retro-core.h"
 #include "retro-core-descriptor.h"
 #include "retro-core-view.h"
-#include "retro-joypad-id.h"
-#include "retro-lightgun-id.h"
 #include "retro-log.h"
 #include "retro-main-loop.h"
 #include "retro-memory-type.h"
 #include "retro-module-iterator.h"
 #include "retro-module-query.h"
-#include "retro-mouse-id.h"
 #include "retro-pixdata.h"
-#include "retro-pointer-id.h"
 #include "retro-video-filter.h"
 
 #undef __RETRO_GTK_INSIDE__


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