[retro-gtk/wip/aplazas/0.13: 2/14] Port DeviceType to C



commit c1de3ff0e5c54dc137c1bd94e153d43ebc4f77ba
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Tue Sep 5 13:15:51 2017 +0200

    Port DeviceType to C

 retro-gtk/Makefile.am                 |   10 ++++++++-
 retro-gtk/input/device.vala           |   32 ----------------------------
 retro-gtk/retro-device-type.h         |   37 +++++++++++++++++++++++++++++++++
 retro-gtk/vapi/retro-device-type.vapi |   13 +++++++++++
 4 files changed, 59 insertions(+), 33 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index 615dd4e..2f1e204 100644
--- a/retro-gtk/Makefile.am
+++ b/retro-gtk/Makefile.am
@@ -85,6 +85,7 @@ libretro_gtk_la_LDFLAGS =
 libretro_gtk_la_VALAFLAGS = \
        --pkg cairo \
        --pkg config \
+       --pkg retro-device-type \
        --pkg gio-2.0  \
        --pkg glib-2.0 \
        --pkg gmodule-2.0 \
@@ -105,6 +106,7 @@ libretro_gtk_la_LIBADD = $(RETRO_GTK_LIBS)
 
 retro_gtkincludedir = $(includedir)/retro-gtk-0.12
 retro_gtkinclude_HEADERS = \
+       retro-device-type.h \
        retro-gtk.h \
        $(NULL)
 
@@ -133,7 +135,11 @@ BUILT_SOURCES += libretro-gtk.la Retro-0.12.gir
 
 Retro-0.12.gir: $(INTROSPECTION_SCANNER) libretro-gtk.la
 Retro_0_12_gir_INCLUDES = GLib-2.0 GObject-2.0 Gio-2.0 Gtk-3.0 cairo-1.0
-Retro_0_12_gir_SCANNERFLAGS = --c-include=retro-gtk.h --pkg-export=retro-gtk-0.12
+Retro_0_12_gir_SCANNERFLAGS = \
+       --c-include=retro-gtk.h \
+       --c-include=retro-device-type.h \
+       --pkg-export=retro-gtk-0.12 \
+       $(NULL)
 Retro_0_12_gir_CFLAGS = -DRETRO_GTK_USE_UNSTABLE_API $(retro_gtk_CFLAGS)
 Retro_0_12_gir_LIBS = libretro-gtk.la
 Retro_0_12_gir_FILES = $(introspection_sources)
@@ -162,6 +168,7 @@ EXTRA_DIST = \
        input/retro-keyboard-key.h \
        retro-core.h \
        retro-core-view-input-device.h \
+       retro-device-type.h \
        retro-disk-control-callback.h \
        retro-game-info.h \
        retro-module.h \
@@ -170,6 +177,7 @@ EXTRA_DIST = \
        retro-system-info.h \
        retro-gtk-0.12.pc.in \
        update-from-retroarch.sh \
+       vapi/retro-device-type.vapi \
        $(NULL)
 
 INPUTDIR=$(top_srcdir)/../RetroArch/libretro-common/include/
diff --git a/retro-gtk/input/device.vala b/retro-gtk/input/device.vala
index ce8a5bf..a6e618e 100644
--- a/retro-gtk/input/device.vala
+++ b/retro-gtk/input/device.vala
@@ -3,38 +3,6 @@
 namespace Retro {
 
 /**
- * The device types.
- */
-public enum DeviceType {
-       TYPE_MASK = 0xff,
-
-       /* See RETRO_DEVICE_NONE and below in libretro.h for docs */
-       NONE = 0,
-       JOYPAD = 1,
-       MOUSE = 2,
-       KEYBOARD = 3,
-       LIGHTGUN = 4,
-       ANALOG = 5,
-       POINTER = 6;
-
-       /**
-        * Gets the basic type of a device type.
-        *
-        * Applies the type mask on a DeviceType to get its basic type.
-        * If the device type is already basic, it will return the same type.
-        *
-        * E.g DeviceType.JOYPAD_MULTITAP.get_basic_type () returns
-        * DeviceType.JOYPAD, and DeviceType.JOYPAD.get_basic_type () also
-        * returns Type.JOYPAD.
-        *
-        * @return the basic type of a device type
-        */
-       public DeviceType get_basic_type () {
-               return this & DeviceType.TYPE_MASK;
-       }
-}
-
-/**
  * The input types of a joypad.
  */
 public enum JoypadId {
diff --git a/retro-gtk/retro-device-type.h b/retro-gtk/retro-device-type.h
new file mode 100644
index 0000000..d580588
--- /dev/null
+++ b/retro-gtk/retro-device-type.h
@@ -0,0 +1,37 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#ifndef RETRO_DEVICE_TYPE_H
+#define RETRO_DEVICE_TYPE_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+/**
+ * RetroJoypadId:
+ * @RETRO_DEVICE_TYPE_NONE: No input decive.
+ * @RETRO_DEVICE_TYPE_JOYPAD: A classic gamepad, see #RetroJoypadId.
+ * @RETRO_DEVICE_TYPE_MOUSE: A simple mouse.
+ * @RETRO_DEVICE_TYPE_KEYBOARD: A keyboard.
+ * @RETRO_DEVICE_TYPE_LIGHTGUN: A lightgun.
+ * @RETRO_DEVICE_TYPE_ANALOG: A gamepad with analog sticks.
+ * @RETRO_DEVICE_TYPE_POINTER: A screen pointer.
+ * @RETRO_DEVICE_TYPE_TYPE_MASK:
+ *
+ * Represents the base types for Libretro input devices.
+ */
+typedef enum
+{
+  RETRO_DEVICE_TYPE_NONE = 0,
+  RETRO_DEVICE_TYPE_JOYPAD = 1,
+  RETRO_DEVICE_TYPE_MOUSE = 2,
+  RETRO_DEVICE_TYPE_KEYBOARD = 3,
+  RETRO_DEVICE_TYPE_LIGHTGUN = 4,
+  RETRO_DEVICE_TYPE_ANALOG = 5,
+  RETRO_DEVICE_TYPE_POINTER = 6,
+  RETRO_DEVICE_TYPE_TYPE_MASK = 0xff,
+} RetroDeviceType;
+
+G_END_DECLS
+
+#endif /* RETRO_DEVICE_TYPE_H */
diff --git a/retro-gtk/vapi/retro-device-type.vapi b/retro-gtk/vapi/retro-device-type.vapi
new file mode 100644
index 0000000..208723a
--- /dev/null
+++ b/retro-gtk/vapi/retro-device-type.vapi
@@ -0,0 +1,13 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+[CCode (cheader_filename = "retro-device-type.h")]
+public enum Retro.DeviceType {
+       TYPE_MASK = 0xff,
+       NONE = 0,
+       JOYPAD = 1,
+       MOUSE = 2,
+       KEYBOARD = 3,
+       LIGHTGUN = 4,
+       ANALOG = 5,
+       POINTER = 6,
+}


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