[retro-gtk/wip/aplazas/master: 5/10] Port MouseId to C
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk/wip/aplazas/master: 5/10] Port MouseId to C
- Date: Sat, 7 Oct 2017 08:51:05 +0000 (UTC)
commit d512eac8d5e0369d80ce1d3effdccda364df35e1
Author: Adrien Plazas <kekun plazas laposte net>
Date: Tue Sep 5 14:52:10 2017 +0200
Port MouseId to C
retro-gtk/Makefile.am | 2 +
retro-gtk/input/device.vala | 15 -----------
retro-gtk/retro-core-view-extern.c | 1 +
retro-gtk/retro-gtk.h | 1 +
retro-gtk/retro-mouse-id.c | 31 +++++++++++++++++++++++
retro-gtk/retro-mouse-id.h | 47 ++++++++++++++++++++++++++++++++++++
6 files changed, 82 insertions(+), 15 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index cd9d251..aac475e 100644
--- a/retro-gtk/Makefile.am
+++ b/retro-gtk/Makefile.am
@@ -36,6 +36,7 @@ retro_gtk_public_h_sources = \
retro-gtk.h \
retro-gtk-vala.h \
retro-joypad-id.h \
+ retro-mouse-id.h \
$(NULL)
retro_gtk_private_h_sources = \
@@ -84,6 +85,7 @@ libretro_gtk_la_SOURCES = \
retro-module.c \
retro-module-query.vala \
retro-module-iterator.vala \
+ retro-mouse-id.c \
retro-option.c \
retro-options.c \
rumble.vala \
diff --git a/retro-gtk/input/device.vala b/retro-gtk/input/device.vala
index bc98db7..a8165eb 100644
--- a/retro-gtk/input/device.vala
+++ b/retro-gtk/input/device.vala
@@ -3,21 +3,6 @@
namespace Retro {
/**
- * The input types of a mouse.
- */
-private enum MouseId {
- X,
- Y,
- LEFT,
- RIGHT,
- WHEELUP,
- WHEELDOWN,
- MIDDLE,
- HORIZ_WHEELUP,
- HORIZ_WHEELDOWN,
-}
-
-/**
* The input types of a lightgun.
*/
private enum LightgunId {
diff --git a/retro-gtk/retro-core-view-extern.c b/retro-gtk/retro-core-view-extern.c
index 8377168..a7c6843 100644
--- a/retro-gtk/retro-core-view-extern.c
+++ b/retro-gtk/retro-core-view-extern.c
@@ -4,6 +4,7 @@
#include "retro-gtk-internal.h"
#include "retro-core-view-input-device.h"
#include "retro-joypad-id.h"
+#include "retro-mouse-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 be8b24f..82b5ba9 100644
--- a/retro-gtk/retro-gtk.h
+++ b/retro-gtk/retro-gtk.h
@@ -14,6 +14,7 @@
#include "retro-device-type.h"
#include "retro-gtk-vala.h"
#include "retro-joypad-id.h"
+#include "retro-mouse-id.h"
#undef __RETRO_GTK_INSIDE__
diff --git a/retro-gtk/retro-mouse-id.c b/retro-gtk/retro-mouse-id.c
new file mode 100644
index 0000000..088de38
--- /dev/null
+++ b/retro-gtk/retro-mouse-id.c
@@ -0,0 +1,31 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#include "retro-mouse-id.h"
+
+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;
+}
diff --git a/retro-gtk/retro-mouse-id.h b/retro-gtk/retro-mouse-id.h
new file mode 100644
index 0000000..b195030
--- /dev/null
+++ b/retro-gtk/retro-mouse-id.h
@@ -0,0 +1,47 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#ifndef RETRO_MOUSE_ID_H
+#define RETRO_MOUSE_ID_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_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;
+
+G_END_DECLS
+
+#endif /* RETRO_MOUSE_ID_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]