[retro-gtk/wip/aplazas/c-port: 4/36] Port JoypadId to C



commit 77b96b793835197c42c10a6be90d0414e2251ba3
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Tue Sep 5 13:28:53 2017 +0200

    Port JoypadId to C

 retro-gtk/Makefile.am              |    1 +
 retro-gtk/input/device.vala        |   23 -------------
 retro-gtk/retro-core-view-extern.c |    1 +
 retro-gtk/retro-gtk.h              |    1 +
 retro-gtk/retro-joypad-id.h        |   63 ++++++++++++++++++++++++++++++++++++
 5 files changed, 66 insertions(+), 23 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index 0f13040..c63b6df 100644
--- a/retro-gtk/Makefile.am
+++ b/retro-gtk/Makefile.am
@@ -33,6 +33,7 @@ retro_gtk_public_h_sources = \
        retro-device-type.h \
        retro-gtk.h \
        retro-gtk-vala.h \
+       retro-joypad-id.h \
        $(NULL)
 
 retro_gtk_private_h_sources = \
diff --git a/retro-gtk/input/device.vala b/retro-gtk/input/device.vala
index a6e618e..180630b 100644
--- a/retro-gtk/input/device.vala
+++ b/retro-gtk/input/device.vala
@@ -3,29 +3,6 @@
 namespace Retro {
 
 /**
- * The input types of a joypad.
- */
-public enum JoypadId {
-       B,
-       Y,
-       SELECT,
-       START,
-       UP,
-       DOWN,
-       LEFT,
-       RIGHT,
-       A,
-       X,
-       L,
-       R,
-       L2,
-       R2,
-       L3,
-       R3,
-       COUNT,
-}
-
-/**
  * The analog sticks of an analog joypad.
  */
 public enum AnalogIndex {
diff --git a/retro-gtk/retro-core-view-extern.c b/retro-gtk/retro-core-view-extern.c
index 089eaaf..8377168 100644
--- a/retro-gtk/retro-core-view-extern.c
+++ b/retro-gtk/retro-core-view-extern.c
@@ -3,6 +3,7 @@
 #include <linux/input-event-codes.h>
 #include "retro-gtk-internal.h"
 #include "retro-core-view-input-device.h"
+#include "retro-joypad-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 e9dabaa..2be93f4 100644
--- a/retro-gtk/retro-gtk.h
+++ b/retro-gtk/retro-gtk.h
@@ -11,6 +11,7 @@
 
 #include "retro-device-type.h"
 #include "retro-gtk-vala.h"
+#include "retro-joypad-id.h"
 
 #undef __RETRO_GTK_INSIDE__
 
diff --git a/retro-gtk/retro-joypad-id.h b/retro-gtk/retro-joypad-id.h
new file mode 100644
index 0000000..d7c772d
--- /dev/null
+++ b/retro-gtk/retro-joypad-id.h
@@ -0,0 +1,63 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#ifndef RETRO_JOYPAD_ID_H
+#define RETRO_JOYPAD_ID_H
+
+#if !defined(__RETRO_GTK_INSIDE__) && !defined(RETRO_GTK_COMPILATION)
+# error "Only <retro-gtk.h> can be included directly."
+#endif
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+/**
+ * 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 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> 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;
+
+G_END_DECLS
+
+#endif /* RETRO_JOYPAD_ID_H */


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