[gnome-games/wip/aplazas/781572-remove-vala-macro: 2/11] gamepad: Port StandardGamepadAxis to C
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/aplazas/781572-remove-vala-macro: 2/11] gamepad: Port StandardGamepadAxis to C
- Date: Thu, 27 Apr 2017 04:59:56 +0000 (UTC)
commit 3f8dbdafcae5718e779431d0375bc2785a8dce3c
Author: Adrien Plazas <kekun plazas laposte net>
Date: Thu Apr 20 12:35:47 2017 +0200
gamepad: Port StandardGamepadAxis to C
This will help to port part of the gamepad handling to C to avoid using
Vala macros.
src/Makefile.am | 6 ++++-
src/gamepad/standard-gamepad-axis.c | 29 ++++++++++++++++++++++++
src/gamepad/standard-gamepad-axis.h | 38 ++++++++++++++++++++++++++++++++
src/gamepad/standard-gamepad-axis.vala | 33 ---------------------------
src/gamepad/standard-gamepad-axis.vapi | 10 ++++++++
5 files changed, 82 insertions(+), 34 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index cc9f9a5..1ddb729 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -24,6 +24,7 @@ BUILT_SOURCES = \
EXTRA_DIST = \
$(gresource_file) \
gamepad/linux/libevdev.vapi \
+ gamepad/standard-gamepad-axis.vapi \
$(NULL)
header_file = libgnome-games.h
@@ -77,7 +78,7 @@ gnome_games_SOURCES = \
gamepad/gamepad-monitor.vala \
gamepad/raw-gamepad.vala \
gamepad/raw-gamepad-monitor.vala \
- gamepad/standard-gamepad-axis.vala \
+ gamepad/standard-gamepad-axis.c \
gamepad/standard-gamepad-button.vala \
\
generic/generic-game.vala \
@@ -178,8 +179,10 @@ gnome_games_VALAFLAGS = \
--pkg retro-gtk-0.10 \
--pkg linux \
--pkg posix \
+ --pkg standard-gamepad-axis \
--gresources $(gresource_file) \
--vapi $(vapi_file) \
+ --vapidir=gamepad/ \
-H $(header_file) \
$(NULL)
@@ -202,6 +205,7 @@ gnome_games_CFLAGS = \
$(GNOME_GAMES_CFLAGS) \
$(GAMEPADS_CFLAGS) \
$(UDEV_CFLAGS) \
+ -I$(srcdir)/gamepad \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DGAMES_PLUGINS_DIR=\"$(libdir)/gnome-games/plugins\" \
$(NULL)
diff --git a/src/gamepad/standard-gamepad-axis.c b/src/gamepad/standard-gamepad-axis.c
new file mode 100644
index 0000000..6a5fa78
--- /dev/null
+++ b/src/gamepad/standard-gamepad-axis.c
@@ -0,0 +1,29 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+#include "standard-gamepad-axis.h"
+
+GType
+games_standard_gamepad_axis_get_type (void)
+{
+ static volatile gsize type_id_volatile = 0;
+
+ if (g_once_init_enter (&type_id_volatile))
+ {
+ static const GEnumValue values[] =
+ {
+ { GAMES_STANDARD_GAMEPAD_AXIS_UNKNOWN, "GAMES_STANDARD_GAMEPAD_AXIS_UNKNOWN", "unknown" },
+ { GAMES_STANDARD_GAMEPAD_AXIS_LEFT_X, "GAMES_STANDARD_GAMEPAD_AXIS_LEFT_X", "left-x" },
+ { GAMES_STANDARD_GAMEPAD_AXIS_LEFT_Y, "GAMES_STANDARD_GAMEPAD_AXIS_LEFT_Y", "left-y" },
+ { GAMES_STANDARD_GAMEPAD_AXIS_RIGHT_X, "GAMES_STANDARD_GAMEPAD_AXIS_RIGHT_X", "right-x" },
+ { GAMES_STANDARD_GAMEPAD_AXIS_RIGHT_Y, "GAMES_STANDARD_GAMEPAD_AXIS_RIGHT_Y", "right-y" },
+ { 0, NULL, NULL },
+ };
+ GType type_id;
+
+ type_id = g_enum_register_static ("GamesStandardGamepadAxis", values);
+
+ g_once_init_leave (&type_id_volatile, type_id);
+ }
+
+ return type_id_volatile;
+}
diff --git a/src/gamepad/standard-gamepad-axis.h b/src/gamepad/standard-gamepad-axis.h
new file mode 100644
index 0000000..636f0f1
--- /dev/null
+++ b/src/gamepad/standard-gamepad-axis.h
@@ -0,0 +1,38 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+#ifndef GAMES_STANDARD_GAMEPAD_AXIS_H
+#define GAMES_STANDARD_GAMEPAD_AXIS_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GAMES_TYPE_STANDARD_GAMEPAD_AXIS (games_standard_gamepad_axis_get_type ())
+
+/**
+ * GamesStandardGamepadAxis:
+ * @GAMES_STANDARD_GAMEPAD_AXIS_UNKNOWN: an unknown axis
+ * @GAMES_STANDARD_GAMEPAD_AXIS_LEFT_X: the horizontal axis of the left stick
+ * @GAMES_STANDARD_GAMEPAD_AXIS_LEFT_Y: the vertical axis of the left stick
+ * @GAMES_STANDARD_GAMEPAD_AXIS_RIGHT_X: the horizontal axis of the right stick
+ * @GAMES_STANDARD_GAMEPAD_AXIS_RIGHT_Y: the vertical axis of the right stick
+ *
+ * The axes of a standard gamepad.
+ *
+ * For horizontal axes, left is -1 and right is 1; for vertical axes,
+ * top is -1 and bottom is 1.
+ **/
+typedef enum
+{
+ GAMES_STANDARD_GAMEPAD_AXIS_UNKNOWN,
+ GAMES_STANDARD_GAMEPAD_AXIS_LEFT_X,
+ GAMES_STANDARD_GAMEPAD_AXIS_LEFT_Y,
+ GAMES_STANDARD_GAMEPAD_AXIS_RIGHT_X,
+ GAMES_STANDARD_GAMEPAD_AXIS_RIGHT_Y,
+} GamesStandardGamepadAxis;
+
+GType games_standard_gamepad_axis_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* GAMES_STANDARD_GAMEPAD_AXIS_H */
diff --git a/src/gamepad/standard-gamepad-axis.vapi b/src/gamepad/standard-gamepad-axis.vapi
new file mode 100644
index 0000000..d306075
--- /dev/null
+++ b/src/gamepad/standard-gamepad-axis.vapi
@@ -0,0 +1,10 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+[CCode (cheader_filename = "standard-gamepad-axis.h")]
+private enum Games.StandardGamepadAxis {
+ UNKNOWN,
+ LEFT_X,
+ LEFT_Y,
+ RIGHT_X,
+ RIGHT_Y,
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]