[gnome-games/wip/aplazas/gamepad-config: 3/26] gamepad: Add 'name' & 'guid' properties to Gamepad



commit fef1477ef1c067adc1c107f67b6b3bb1629ffba8
Author: theawless <theawless gmail com>
Date:   Sat May 20 13:08:58 2017 +0530

    gamepad: Add 'name' & 'guid' properties to Gamepad
    
    These will be used to build mappings for gamepads in subsequent commits.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780754

 src/gamepad/gamepad.c                 |   12 ++++++++++++
 src/gamepad/gamepad.h                 |    2 ++
 src/gamepad/gamepad.vapi              |    2 ++
 src/gamepad/linux/linux-raw-gamepad.c |   11 +++++++++++
 src/gamepad/raw-gamepad.c             |    8 ++++++++
 src/gamepad/raw-gamepad.h             |    2 ++
 src/gamepad/raw-gamepad.vapi          |    1 +
 7 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/src/gamepad/gamepad.c b/src/gamepad/gamepad.c
index 3827bf6..8a543fd 100644
--- a/src/gamepad/gamepad.c
+++ b/src/gamepad/gamepad.c
@@ -224,6 +224,18 @@ on_unplugged (GamesRawGamepad *sender,
 
 /* Public */
 
+const gchar *
+games_gamepad_get_guid (GamesGamepad *self)
+{
+  return games_raw_gamepad_get_guid (self->raw_gamepad);
+}
+
+const gchar *
+games_gamepad_get_name (GamesGamepad *self)
+{
+  return games_raw_gamepad_get_name (self->raw_gamepad);
+}
+
 // FIXME
 GamesGamepad *
 games_gamepad_new (GamesRawGamepad  *raw_gamepad,
diff --git a/src/gamepad/gamepad.h b/src/gamepad/gamepad.h
index cb8c1a0..16d0db4 100644
--- a/src/gamepad/gamepad.h
+++ b/src/gamepad/gamepad.h
@@ -14,6 +14,8 @@ G_DECLARE_FINAL_TYPE (GamesGamepad, games_gamepad, GAMES, GAMEPAD, GObject)
 
 GamesGamepad *games_gamepad_new (GamesRawGamepad  *raw_gamepad,
                                  GError          **error);
+const gchar *games_gamepad_get_guid (GamesGamepad *self);
+const gchar *games_gamepad_get_name (GamesGamepad *self);
 
 G_END_DECLS
 
diff --git a/src/gamepad/gamepad.vapi b/src/gamepad/gamepad.vapi
index e52b030..52006a0 100644
--- a/src/gamepad/gamepad.vapi
+++ b/src/gamepad/gamepad.vapi
@@ -8,5 +8,7 @@ private class Games.Gamepad : GLib.Object {
        public signal void axis_event (Event event);
        public signal void hat_event (Event event);
        public signal void unplugged ();
+       public string guid { get; }
+       public string name { get; }
        public Gamepad (RawGamepad raw_gamepad) throws GLib.Error;
 }
diff --git a/src/gamepad/linux/linux-raw-gamepad.c b/src/gamepad/linux/linux-raw-gamepad.c
index 5ff11a8..475e95e 100644
--- a/src/gamepad/linux/linux-raw-gamepad.c
+++ b/src/gamepad/linux/linux-raw-gamepad.c
@@ -96,6 +96,16 @@ get_guid (GamesRawGamepad *base)
   return self->guid;
 }
 
+static const gchar *
+get_name (GamesRawGamepad *base)
+{
+  GamesLinuxRawGamepad *self;
+
+  self = GAMES_LINUX_RAW_GAMEPAD (base);
+
+  return libevdev_get_name (self->device);
+}
+
 static struct input_absinfo *_abs_info_dup (struct input_absinfo *self);
 
 static gdouble
@@ -384,6 +394,7 @@ static void
 games_raw_gamepad_interface_init (GamesRawGamepadInterface *interface)
 {
   interface->get_guid = get_guid;
+  interface->get_name = get_name;
 }
 
 static void
diff --git a/src/gamepad/raw-gamepad.c b/src/gamepad/raw-gamepad.c
index aebb8b9..b94184e 100644
--- a/src/gamepad/raw-gamepad.c
+++ b/src/gamepad/raw-gamepad.c
@@ -39,6 +39,14 @@ games_raw_gamepad_get_guid (GamesRawGamepad *self)
   return GAMES_RAW_GAMEPAD_GET_IFACE (self)->get_guid (self);
 }
 
+const gchar *
+games_raw_gamepad_get_name (GamesRawGamepad *self)
+{
+  g_return_val_if_fail (self != NULL, NULL);
+
+  return GAMES_RAW_GAMEPAD_GET_IFACE (self)->get_name (self);
+}
+
 /* Type */
 
 static void
diff --git a/src/gamepad/raw-gamepad.h b/src/gamepad/raw-gamepad.h
index acf0d97..262e00a 100644
--- a/src/gamepad/raw-gamepad.h
+++ b/src/gamepad/raw-gamepad.h
@@ -15,9 +15,11 @@ struct _GamesRawGamepadInterface {
   GTypeInterface parent;
 
   const gchar *(*get_guid) (GamesRawGamepad *self);
+  const gchar *(*get_name) (GamesRawGamepad *self);
 };
 
 const gchar *games_raw_gamepad_get_guid (GamesRawGamepad *self);
+const gchar *games_raw_gamepad_get_name (GamesRawGamepad *self);
 
 G_END_DECLS
 
diff --git a/src/gamepad/raw-gamepad.vapi b/src/gamepad/raw-gamepad.vapi
index 7c4099d..42e1704 100644
--- a/src/gamepad/raw-gamepad.vapi
+++ b/src/gamepad/raw-gamepad.vapi
@@ -5,4 +5,5 @@ private interface Games.RawGamepad : GLib.Object {
        public abstract signal void event (Event event);
        public abstract signal void unplugged ();
        public abstract string guid { get; }
+       public abstract string name { get; }
 }


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