[gnome-games] gamepad: Add the 'event' signal to Gamepad



commit ae3f974d7fe9232bae052b50e7e5d7947522dce5
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Fri May 12 08:37:51 2017 +0200

    gamepad: Add the 'event' signal to Gamepad
    
    This will be used to propagate gamepad events from the raw gamepad.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=782611

 src/gamepad/gamepad.c    |   15 +++++++++++++++
 src/gamepad/gamepad.vapi |    1 +
 2 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/src/gamepad/gamepad.c b/src/gamepad/gamepad.c
index 6183acb..b980f20 100644
--- a/src/gamepad/gamepad.c
+++ b/src/gamepad/gamepad.c
@@ -3,6 +3,7 @@
 #include "gamepad.h"
 
 #include <stdlib.h>
+#include "../event/event.h"
 #include "gamepad-mapping.h"
 #include "gamepad-mappings-manager.h"
 
@@ -16,6 +17,7 @@ struct _GamesGamepad {
 G_DEFINE_TYPE (GamesGamepad, games_gamepad, G_TYPE_OBJECT)
 
 enum {
+  SIGNAL_EVENT,
   SIGNAL_BUTTON_EVENT,
   SIGNAL_AXIS_EVENT,
   SIGNAL_UNPLUGGED,
@@ -278,6 +280,19 @@ static void games_gamepad_class_init (GamesGamepadClass *klass) {
   G_OBJECT_CLASS (klass)->finalize = finalize;
 
   /**
+   * GamesGamepad::event:
+   * @event: the event emitted by the gamepad
+   **/
+  signals[SIGNAL_EVENT] =
+    g_signal_new ("event",
+                  GAMES_TYPE_GAMEPAD,
+                  G_SIGNAL_RUN_LAST,
+                  0, NULL, NULL,
+                  g_cclosure_marshal_VOID__BOXED,
+                  G_TYPE_NONE, 1,
+                  GAMES_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+  /**
    * GamesGamepad::axis-event:
    * @button: the code representing the button
    * @value: %TRUE if the button is pressed, %FALSE otherwise
diff --git a/src/gamepad/gamepad.vapi b/src/gamepad/gamepad.vapi
index 42e7aa7..21bcc0d 100644
--- a/src/gamepad/gamepad.vapi
+++ b/src/gamepad/gamepad.vapi
@@ -2,6 +2,7 @@
 
 [CCode (cheader_filename = "gamepad.h")]
 private class Games.Gamepad : GLib.Object {
+       public signal void event (Event event);
        public signal void button_event (StandardGamepadButton button, bool value);
        public signal void axis_event (StandardGamepadAxis axis, double value);
        public signal void unplugged ();


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