[gnome-games/wip/abhinavsingh/gamepad-config: 15/22] gamepad: Add 'name' & 'guid' properties to Gamepad



commit 2e2e4a3fea5db841c80257f8971ce6f3b1704e3d
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.

 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 79e6d2d..4ad7baa 100644
--- a/src/gamepad/gamepad.c
+++ b/src/gamepad/gamepad.c
@@ -222,6 +222,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);
+}
+
 void
 games_gamepad_set_mapping (GamesGamepad        *self,
                            GamesGamepadMapping *mapping)
diff --git a/src/gamepad/gamepad.h b/src/gamepad/gamepad.h
index 9a232e0..3916d5b 100644
--- a/src/gamepad/gamepad.h
+++ b/src/gamepad/gamepad.h
@@ -14,6 +14,8 @@ G_BEGIN_DECLS
 G_DECLARE_FINAL_TYPE (GamesGamepad, games_gamepad, GAMES, GAMEPAD, GObject)
 
 GamesGamepad *games_gamepad_new (GamesRawGamepad *raw_gamepad);
+const gchar *games_gamepad_get_guid (GamesGamepad *self);
+const gchar *games_gamepad_get_name (GamesGamepad *self);
 void games_gamepad_set_mapping (GamesGamepad        *self,
                                 GamesGamepadMapping *mapping);
 
diff --git a/src/gamepad/gamepad.vapi b/src/gamepad/gamepad.vapi
index d651c5a..67d05c4 100644
--- a/src/gamepad/gamepad.vapi
+++ b/src/gamepad/gamepad.vapi
@@ -9,5 +9,7 @@ private class Games.Gamepad : GLib.Object {
        public signal void hat_event (Event event);
        public signal void unplugged ();
        public Gamepad (RawGamepad raw_gamepad);
+       public string guid { get; }
+       public string name { get; }
        public void set_mapping (GamepadMapping? mapping);
 }
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]