[gnome-games/wip/abhinavsingh/gamepad-config: 14/23] gamepad: Add set_mapping() to Gamepad
- From: Abhinav Singh <abhinavsingh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/abhinavsingh/gamepad-config: 14/23] gamepad: Add set_mapping() to Gamepad
- Date: Wed, 12 Jul 2017 12:33:09 +0000 (UTC)
commit 773587b76652d0a64c7645dbce870db7fead6ae5
Author: theawless <theawless gmail com>
Date: Wed Jun 21 02:00:46 2017 +0530
gamepad: Add set_mapping() to Gamepad
This will allow us to change mappings of Gamepad even after its
construction.
https://bugzilla.gnome.org/show_bug.cgi?id=780754
src/gamepad/gamepad.c | 11 ++++++++++-
src/gamepad/gamepad.h | 3 +++
src/gamepad/gamepad.vapi | 1 +
3 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/src/gamepad/gamepad.c b/src/gamepad/gamepad.c
index 3827bf6..64d7ae7 100644
--- a/src/gamepad/gamepad.c
+++ b/src/gamepad/gamepad.c
@@ -5,7 +5,6 @@
#include <linux/input-event-codes.h>
#include <stdlib.h>
#include "../event/event.h"
-#include "gamepad-mapping.h"
#include "gamepad-mappings-manager.h"
struct _GamesGamepad {
@@ -224,6 +223,16 @@ on_unplugged (GamesRawGamepad *sender,
/* Public */
+void
+games_gamepad_set_mapping (GamesGamepad *self,
+ GamesGamepadMapping *mapping)
+{
+ if (self->mapping != NULL)
+ g_object_unref (self->mapping);
+
+ self->mapping = mapping ? g_object_ref (mapping) : NULL;
+}
+
// FIXME
GamesGamepad *
games_gamepad_new (GamesRawGamepad *raw_gamepad,
diff --git a/src/gamepad/gamepad.h b/src/gamepad/gamepad.h
index cb8c1a0..e4fe191 100644
--- a/src/gamepad/gamepad.h
+++ b/src/gamepad/gamepad.h
@@ -5,6 +5,7 @@
#include <glib-object.h>
#include "raw-gamepad.h"
+#include "gamepad-mapping.h"
G_BEGIN_DECLS
@@ -14,6 +15,8 @@ G_DECLARE_FINAL_TYPE (GamesGamepad, games_gamepad, GAMES, GAMEPAD, GObject)
GamesGamepad *games_gamepad_new (GamesRawGamepad *raw_gamepad,
GError **error);
+void games_gamepad_set_mapping (GamesGamepad *self,
+ GamesGamepadMapping *mapping);
G_END_DECLS
diff --git a/src/gamepad/gamepad.vapi b/src/gamepad/gamepad.vapi
index e52b030..2cfc5bb 100644
--- a/src/gamepad/gamepad.vapi
+++ b/src/gamepad/gamepad.vapi
@@ -9,4 +9,5 @@ private class Games.Gamepad : GLib.Object {
public signal void hat_event (Event event);
public signal void unplugged ();
public Gamepad (RawGamepad raw_gamepad) throws GLib.Error;
+ public void set_mapping (GamepadMapping mapping);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]