/* gamepad-mapper.c generated by valac 0.36.12.13-3ae08, the Vala compiler
 * generated from gamepad-mapper.vala, do not modify */

/* This file is part of GNOME Games. License: GPL-3.0+.*/

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <libmanette.h>
#include <stdlib.h>
#include <string.h>
#include <linux/input-event-codes.h>
#include <float.h>
#include <math.h>
#include <glib/gi18n-lib.h>


#define GAMES_TYPE_GAMEPAD_MAPPER (games_gamepad_mapper_get_type ())
#define GAMES_GAMEPAD_MAPPER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_GAMEPAD_MAPPER, GamesGamepadMapper))
#define GAMES_GAMEPAD_MAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_GAMEPAD_MAPPER, GamesGamepadMapperClass))
#define GAMES_IS_GAMEPAD_MAPPER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_GAMEPAD_MAPPER))
#define GAMES_IS_GAMEPAD_MAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_GAMEPAD_MAPPER))
#define GAMES_GAMEPAD_MAPPER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_GAMEPAD_MAPPER, GamesGamepadMapperClass))

typedef struct _GamesGamepadMapper GamesGamepadMapper;
typedef struct _GamesGamepadMapperClass GamesGamepadMapperClass;
typedef struct _GamesGamepadMapperPrivate GamesGamepadMapperPrivate;

#define GAMES_TYPE_GAMEPAD_VIEW (games_gamepad_view_get_type ())
#define GAMES_GAMEPAD_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_GAMEPAD_VIEW, GamesGamepadView))
#define GAMES_GAMEPAD_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_GAMEPAD_VIEW, GamesGamepadViewClass))
#define GAMES_IS_GAMEPAD_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_GAMEPAD_VIEW))
#define GAMES_IS_GAMEPAD_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_GAMEPAD_VIEW))
#define GAMES_GAMEPAD_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_GAMEPAD_VIEW, GamesGamepadViewClass))

typedef struct _GamesGamepadView GamesGamepadView;
typedef struct _GamesGamepadViewClass GamesGamepadViewClass;

#define GAMES_TYPE_GAMEPAD_MAPPING_BUILDER (games_gamepad_mapping_builder_get_type ())
#define GAMES_GAMEPAD_MAPPING_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_GAMEPAD_MAPPING_BUILDER, GamesGamepadMappingBuilder))
#define GAMES_GAMEPAD_MAPPING_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_GAMEPAD_MAPPING_BUILDER, GamesGamepadMappingBuilderClass))
#define GAMES_IS_GAMEPAD_MAPPING_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_GAMEPAD_MAPPING_BUILDER))
#define GAMES_IS_GAMEPAD_MAPPING_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_GAMEPAD_MAPPING_BUILDER))
#define GAMES_GAMEPAD_MAPPING_BUILDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_GAMEPAD_MAPPING_BUILDER, GamesGamepadMappingBuilderClass))

typedef struct _GamesGamepadMappingBuilder GamesGamepadMappingBuilder;
typedef struct _GamesGamepadMappingBuilderClass GamesGamepadMappingBuilderClass;

#define GAMES_TYPE_GAMEPAD_INPUT (games_gamepad_input_get_type ())
typedef struct _GamesGamepadInput GamesGamepadInput;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GAMES_TYPE_GAMEPAD_VIEW_CONFIGURATION (games_gamepad_view_configuration_get_type ())

#define GAMES_TYPE_GAMEPAD_INPUT_PATH (games_gamepad_input_path_get_type ())
typedef struct _GamesGamepadInputPath GamesGamepadInputPath;
typedef struct _GamesGamepadViewConfiguration GamesGamepadViewConfiguration;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
enum  {
	GAMES_GAMEPAD_MAPPER_FINISHED_SIGNAL,
	GAMES_GAMEPAD_MAPPER_NUM_SIGNALS
};
static guint games_gamepad_mapper_signals[GAMES_GAMEPAD_MAPPER_NUM_SIGNALS] = {0};

struct _GamesGamepadMapper {
	GtkBox parent_instance;
	GamesGamepadMapperPrivate * priv;
};

struct _GamesGamepadMapperClass {
	GtkBoxClass parent_class;
};

struct _GamesGamepadInput {
	guint16 type;
	guint16 code;
};

struct _GamesGamepadMapperPrivate {
	GamesGamepadView* gamepad_view;
	GtkLabel* info_message;
	ManetteDevice* device;
	GamesGamepadMappingBuilder* mapping_builder;
	GamesGamepadInput* mapping_inputs;
	gint mapping_inputs_length1;
	gint _mapping_inputs_size_;
	GamesGamepadInput input;
	guint current_input_index;
	gulong gamepad_event_handler_id;
};

struct _GamesGamepadInputPath {
	GamesGamepadInput input;
	gchar* path;
};

struct _GamesGamepadViewConfiguration {
	gchar* svg_path;
	GamesGamepadInputPath* input_paths;
	gint input_paths_length1;
	gint _input_paths_size_;
};


static gpointer games_gamepad_mapper_parent_class = NULL;

GType games_gamepad_mapper_get_type (void) G_GNUC_CONST;
GType games_gamepad_view_get_type (void) G_GNUC_CONST;
GType games_gamepad_mapping_builder_get_type (void) G_GNUC_CONST;
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);
#define GAMES_GAMEPAD_MAPPER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_GAMEPAD_MAPPER, GamesGamepadMapperPrivate))
enum  {
	GAMES_GAMEPAD_MAPPER_0_PROPERTY
};
GType games_gamepad_view_configuration_get_type (void) G_GNUC_CONST;
GType games_gamepad_input_path_get_type (void) G_GNUC_CONST;
GamesGamepadInputPath* games_gamepad_input_path_dup (const GamesGamepadInputPath* self);
void games_gamepad_input_path_free (GamesGamepadInputPath* self);
void games_gamepad_input_path_copy (const GamesGamepadInputPath* self, GamesGamepadInputPath* dest);
void games_gamepad_input_path_destroy (GamesGamepadInputPath* self);
GamesGamepadViewConfiguration* games_gamepad_view_configuration_dup (const GamesGamepadViewConfiguration* self);
void games_gamepad_view_configuration_free (GamesGamepadViewConfiguration* self);
void games_gamepad_view_configuration_copy (const GamesGamepadViewConfiguration* self, GamesGamepadViewConfiguration* dest);
void games_gamepad_view_configuration_destroy (GamesGamepadViewConfiguration* self);
GamesGamepadMapper* games_gamepad_mapper_new (ManetteDevice* device, GamesGamepadViewConfiguration* configuration, GamesGamepadInput* mapping_inputs, int mapping_inputs_length1);
GamesGamepadMapper* games_gamepad_mapper_construct (GType object_type, ManetteDevice* device, GamesGamepadViewConfiguration* configuration, GamesGamepadInput* mapping_inputs, int mapping_inputs_length1);
static GamesGamepadInput* _vala_array_dup13 (GamesGamepadInput* self, int length);
void games_gamepad_view_set_configuration (GamesGamepadView* self, GamesGamepadViewConfiguration* configuration, GError** error);
void games_gamepad_mapper_start (GamesGamepadMapper* self);
GamesGamepadMappingBuilder* games_gamepad_mapping_builder_new (void);
GamesGamepadMappingBuilder* games_gamepad_mapping_builder_construct (GType object_type);
static void games_gamepad_mapper_connect_to_gamepad (GamesGamepadMapper* self);
static void games_gamepad_mapper_next_input (GamesGamepadMapper* self);
void games_gamepad_mapper_stop (GamesGamepadMapper* self);
static void games_gamepad_mapper_disconnect_from_gamepad (GamesGamepadMapper* self);
static void games_gamepad_mapper_on_skip_clicked (GamesGamepadMapper* self);
static void _games_gamepad_mapper_on_skip_clicked_gtk_button_clicked (GtkButton* _sender, gpointer self);
static void games_gamepad_mapper_on_event (GamesGamepadMapper* self, ManetteEvent* event);
static void _games_gamepad_mapper_on_event_manette_device_event (ManetteDevice* _sender, ManetteEvent* event, gpointer self);
gboolean games_gamepad_mapping_builder_set_button_mapping (GamesGamepadMappingBuilder* self, guint8 hardware_index, GamesGamepadInput* source);
gboolean games_gamepad_mapping_builder_set_axis_mapping (GamesGamepadMappingBuilder* self, guint8 hardware_index, GamesGamepadInput* source);
gboolean games_gamepad_mapping_builder_set_hat_mapping (GamesGamepadMappingBuilder* self, guint8 hardware_index, gint32 value, GamesGamepadInput* source);
gchar* games_gamepad_mapping_builder_build_sdl_string (GamesGamepadMappingBuilder* self);
void games_gamepad_view_reset (GamesGamepadView* self);
gboolean games_gamepad_view_highlight (GamesGamepadView* self, GamesGamepadInput* input, gboolean highlight);
static void games_gamepad_mapper_update_info_message (GamesGamepadMapper* self);
static void games_gamepad_mapper_finalize (GObject * obj);


static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


static GamesGamepadInput* _vala_array_dup13 (GamesGamepadInput* self, int length) {
	return g_memdup (self, length * sizeof (GamesGamepadInput));
}


GamesGamepadMapper* games_gamepad_mapper_construct (GType object_type, ManetteDevice* device, GamesGamepadViewConfiguration* configuration, GamesGamepadInput* mapping_inputs, int mapping_inputs_length1) {
	GamesGamepadMapper * self = NULL;
	ManetteDevice* _tmp0_;
	ManetteDevice* _tmp1_;
	GamesGamepadInput* _tmp2_;
	gint _tmp2__length1;
	GamesGamepadInput* _tmp3_;
	gint _tmp3__length1;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (device != NULL, NULL);
	g_return_val_if_fail (configuration != NULL, NULL);
	self = (GamesGamepadMapper*) g_object_new (object_type, NULL);
	_tmp0_ = device;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->device);
	self->priv->device = _tmp1_;
	_tmp2_ = mapping_inputs;
	_tmp2__length1 = mapping_inputs_length1;
	_tmp3_ = (_tmp2_ != NULL) ? _vala_array_dup13 (_tmp2_, _tmp2__length1) : ((gpointer) _tmp2_);
	_tmp3__length1 = _tmp2__length1;
	self->priv->mapping_inputs = (g_free (self->priv->mapping_inputs), NULL);
	self->priv->mapping_inputs = _tmp3_;
	self->priv->mapping_inputs_length1 = _tmp3__length1;
	self->priv->_mapping_inputs_size_ = self->priv->mapping_inputs_length1;
	{
		GamesGamepadView* _tmp4_;
		GamesGamepadViewConfiguration _tmp5_;
		_tmp4_ = self->priv->gamepad_view;
		_tmp5_ = *configuration;
		games_gamepad_view_set_configuration (_tmp4_, &_tmp5_, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch34_g_error;
		}
	}
	goto __finally34;
	__catch34_g_error:
	{
		GError* e = NULL;
		GError* _tmp6_;
		const gchar* _tmp7_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp6_ = e;
		_tmp7_ = _tmp6_->message;
		g_critical ("gamepad-mapper.vala:27: Could not set up gamepad view: %s", _tmp7_);
		_g_error_free0 (e);
	}
	__finally34:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	return self;
}


GamesGamepadMapper* games_gamepad_mapper_new (ManetteDevice* device, GamesGamepadViewConfiguration* configuration, GamesGamepadInput* mapping_inputs, int mapping_inputs_length1) {
	return games_gamepad_mapper_construct (GAMES_TYPE_GAMEPAD_MAPPER, device, configuration, mapping_inputs, mapping_inputs_length1);
}


void games_gamepad_mapper_start (GamesGamepadMapper* self) {
	GamesGamepadMappingBuilder* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = games_gamepad_mapping_builder_new ();
	_g_object_unref0 (self->priv->mapping_builder);
	self->priv->mapping_builder = _tmp0_;
	self->priv->current_input_index = (guint) 0;
	games_gamepad_mapper_connect_to_gamepad (self);
	games_gamepad_mapper_next_input (self);
}


void games_gamepad_mapper_stop (GamesGamepadMapper* self) {
	g_return_if_fail (self != NULL);
	games_gamepad_mapper_disconnect_from_gamepad (self);
}


static void games_gamepad_mapper_on_skip_clicked (GamesGamepadMapper* self) {
	g_return_if_fail (self != NULL);
	games_gamepad_mapper_next_input (self);
}


static void _games_gamepad_mapper_on_skip_clicked_gtk_button_clicked (GtkButton* _sender, gpointer self) {
	games_gamepad_mapper_on_skip_clicked ((GamesGamepadMapper*) self);
}


static void _games_gamepad_mapper_on_event_manette_device_event (ManetteDevice* _sender, ManetteEvent* event, gpointer self) {
	games_gamepad_mapper_on_event ((GamesGamepadMapper*) self, event);
}


static void games_gamepad_mapper_connect_to_gamepad (GamesGamepadMapper* self) {
	ManetteDevice* _tmp0_;
	gulong _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->device;
	_tmp1_ = g_signal_connect_object (_tmp0_, "event", (GCallback) _games_gamepad_mapper_on_event_manette_device_event, self, 0);
	self->priv->gamepad_event_handler_id = _tmp1_;
}


static void games_gamepad_mapper_disconnect_from_gamepad (GamesGamepadMapper* self) {
	gulong _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->gamepad_event_handler_id;
	if (_tmp0_ != ((gulong) 0)) {
		ManetteDevice* _tmp1_;
		gulong _tmp2_;
		_tmp1_ = self->priv->device;
		_tmp2_ = self->priv->gamepad_event_handler_id;
		g_signal_handler_disconnect ((GObject*) _tmp1_, _tmp2_);
		self->priv->gamepad_event_handler_id = (gulong) 0;
	}
}


static void games_gamepad_mapper_on_event (GamesGamepadMapper* self, ManetteEvent* event) {
	ManetteEvent* _tmp0_;
	ManetteEventType _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (event != NULL);
	_tmp0_ = event;
	_tmp1_ = manette_event_get_event_type (_tmp0_);
	switch (_tmp1_) {
		case MANETTE_EVENT_BUTTON_RELEASE:
		{
			GamesGamepadInput _tmp2_;
			guint16 _tmp3_;
			GamesGamepadMappingBuilder* _tmp4_;
			ManetteEvent* _tmp5_;
			guint16 _tmp6_;
			GamesGamepadInput _tmp7_;
			gboolean _tmp8_;
			_tmp2_ = self->priv->input;
			_tmp3_ = _tmp2_.type;
			if (_tmp3_ == EV_ABS) {
				return;
			}
			_tmp4_ = self->priv->mapping_builder;
			_tmp5_ = event;
			_tmp6_ = manette_event_get_hardware_index (_tmp5_);
			_tmp7_ = self->priv->input;
			_tmp8_ = games_gamepad_mapping_builder_set_button_mapping (_tmp4_, (guint8) _tmp6_, &_tmp7_);
			if (!_tmp8_) {
				return;
			}
			break;
		}
		case MANETTE_EVENT_ABSOLUTE:
		{
			guint16 axis = 0U;
			gdouble value = 0.0;
			GamesGamepadInput _tmp9_;
			guint16 _tmp10_;
			ManetteEvent* _tmp11_;
			guint16 _tmp12_ = 0U;
			gdouble _tmp13_ = 0.0;
			gboolean _tmp14_;
			gdouble _tmp15_;
			gdouble _tmp16_;
			GamesGamepadMappingBuilder* _tmp17_;
			ManetteEvent* _tmp18_;
			guint16 _tmp19_;
			GamesGamepadInput _tmp20_;
			gboolean _tmp21_;
			_tmp9_ = self->priv->input;
			_tmp10_ = _tmp9_.type;
			if (_tmp10_ == EV_KEY) {
				return;
			}
			_tmp11_ = event;
			_tmp14_ = manette_event_get_absolute (_tmp11_, &_tmp12_, &_tmp13_);
			axis = _tmp12_;
			value = _tmp13_;
			if (!_tmp14_) {
				return;
			}
			_tmp15_ = value;
			_tmp16_ = _tmp15_;
			if (((-0.8) < _tmp16_) && (_tmp16_ < 0.8)) {
				return;
			}
			_tmp17_ = self->priv->mapping_builder;
			_tmp18_ = event;
			_tmp19_ = manette_event_get_hardware_index (_tmp18_);
			_tmp20_ = self->priv->input;
			_tmp21_ = games_gamepad_mapping_builder_set_axis_mapping (_tmp17_, (guint8) _tmp19_, &_tmp20_);
			if (!_tmp21_) {
				return;
			}
			break;
		}
		case MANETTE_EVENT_HAT:
		{
			guint16 axis = 0U;
			gint8 value = 0;
			ManetteEvent* _tmp22_;
			guint16 _tmp23_ = 0U;
			gint8 _tmp24_ = 0;
			gboolean _tmp25_;
			gint8 _tmp26_;
			GamesGamepadMappingBuilder* _tmp27_;
			ManetteEvent* _tmp28_;
			guint16 _tmp29_;
			gint8 _tmp30_;
			GamesGamepadInput _tmp31_;
			gboolean _tmp32_;
			_tmp22_ = event;
			_tmp25_ = manette_event_get_hat (_tmp22_, &_tmp23_, &_tmp24_);
			axis = _tmp23_;
			value = _tmp24_;
			if (!_tmp25_) {
				return;
			}
			_tmp26_ = value;
			if (((gint) _tmp26_) == 0) {
				return;
			}
			_tmp27_ = self->priv->mapping_builder;
			_tmp28_ = event;
			_tmp29_ = manette_event_get_hardware_index (_tmp28_);
			_tmp30_ = value;
			_tmp31_ = self->priv->input;
			_tmp32_ = games_gamepad_mapping_builder_set_hat_mapping (_tmp27_, (guint8) _tmp29_, (gint32) _tmp30_, &_tmp31_);
			if (!_tmp32_) {
				return;
			}
			break;
		}
		default:
		{
			return;
		}
	}
	games_gamepad_mapper_next_input (self);
}


static void games_gamepad_mapper_next_input (GamesGamepadMapper* self) {
	guint _tmp0_;
	GamesGamepadInput* _tmp1_;
	gint _tmp1__length1;
	GamesGamepadView* _tmp5_;
	GamesGamepadInput* _tmp6_;
	gint _tmp6__length1;
	guint _tmp7_;
	GamesGamepadInput _tmp8_;
	GamesGamepadView* _tmp9_;
	GamesGamepadInput _tmp10_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->current_input_index;
	_tmp1_ = self->priv->mapping_inputs;
	_tmp1__length1 = self->priv->mapping_inputs_length1;
	if (_tmp0_ == ((guint) _tmp1__length1)) {
		gchar* sdl_string = NULL;
		GamesGamepadMappingBuilder* _tmp2_;
		gchar* _tmp3_;
		const gchar* _tmp4_;
		_tmp2_ = self->priv->mapping_builder;
		_tmp3_ = games_gamepad_mapping_builder_build_sdl_string (_tmp2_);
		sdl_string = _tmp3_;
		_tmp4_ = sdl_string;
		g_signal_emit (self, games_gamepad_mapper_signals[GAMES_GAMEPAD_MAPPER_FINISHED_SIGNAL], 0, _tmp4_);
		_g_free0 (sdl_string);
		return;
	}
	_tmp5_ = self->priv->gamepad_view;
	games_gamepad_view_reset (_tmp5_);
	_tmp6_ = self->priv->mapping_inputs;
	_tmp6__length1 = self->priv->mapping_inputs_length1;
	_tmp7_ = self->priv->current_input_index;
	self->priv->current_input_index = _tmp7_ + 1;
	_tmp8_ = _tmp6_[_tmp7_];
	self->priv->input = _tmp8_;
	_tmp9_ = self->priv->gamepad_view;
	_tmp10_ = self->priv->input;
	games_gamepad_view_highlight (_tmp9_, &_tmp10_, TRUE);
	games_gamepad_mapper_update_info_message (self);
}


static void games_gamepad_mapper_update_info_message (GamesGamepadMapper* self) {
	GamesGamepadInput _tmp0_;
	guint16 _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->input;
	_tmp1_ = _tmp0_.type;
	switch (_tmp1_) {
		case EV_KEY:
		{
			GtkLabel* _tmp2_;
			_tmp2_ = self->priv->info_message;
			gtk_label_set_label (_tmp2_, _ ("Press suitable button on your gamepad"));
			break;
		}
		case EV_ABS:
		{
			gboolean _tmp3_ = FALSE;
			GamesGamepadInput _tmp4_;
			guint16 _tmp5_;
			_tmp4_ = self->priv->input;
			_tmp5_ = _tmp4_.code;
			if (_tmp5_ == ABS_X) {
				_tmp3_ = TRUE;
			} else {
				GamesGamepadInput _tmp6_;
				guint16 _tmp7_;
				_tmp6_ = self->priv->input;
				_tmp7_ = _tmp6_.code;
				_tmp3_ = _tmp7_ == ABS_RX;
			}
			if (_tmp3_) {
				GtkLabel* _tmp8_;
				_tmp8_ = self->priv->info_message;
				gtk_label_set_label (_tmp8_, _ ("Move suitable axis left/right on your gamepad"));
			} else {
				gboolean _tmp9_ = FALSE;
				GamesGamepadInput _tmp10_;
				guint16 _tmp11_;
				_tmp10_ = self->priv->input;
				_tmp11_ = _tmp10_.code;
				if (_tmp11_ == ABS_Y) {
					_tmp9_ = TRUE;
				} else {
					GamesGamepadInput _tmp12_;
					guint16 _tmp13_;
					_tmp12_ = self->priv->input;
					_tmp13_ = _tmp12_.code;
					_tmp9_ = _tmp13_ == ABS_RY;
				}
				if (_tmp9_) {
					GtkLabel* _tmp14_;
					_tmp14_ = self->priv->info_message;
					gtk_label_set_label (_tmp14_, _ ("Move suitable axis up/down on your gamepad"));
				}
			}
			break;
		}
		default:
		{
			break;
		}
	}
}


static void games_gamepad_mapper_class_init (GamesGamepadMapperClass * klass) {
	gint GamesGamepadMapper_private_offset;
	games_gamepad_mapper_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesGamepadMapperPrivate));
	G_OBJECT_CLASS (klass)->finalize = games_gamepad_mapper_finalize;
	GamesGamepadMapper_private_offset = g_type_class_get_instance_private_offset (klass);
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Games/ui/gamepad-mapper.ui");
	games_gamepad_mapper_signals[GAMES_GAMEPAD_MAPPER_FINISHED_SIGNAL] = g_signal_new ("finished", GAMES_TYPE_GAMEPAD_MAPPER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "gamepad_view", FALSE, GamesGamepadMapper_private_offset + G_STRUCT_OFFSET (GamesGamepadMapperPrivate, gamepad_view));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "info_message", FALSE, GamesGamepadMapper_private_offset + G_STRUCT_OFFSET (GamesGamepadMapperPrivate, info_message));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_skip_clicked", G_CALLBACK(_games_gamepad_mapper_on_skip_clicked_gtk_button_clicked));
}


static void games_gamepad_mapper_instance_init (GamesGamepadMapper * self) {
	self->priv = GAMES_GAMEPAD_MAPPER_GET_PRIVATE (self);
	g_type_ensure (GAMES_TYPE_GAMEPAD_VIEW);
	gtk_widget_init_template (GTK_WIDGET (self));
}


static void games_gamepad_mapper_finalize (GObject * obj) {
	GamesGamepadMapper * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_GAMEPAD_MAPPER, GamesGamepadMapper);
	_g_object_unref0 (self->priv->gamepad_view);
	_g_object_unref0 (self->priv->info_message);
	_g_object_unref0 (self->priv->device);
	_g_object_unref0 (self->priv->mapping_builder);
	self->priv->mapping_inputs = (g_free (self->priv->mapping_inputs), NULL);
	G_OBJECT_CLASS (games_gamepad_mapper_parent_class)->finalize (obj);
}


GType games_gamepad_mapper_get_type (void) {
	static volatile gsize games_gamepad_mapper_type_id__volatile = 0;
	if (g_once_init_enter (&games_gamepad_mapper_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GamesGamepadMapperClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_gamepad_mapper_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesGamepadMapper), 0, (GInstanceInitFunc) games_gamepad_mapper_instance_init, NULL };
		GType games_gamepad_mapper_type_id;
		games_gamepad_mapper_type_id = g_type_register_static (gtk_box_get_type (), "GamesGamepadMapper", &g_define_type_info, 0);
		g_once_init_leave (&games_gamepad_mapper_type_id__volatile, games_gamepad_mapper_type_id);
	}
	return games_gamepad_mapper_type_id__volatile;
}



