[gnome-games/wip/aplazas/781572-remove-vala-macro: 3/10] gamepad: Port StandardGamepadButton to C
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/aplazas/781572-remove-vala-macro: 3/10] gamepad: Port StandardGamepadButton to C
- Date: Thu, 27 Apr 2017 09:59:25 +0000 (UTC)
commit cf9890e2e2f58e98eb93ed44380490cd310849db
Author: Adrien Plazas <kekun plazas laposte net>
Date: Thu Apr 20 12:39:56 2017 +0200
gamepad: Port StandardGamepadButton to C
This will help to port part of the gamepad handling to C to avoid using
Vala macros.
src/Makefile.am | 4 +-
src/gamepad/standard-gamepad-button.c | 37 +++++++++++++++
src/gamepad/standard-gamepad-button.h | 60 ++++++++++++++++++++++++
src/gamepad/standard-gamepad-button.vala | 75 ------------------------------
src/gamepad/standard-gamepad-button.vapi | 23 +++++++++
5 files changed, 123 insertions(+), 76 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 1ddb729..d86f402 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -25,6 +25,7 @@ EXTRA_DIST = \
$(gresource_file) \
gamepad/linux/libevdev.vapi \
gamepad/standard-gamepad-axis.vapi \
+ gamepad/standard-gamepad-button.vapi \
$(NULL)
header_file = libgnome-games.h
@@ -79,7 +80,7 @@ gnome_games_SOURCES = \
gamepad/raw-gamepad.vala \
gamepad/raw-gamepad-monitor.vala \
gamepad/standard-gamepad-axis.c \
- gamepad/standard-gamepad-button.vala \
+ gamepad/standard-gamepad-button.c \
\
generic/generic-game.vala \
generic/generic-sync-game-uri-adapter.vala \
@@ -180,6 +181,7 @@ gnome_games_VALAFLAGS = \
--pkg linux \
--pkg posix \
--pkg standard-gamepad-axis \
+ --pkg standard-gamepad-button \
--gresources $(gresource_file) \
--vapi $(vapi_file) \
--vapidir=gamepad/ \
diff --git a/src/gamepad/standard-gamepad-button.c b/src/gamepad/standard-gamepad-button.c
new file mode 100644
index 0000000..ba17680
--- /dev/null
+++ b/src/gamepad/standard-gamepad-button.c
@@ -0,0 +1,37 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+#include "standard-gamepad-button.h"
+
+GType
+games_standard_gamepad_button_get_type (void)
+{
+ static volatile gsize type_id = 0;
+ static const GEnumValue values[] = {
+ { GAMES_STANDARD_GAMEPAD_BUTTON_UNKNOWN, "GAMES_STANDARD_GAMEPAD_BUTTON_UNKNOWN", "unknown" },
+ { GAMES_STANDARD_GAMEPAD_BUTTON_A, "GAMES_STANDARD_GAMEPAD_BUTTON_A", "a" },
+ { GAMES_STANDARD_GAMEPAD_BUTTON_B, "GAMES_STANDARD_GAMEPAD_BUTTON_B", "b" },
+ { GAMES_STANDARD_GAMEPAD_BUTTON_X, "GAMES_STANDARD_GAMEPAD_BUTTON_X", "x" },
+ { GAMES_STANDARD_GAMEPAD_BUTTON_Y, "GAMES_STANDARD_GAMEPAD_BUTTON_Y", "y" },
+ { GAMES_STANDARD_GAMEPAD_BUTTON_SHOULDER_L, "GAMES_STANDARD_GAMEPAD_BUTTON_SHOULDER_L", "shoulder-l" },
+ { GAMES_STANDARD_GAMEPAD_BUTTON_SHOULDER_R, "GAMES_STANDARD_GAMEPAD_BUTTON_SHOULDER_R", "shoulder-r" },
+ { GAMES_STANDARD_GAMEPAD_BUTTON_TRIGGER_L, "GAMES_STANDARD_GAMEPAD_BUTTON_TRIGGER_L", "trigger-l" },
+ { GAMES_STANDARD_GAMEPAD_BUTTON_TRIGGER_R, "GAMES_STANDARD_GAMEPAD_BUTTON_TRIGGER_R", "trigger-r" },
+ { GAMES_STANDARD_GAMEPAD_BUTTON_SELECT, "GAMES_STANDARD_GAMEPAD_BUTTON_SELECT", "select" },
+ { GAMES_STANDARD_GAMEPAD_BUTTON_START, "GAMES_STANDARD_GAMEPAD_BUTTON_START", "start" },
+ { GAMES_STANDARD_GAMEPAD_BUTTON_STICK_L, "GAMES_STANDARD_GAMEPAD_BUTTON_STICK_L", "stick-l" },
+ { GAMES_STANDARD_GAMEPAD_BUTTON_STICK_R, "GAMES_STANDARD_GAMEPAD_BUTTON_STICK_R", "stick-r" },
+ { GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_UP, "GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_UP", "dpad-up" },
+ { GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_DOWN, "GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_DOWN", "dpad-down" },
+ { GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_LEFT, "GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_LEFT", "dpad-left" },
+ { GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_RIGHT, "GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_RIGHT", "dpad-right" },
+ { GAMES_STANDARD_GAMEPAD_BUTTON_HOME, "GAMES_STANDARD_GAMEPAD_BUTTON_HOME", "home" },
+ { 0, NULL, NULL },
+ };
+
+ if (g_once_init_enter (&type_id))
+ g_once_init_leave (&type_id,
+ g_enum_register_static ("GamesStandardGamepadButton",
+ values));
+
+ return type_id;
+}
diff --git a/src/gamepad/standard-gamepad-button.h b/src/gamepad/standard-gamepad-button.h
new file mode 100644
index 0000000..cd5e7bd
--- /dev/null
+++ b/src/gamepad/standard-gamepad-button.h
@@ -0,0 +1,60 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+#ifndef GAMES_STANDARD_GAMEPAD_BUTTON_H
+#define GAMES_STANDARD_GAMEPAD_BUTTON_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GAMES_TYPE_STANDARD_GAMEPAD_BUTTON (games_standard_gamepad_button_get_type ())
+
+/**
+ * GamesStandardGamepadButton:
+ * @GAMES_STANDARD_GAMEPAD_BUTTON_UNKNOWN: an unknown button
+ * @GAMES_STANDARD_GAMEPAD_BUTTON_A: the A (south) button
+ * @GAMES_STANDARD_GAMEPAD_BUTTON_B: the B (east) button
+ * @GAMES_STANDARD_GAMEPAD_BUTTON_X: the X (west) button
+ * @GAMES_STANDARD_GAMEPAD_BUTTON_Y: the Y (north) button
+ * @GAMES_STANDARD_GAMEPAD_BUTTON_SHOULDER_L: the left shoulder button
+ * @GAMES_STANDARD_GAMEPAD_BUTTON_SHOULDER_R: the right shoulder button
+ * @GAMES_STANDARD_GAMEPAD_BUTTON_TRIGGER_L: the left trigger
+ * @GAMES_STANDARD_GAMEPAD_BUTTON_TRIGGER_R: the right trigger
+ * @GAMES_STANDARD_GAMEPAD_BUTTON_SELECT: the Select button
+ * @GAMES_STANDARD_GAMEPAD_BUTTON_START: the Start button
+ * @GAMES_STANDARD_GAMEPAD_BUTTON_STICK_L: the left stick's button
+ * @GAMES_STANDARD_GAMEPAD_BUTTON_STICK_R: the right stick's button
+ * @GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_UP: the up button of the d-pad
+ * @GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_DOWN: the down button of the d-pad
+ * @GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_LEFT: the left button of the d-pad
+ * @GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_RIGHT: the right button of the d-pad
+ * @GAMES_STANDARD_GAMEPAD_BUTTON_HOME: the Home button
+ *
+ * The buttons of a standard gamepad.
+ **/
+typedef enum {
+ GAMES_STANDARD_GAMEPAD_BUTTON_UNKNOWN,
+ GAMES_STANDARD_GAMEPAD_BUTTON_A,
+ GAMES_STANDARD_GAMEPAD_BUTTON_B,
+ GAMES_STANDARD_GAMEPAD_BUTTON_X,
+ GAMES_STANDARD_GAMEPAD_BUTTON_Y,
+ GAMES_STANDARD_GAMEPAD_BUTTON_SHOULDER_L,
+ GAMES_STANDARD_GAMEPAD_BUTTON_SHOULDER_R,
+ GAMES_STANDARD_GAMEPAD_BUTTON_TRIGGER_L,
+ GAMES_STANDARD_GAMEPAD_BUTTON_TRIGGER_R,
+ GAMES_STANDARD_GAMEPAD_BUTTON_SELECT,
+ GAMES_STANDARD_GAMEPAD_BUTTON_START,
+ GAMES_STANDARD_GAMEPAD_BUTTON_STICK_L,
+ GAMES_STANDARD_GAMEPAD_BUTTON_STICK_R,
+ GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_UP,
+ GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_DOWN,
+ GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_LEFT,
+ GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_RIGHT,
+ GAMES_STANDARD_GAMEPAD_BUTTON_HOME,
+} GamesStandardGamepadButton;
+
+GType games_standard_gamepad_button_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* GAMES_STANDARD_GAMEPAD_BUTTON_H */
diff --git a/src/gamepad/standard-gamepad-button.vapi b/src/gamepad/standard-gamepad-button.vapi
new file mode 100644
index 0000000..bfde8af
--- /dev/null
+++ b/src/gamepad/standard-gamepad-button.vapi
@@ -0,0 +1,23 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+[CCode (cheader_filename = "standard-gamepad-button.h")]
+private enum Games.StandardGamepadButton {
+ UNKNOWN,
+ A,
+ B,
+ X,
+ Y,
+ SHOULDER_L,
+ SHOULDER_R,
+ TRIGGER_L,
+ TRIGGER_R,
+ SELECT,
+ START,
+ STICK_L,
+ STICK_R,
+ DPAD_UP,
+ DPAD_DOWN,
+ DPAD_LEFT,
+ DPAD_RIGHT,
+ HOME,
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]