[gnome-games/wip/abhinavsingh/gamepad-config: 11/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: 11/23] gamepad: Add set_mapping() to Gamepad
- Date: Sat, 22 Jul 2017 20:03:33 +0000 (UTC)
commit 80c37943e7ccfbc5150e96dad9db3c33cfc140e2
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 mapping of a Gamepad even after its
construction.
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..ae564c2 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]