[gnome-games] gamepad: Use GamepadInput in GamepadDPad



commit 2dc64b72d83857bc6ad94551635471a524d2ea34
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Mon May 15 14:53:03 2017 +0200

    gamepad: Use GamepadInput in GamepadDPad
    
    This makes the code simpler.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=782611

 src/gamepad/gamepad-dpad.h    |    4 ++--
 src/gamepad/gamepad-mapping.c |    6 ++----
 2 files changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/src/gamepad/gamepad-dpad.h b/src/gamepad/gamepad-dpad.h
index b344484..693304e 100644
--- a/src/gamepad/gamepad-dpad.h
+++ b/src/gamepad/gamepad-dpad.h
@@ -4,14 +4,14 @@
 #define GAMES_GAMEPAD_DPAD_H
 
 #include <glib-object.h>
+#include "gamepad-input.h"
 
 G_BEGIN_DECLS
 
 #define GAMES_TYPE_GAMEPAD_DPAD (games_gamepad_dpad_get_type ())
 
 typedef struct {
-  guint16 types[4];
-  guint16 values[4];
+  GamesGamepadInput inputs[4];
   gint32 axis_values[2];
 } GamesGamepadDPad;
 
diff --git a/src/gamepad/gamepad-mapping.c b/src/gamepad/gamepad-mapping.c
index 2327567..ea4b1c9 100644
--- a/src/gamepad/gamepad-mapping.c
+++ b/src/gamepad/gamepad-mapping.c
@@ -61,8 +61,7 @@ parse_dpad_source (GamesGamepadMapping *self,
 
   if (self->dpads->len <= dpad_index)
     g_array_set_size (self->dpads, dpad_index + 1);
-  g_array_index (self->dpads, GamesGamepadDPad, dpad_index).types[dpad_position] = destination.type;
-  g_array_index (self->dpads, GamesGamepadDPad, dpad_index).values[dpad_position] = destination.code;
+  g_array_index (self->dpads, GamesGamepadDPad, dpad_index).inputs[dpad_position] = destination;
 }
 
 static void
@@ -282,8 +281,7 @@ games_gamepad_mapping_get_dpad_mapping (GamesGamepadMapping *self,
   // We add 4 so that the remainder is always positive.
   dpad_position = (dpad_changed_value + dpad_axis + 4) % 4;
   dpad->axis_values[dpad_axis] = dpad_value;
-  destination->type = dpad->types[dpad_position];
-  destination->code = dpad->values[dpad_position];
+  *destination = dpad->inputs[dpad_position];
 }
 
 void


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