Commit 804fa2a7 authored by Adrien Plazas's avatar Adrien Plazas
Browse files

gamepad: Rename GamepadMappedEvent into GamepadInput

This better reflect the goal of the type and make it shorter.

https://bugzilla.gnome.org/show_bug.cgi?id=782611
parent 3ef5bcc1
......@@ -77,7 +77,7 @@ gnome_games_SOURCES = \
\
gamepad/gamepad.c \
gamepad/gamepad-dpad.c \
gamepad/gamepad-mapped-event.c \
gamepad/gamepad-input.c \
gamepad/gamepad-mapping.c \
gamepad/gamepad-mapping-error.c \
gamepad/gamepad-mappings-manager.c \
......
// This file is part of GNOME Games. License: GPL-3.0+.
#include "gamepad-mapped-event.h"
#include "gamepad-input.h"
#include <string.h>
GamesGamepadMappedEvent *
games_gamepad_mapped_event_dup (const GamesGamepadMappedEvent *self)
GamesGamepadInput *
games_gamepad_input_dup (const GamesGamepadInput *self)
{
GamesGamepadMappedEvent *dup;
GamesGamepadInput *dup;
dup = g_new0 (GamesGamepadMappedEvent, 1);
memcpy (dup, self, sizeof (GamesGamepadMappedEvent));
dup = g_new0 (GamesGamepadInput, 1);
memcpy (dup, self, sizeof (GamesGamepadInput));
return dup;
}
void
games_gamepad_mapped_event_free (GamesGamepadMappedEvent *self)
games_gamepad_input_free (GamesGamepadInput *self)
{
g_free (self);
}
GType
games_gamepad_mapped_event_get_type (void)
games_gamepad_input_get_type (void)
{
static volatile gsize type_id = 0;
if (g_once_init_enter (&type_id))
g_once_init_leave (&type_id,
g_boxed_type_register_static ("GamesGamepadMappedEvent",
(GBoxedCopyFunc) games_gamepad_mapped_event_dup,
(GBoxedFreeFunc) games_gamepad_mapped_event_free));
g_boxed_type_register_static ("GamesGamepadInput",
(GBoxedCopyFunc) games_gamepad_input_dup,
(GBoxedFreeFunc) games_gamepad_input_free));
return type_id;
}
// This file is part of GNOME Games. License: GPL-3.0+.
#ifndef GAMES_GAMEPAD_INPUT_H
#define GAMES_GAMEPAD_INPUT_H
#include <glib-object.h>
G_BEGIN_DECLS
#define GAMES_TYPE_GAMEPAD_INPUT (games_gamepad_input_get_type ())
typedef struct {
guint16 type;
guint16 axis;
guint16 button;
} GamesGamepadInput;
GType games_gamepad_input_get_type (void) G_GNUC_CONST;
GamesGamepadInput *games_gamepad_input_dup (const GamesGamepadInput *self);
void games_gamepad_input_free (GamesGamepadInput *self);
G_END_DECLS
#endif /* GAMES_GAMEPAD_INPUT_H */
// This file is part of GNOME Games. License: GPL-3.0+.
#ifndef GAMES_GAMEPAD_MAPPED_EVENT_H
#define GAMES_GAMEPAD_MAPPED_EVENT_H
#include <glib-object.h>
G_BEGIN_DECLS
#define GAMES_TYPE_GAMEPAD_MAPPED_EVENT (games_gamepad_mapped_event_get_type ())
typedef struct {
guint16 type;
guint16 axis;
guint16 button;
} GamesGamepadMappedEvent;
GType games_gamepad_mapped_event_get_type (void) G_GNUC_CONST;
GamesGamepadMappedEvent *games_gamepad_mapped_event_dup (const GamesGamepadMappedEvent *self);
void games_gamepad_mapped_event_free (GamesGamepadMappedEvent *self);
G_END_DECLS
#endif /* GAMES_GAMEPAD_MAPPED_EVENT_H */
......@@ -335,11 +335,11 @@ games_gamepad_mapping_new_from_sdl_string (const gchar *mapping_string,
}
void
games_gamepad_mapping_get_dpad_mapping (GamesGamepadMapping *self,
gint dpad_index,
gint dpad_axis,
gint dpad_value,
GamesGamepadMappedEvent *event)
games_gamepad_mapping_get_dpad_mapping (GamesGamepadMapping *self,
gint dpad_index,
gint dpad_axis,
gint dpad_value,
GamesGamepadInput *event)
{
GamesGamepadDPad *dpad;
gint dpad_changed_value;
......@@ -348,7 +348,7 @@ games_gamepad_mapping_get_dpad_mapping (GamesGamepadMapping *self,
g_return_if_fail (self != NULL);
g_return_if_fail (event != NULL);
memset (event, 0, sizeof (GamesGamepadMappedEvent));
memset (event, 0, sizeof (GamesGamepadInput));
dpad = &g_array_index (self->dpads, GamesGamepadDPad, dpad_index);
dpad_changed_value = (dpad_value == 0) ?
......@@ -374,14 +374,14 @@ games_gamepad_mapping_get_dpad_mapping (GamesGamepadMapping *self,
}
void
games_gamepad_mapping_get_axis_mapping (GamesGamepadMapping *self,
gint axis_number,
GamesGamepadMappedEvent *event)
games_gamepad_mapping_get_axis_mapping (GamesGamepadMapping *self,
gint axis_number,
GamesGamepadInput *event)
{
g_return_if_fail (self != NULL);
g_return_if_fail (event != NULL);
memset (event, 0, sizeof (GamesGamepadMappedEvent));
memset (event, 0, sizeof (GamesGamepadInput));
event->type = (axis_number < self->axes->len) ?
g_array_index (self->axes, input_t, axis_number).type :
......@@ -402,14 +402,14 @@ games_gamepad_mapping_get_axis_mapping (GamesGamepadMapping *self,
}
void
games_gamepad_mapping_get_button_mapping (GamesGamepadMapping *self,
gint button_number,
GamesGamepadMappedEvent *event)
games_gamepad_mapping_get_button_mapping (GamesGamepadMapping *self,
gint button_number,
GamesGamepadInput *event)
{
g_return_if_fail (self != NULL);
g_return_if_fail (event != NULL);
memset (event, 0, sizeof (GamesGamepadMappedEvent));
memset (event, 0, sizeof (GamesGamepadInput));
event->type = (button_number < self->buttons->len) ?
g_array_index (self->buttons, input_t, button_number).type :
......
......@@ -4,7 +4,7 @@
#define GAMES_GAMEPAD_MAPPING_H
#include <glib-object.h>
#include "gamepad-mapped-event.h"
#include "gamepad-input.h"
G_BEGIN_DECLS
......@@ -14,17 +14,17 @@ G_DECLARE_FINAL_TYPE (GamesGamepadMapping, games_gamepad_mapping, GAMES, GAMEPAD
GamesGamepadMapping *games_gamepad_mapping_new_from_sdl_string (const gchar *mapping_string,
GError **error);
void games_gamepad_mapping_get_dpad_mapping (GamesGamepadMapping *self,
gint dpad_index,
gint dpad_axis,
gint dpad_value,
GamesGamepadMappedEvent *result);
void games_gamepad_mapping_get_axis_mapping (GamesGamepadMapping *self,
gint axis_number,
GamesGamepadMappedEvent *result);
void games_gamepad_mapping_get_button_mapping (GamesGamepadMapping *self,
gint button_number,
GamesGamepadMappedEvent *result);
void games_gamepad_mapping_get_dpad_mapping (GamesGamepadMapping *self,
gint dpad_index,
gint dpad_axis,
gint dpad_value,
GamesGamepadInput *result);
void games_gamepad_mapping_get_axis_mapping (GamesGamepadMapping *self,
gint axis_number,
GamesGamepadInput *result);
void games_gamepad_mapping_get_button_mapping (GamesGamepadMapping *self,
gint button_number,
GamesGamepadInput *result);
G_END_DECLS
......
......@@ -35,7 +35,7 @@ on_button_event (GamesRawGamepad *sender,
gpointer data)
{
GamesGamepad *self;
GamesGamepadMappedEvent event;
GamesGamepadInput event;
gboolean value;
self = GAMES_GAMEPAD (data);
......@@ -86,7 +86,7 @@ on_axis_event (GamesRawGamepad *sender,
gpointer data)
{
GamesGamepad *self;
GamesGamepadMappedEvent event;
GamesGamepadInput event;
self = GAMES_GAMEPAD (data);
......@@ -117,7 +117,7 @@ on_hat_event (GamesRawGamepad *sender,
gpointer data)
{
GamesGamepad *self;
GamesGamepadMappedEvent event;
GamesGamepadInput event;
self = GAMES_GAMEPAD (data);
......@@ -174,7 +174,6 @@ on_event (GamesRawGamepad *sender,
gpointer data)
{
GamesGamepad *self;
GamesGamepadMappedEvent mapped_event;
self = GAMES_GAMEPAD (data);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment