[gnome-games/wip/aplazas/gamepad: 8/8] gamepad: Use GamepadInput in GamepadDPad



commit 163ba9b3a7a8a36712c98b11bae2ef0971a41992
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.

 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 d17d306..f200904 100644
--- a/src/gamepad/gamepad-mapping.c
+++ b/src/gamepad/gamepad-mapping.c
@@ -69,8 +69,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
@@ -290,8 +289,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]