[retro-gtk/c-port: 9/42] Port DeviceType to C



commit b7b9f372e2b97a62c3eaee527056720a31c34039
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   |   41 +++++++++++++++++++++++++++++++++++++++
 retro-gtk/retro-gtk.h           |    1 +
 retro-gtk/vapi/retro-gtk-c.vapi |   13 ++++++++++++
 5 files changed, 58 insertions(+), 32 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index 4db301d..5a5f5f2 100644
--- a/retro-gtk/Makefile.am
+++ b/retro-gtk/Makefile.am
@@ -30,6 +30,7 @@ dist_vapi_DATA = retro-gtk-0.12.deps
 BUILT_SOURCES = retro-gtk-internal.h
 
 retro_gtk_public_h_sources = \
+       retro-device-type.h \
        retro-gtk.h \
        retro-gtk-vala.h \
        $(NULL)
@@ -114,6 +115,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 \
@@ -180,6 +182,7 @@ EXTRA_DIST = \
        $(retro_gtk_private_h_sources) \
        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..1d4c327
--- /dev/null
+++ b/retro-gtk/retro-device-type.h
@@ -0,0 +1,41 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#ifndef RETRO_DEVICE_TYPE_H
+#define RETRO_DEVICE_TYPE_H
+
+#if !defined(__RETRO_GTK_INSIDE__) && !defined(RETRO_GTK_COMPILATION)
+# error "Only <retro-gtk.h> can be included directly."
+#endif
+
+#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 72f85f6..e9dabaa 100644
--- a/retro-gtk/retro-gtk.h
+++ b/retro-gtk/retro-gtk.h
@@ -9,6 +9,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"
 
 #undef __RETRO_GTK_INSIDE__
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]