[retro-gtk/wip/aplazas/port-module-query: 7/24] Port DeviceType to C



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

    Port DeviceType to C

 retro-gtk/Makefile.am           |    3 +++
 retro-gtk/input/device.vala     |   32 --------------------------------
 retro-gtk/retro-device-type.h   |   37 +++++++++++++++++++++++++++++++++++++
 retro-gtk/retro-gtk.h           |    1 +
 retro-gtk/vapi/retro-gtk-c.vapi |   13 +++++++++++++
 5 files changed, 54 insertions(+), 32 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index 499dbac..ca24d2c 100644
--- a/retro-gtk/Makefile.am
+++ b/retro-gtk/Makefile.am
@@ -92,6 +92,7 @@ libretro_gtk_la_VALAFLAGS = \
        --pkg gtk+-3.0 \
        --pkg libpulse \
        --pkg libpulse-simple \
+       --pkg retro-gtk-c \
        --vapidir=vapi \
        --thread \
        --target-glib 2.32 \
@@ -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 \
        retro-gtk-vala.h \
        retro-option.h \
@@ -170,6 +172,7 @@ EXTRA_DIST = \
        retro-system-info.h \
        retro-gtk-0.12.pc.in \
        update-from-retroarch.sh \
+       vapi/retro-gtk-c.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..4aea6aa
--- /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
+
+/**
+ * RetroDeviceType:
+ * @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/retro-gtk.h b/retro-gtk/retro-gtk.h
index a520b61..9c628b1 100644
--- a/retro-gtk/retro-gtk.h
+++ b/retro-gtk/retro-gtk.h
@@ -7,6 +7,7 @@
 #error    retro-gtk is unstable API. You must define RETRO_GTK_USE_UNSTABLE_API before including retro-gtk.h
 #endif
 
+#include "retro-device-type.h"
 #include "retro-gtk-vala.h"
 
 #endif
diff --git a/retro-gtk/vapi/retro-gtk-c.vapi b/retro-gtk/vapi/retro-gtk-c.vapi
new file mode 100644
index 0000000..208723a
--- /dev/null
+++ b/retro-gtk/vapi/retro-gtk-c.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]