[gnome-games/wip/aplazas/781572-remove-vala-macro: 12/19] gamepad: Port GamepadMappedEvent to C
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/aplazas/781572-remove-vala-macro: 12/19] gamepad: Port GamepadMappedEvent to C
- Date: Tue, 2 May 2017 12:11:12 +0000 (UTC)
commit b4f5ab2824772928aa7e1b83adc046e0c6970048
Author: Adrien Plazas <kekun plazas laposte net>
Date: Fri Apr 28 13:22:24 2017 +0200
gamepad: Port GamepadMappedEvent to C
This will help to port part of the gamepad handling to C to avoid using
the Vala preprocessor.
src/Makefile.am | 4 ++-
src/gamepad/gamepad-mapped-event.c | 36 ++++++++++++++++++++
src/gamepad/gamepad-mapped-event.h | 27 +++++++++++++++
...mapped-event.vala => gamepad-mapped-event.vapi} | 1 +
4 files changed, 67 insertions(+), 1 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 37c47d3..19766ee 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -24,6 +24,7 @@ BUILT_SOURCES = \
EXTRA_DIST = \
$(gresource_file) \
gamepad/gamepad-input-type.vapi \
+ gamepad/gamepad-mapped-event.vapi \
gamepad/gamepad-mapping-error.vapi \
gamepad/linux/linux-raw-gamepad-monitor.vapi \
gamepad/raw-gamepad.vapi \
@@ -76,7 +77,7 @@ gnome_games_SOURCES = \
gamepad/gamepad-callbacks.vala \
gamepad/gamepad-dpad.vala \
gamepad/gamepad-input-type.c \
- gamepad/gamepad-mapped-event.vala \
+ gamepad/gamepad-mapped-event.c \
gamepad/gamepad-mapping.vala \
gamepad/gamepad-mapping-error.c \
gamepad/gamepad-mappings-manager.vala \
@@ -185,6 +186,7 @@ gnome_games_VALAFLAGS = \
--pkg linux \
--pkg posix \
--pkg gamepad-input-type \
+ --pkg gamepad-mapped-event \
--pkg gamepad-mapping-error \
--pkg raw-gamepad \
--pkg raw-gamepad-monitor \
diff --git a/src/gamepad/gamepad-mapped-event.c b/src/gamepad/gamepad-mapped-event.c
new file mode 100644
index 0000000..3e67de3
--- /dev/null
+++ b/src/gamepad/gamepad-mapped-event.c
@@ -0,0 +1,36 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+#include "gamepad-mapped-event.h"
+
+#include <string.h>
+
+GamesGamepadMappedEvent *
+games_gamepad_mapped_event_dup (const GamesGamepadMappedEvent *self)
+{
+ GamesGamepadMappedEvent *dup;
+
+ dup = g_new0 (GamesGamepadMappedEvent, 1);
+ memcpy (dup, self, sizeof (GamesGamepadMappedEvent));
+
+ return dup;
+}
+
+void
+games_gamepad_mapped_event_free (GamesGamepadMappedEvent *self)
+{
+ g_free (self);
+}
+
+GType
+games_gamepad_mapped_event_get_type (void)
+{
+ static volatile gsize type_id = 0;
+
+ if (g_once_init_enter (&type_id))
+ g_once_init_leave (&type_id,
+ g_boxed_type_register_static ("GamesGamepadMappedEvent",
+ (GBoxedCopyFunc) games_gamepad_mapped_event_dup,
+ (GBoxedFreeFunc) games_gamepad_mapped_event_free));
+
+ return type_id;
+}
diff --git a/src/gamepad/gamepad-mapped-event.h b/src/gamepad/gamepad-mapped-event.h
new file mode 100644
index 0000000..241a5d6
--- /dev/null
+++ b/src/gamepad/gamepad-mapped-event.h
@@ -0,0 +1,27 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+#ifndef GAMES_GAMEPAD_MAPPED_EVENT_H
+#define GAMES_GAMEPAD_MAPPED_EVENT_H
+
+#include <glib-object.h>
+#include "gamepad-input-type.h"
+#include "standard-gamepad-axis.h"
+#include "standard-gamepad-button.h"
+
+G_BEGIN_DECLS
+
+#define GAMES_TYPE_GAMEPAD_MAPPED_EVENT (games_gamepad_mapped_event_get_type ())
+
+typedef struct {
+ GamesGamepadInputType type;
+ GamesStandardGamepadAxis axis;
+ GamesStandardGamepadButton button;
+} GamesGamepadMappedEvent;
+
+GType games_gamepad_mapped_event_get_type (void) G_GNUC_CONST;
+GamesGamepadMappedEvent *games_gamepad_mapped_event_dup (const GamesGamepadMappedEvent *self);
+void games_gamepad_mapped_event_free (GamesGamepadMappedEvent *self);
+
+G_END_DECLS
+
+#endif /* GAMES_GAMEPAD_MAPPED_EVENT_H */
diff --git a/src/gamepad/gamepad-mapped-event.vala b/src/gamepad/gamepad-mapped-event.vapi
similarity index 77%
rename from src/gamepad/gamepad-mapped-event.vala
rename to src/gamepad/gamepad-mapped-event.vapi
index 2c69e3e..808da43 100644
--- a/src/gamepad/gamepad-mapped-event.vala
+++ b/src/gamepad/gamepad-mapped-event.vapi
@@ -1,5 +1,6 @@
// This file is part of GNOME Games. License: GPL-3.0+.
+[CCode (cheader_filename = "gamepad-mapped-event.h")]
private struct Games.GamepadMappedEvent {
GamepadInputType type;
StandardGamepadAxis axis;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]