/* preferences-subpage-gamepad.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from preferences-subpage-gamepad.vala, do not modify */

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

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

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#define GAMES_TYPE_PREFERENCES_SUBPAGE (games_preferences_subpage_get_type ())
#define GAMES_PREFERENCES_SUBPAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PREFERENCES_SUBPAGE, GamesPreferencesSubpage))
#define GAMES_IS_PREFERENCES_SUBPAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PREFERENCES_SUBPAGE))
#define GAMES_PREFERENCES_SUBPAGE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GAMES_TYPE_PREFERENCES_SUBPAGE, GamesPreferencesSubpageIface))

typedef struct _GamesPreferencesSubpage GamesPreferencesSubpage;
typedef struct _GamesPreferencesSubpageIface GamesPreferencesSubpageIface;

#define GAMES_TYPE_PREFERENCES_SUBPAGE_GAMEPAD (games_preferences_subpage_gamepad_get_type ())
#define GAMES_PREFERENCES_SUBPAGE_GAMEPAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PREFERENCES_SUBPAGE_GAMEPAD, GamesPreferencesSubpageGamepad))
#define GAMES_PREFERENCES_SUBPAGE_GAMEPAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_PREFERENCES_SUBPAGE_GAMEPAD, GamesPreferencesSubpageGamepadClass))
#define GAMES_IS_PREFERENCES_SUBPAGE_GAMEPAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PREFERENCES_SUBPAGE_GAMEPAD))
#define GAMES_IS_PREFERENCES_SUBPAGE_GAMEPAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_PREFERENCES_SUBPAGE_GAMEPAD))
#define GAMES_PREFERENCES_SUBPAGE_GAMEPAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_PREFERENCES_SUBPAGE_GAMEPAD, GamesPreferencesSubpageGamepadClass))

typedef struct _GamesPreferencesSubpageGamepad GamesPreferencesSubpageGamepad;
typedef struct _GamesPreferencesSubpageGamepadClass GamesPreferencesSubpageGamepadClass;
typedef struct _GamesPreferencesSubpageGamepadPrivate GamesPreferencesSubpageGamepadPrivate;
typedef enum  {
	GAMES_PREFERENCES_SUBPAGE_GAMEPAD_STATE_TEST,
	GAMES_PREFERENCES_SUBPAGE_GAMEPAD_STATE_CONFIGURE
} GamesPreferencesSubpageGamepadState;

#define GAMES_PREFERENCES_SUBPAGE_GAMEPAD_TYPE_STATE (games_preferences_subpage_gamepad_state_get_type ())

#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;

#define GAMES_TYPE_GAMEPAD_TESTER (games_gamepad_tester_get_type ())
#define GAMES_GAMEPAD_TESTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_GAMEPAD_TESTER, GamesGamepadTester))
#define GAMES_GAMEPAD_TESTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_GAMEPAD_TESTER, GamesGamepadTesterClass))
#define GAMES_IS_GAMEPAD_TESTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_GAMEPAD_TESTER))
#define GAMES_IS_GAMEPAD_TESTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_GAMEPAD_TESTER))
#define GAMES_GAMEPAD_TESTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_GAMEPAD_TESTER, GamesGamepadTesterClass))

typedef struct _GamesGamepadTester GamesGamepadTester;
typedef struct _GamesGamepadTesterClass GamesGamepadTesterClass;
enum  {
	GAMES_PREFERENCES_SUBPAGE_GAMEPAD_0_PROPERTY,
	GAMES_PREFERENCES_SUBPAGE_GAMEPAD_ALLOW_BACK_PROPERTY,
	GAMES_PREFERENCES_SUBPAGE_GAMEPAD_INFO_MESSAGE_PROPERTY,
	GAMES_PREFERENCES_SUBPAGE_GAMEPAD_DEVICE_PROPERTY,
	GAMES_PREFERENCES_SUBPAGE_GAMEPAD_NUM_PROPERTIES
};
static GParamSpec* games_preferences_subpage_gamepad_properties[GAMES_PREFERENCES_SUBPAGE_GAMEPAD_NUM_PROPERTIES];

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

#define GAMES_TYPE_GAMEPAD_VIEW_CONFIGURATION (games_gamepad_view_configuration_get_type ())
typedef struct _GamesGamepadViewConfiguration GamesGamepadViewConfiguration;

#define GAMES_TYPE_GAMEPAD_BUTTON_PATH (games_gamepad_button_path_get_type ())
typedef struct _GamesGamepadButtonPath GamesGamepadButtonPath;

#define GAMES_TYPE_GAMEPAD_ANALOG_PATH (games_gamepad_analog_path_get_type ())
typedef struct _GamesGamepadAnalogPath GamesGamepadAnalogPath;

struct _GamesPreferencesSubpageIface {
	GTypeInterface parent_iface;
	gboolean (*get_allow_back) (GamesPreferencesSubpage* self);
	void (*set_allow_back) (GamesPreferencesSubpage* self, gboolean value);
};

struct _GamesPreferencesSubpageGamepad {
	GtkBin parent_instance;
	GamesPreferencesSubpageGamepadPrivate * priv;
};

struct _GamesPreferencesSubpageGamepadClass {
	GtkBinClass parent_class;
};

struct _GamesPreferencesSubpageGamepadPrivate {
	GamesPreferencesSubpageGamepadState _state;
	gboolean _allow_back;
	gchar* _info_message;
	GtkStack* stack;
	GtkBox* tester_box;
	GtkBox* mapper_box;
	GtkHeaderBar* tester_header_bar;
	GtkHeaderBar* mapper_header_bar;
	GtkButton* reset_button;
	GamesGamepadMapper* mapper;
	GamesGamepadTester* tester;
	ManetteDevice* _device;
};

struct _GamesGamepadInput {
	guint16 type;
	guint16 code;
};

struct _Block20Data {
	int _ref_count_;
	GamesPreferencesSubpageGamepad* self;
	GtkMessageDialog* dialog;
};

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

struct _GamesGamepadAnalogPath {
	GamesGamepadInput input_x;
	GamesGamepadInput input_y;
	gdouble offset_radius;
	gchar* path;
};

struct _GamesGamepadViewConfiguration {
	gchar* svg_path;
	GamesGamepadButtonPath* button_paths;
	gint button_paths_length1;
	gint _button_paths_size_;
	GamesGamepadAnalogPath* analog_paths;
	gint analog_paths_length1;
	gint _analog_paths_size_;
	gchar** background_paths;
	gint background_paths_length1;
	gint _background_paths_size_;
};

static gint GamesPreferencesSubpageGamepad_private_offset;
static gpointer games_preferences_subpage_gamepad_parent_class = NULL;
static GamesPreferencesSubpageIface * games_preferences_subpage_gamepad_games_preferences_subpage_parent_iface = NULL;

VALA_EXTERN GType games_preferences_subpage_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType games_preferences_subpage_gamepad_get_type (void) G_GNUC_CONST ;
static GType games_preferences_subpage_gamepad_state_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
VALA_EXTERN GType games_gamepad_mapper_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType games_gamepad_tester_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType games_gamepad_input_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GamesGamepadInput* games_gamepad_input_dup (const GamesGamepadInput* self);
VALA_EXTERN void games_gamepad_input_free (GamesGamepadInput* self);
VALA_EXTERN GamesPreferencesSubpageGamepad* games_preferences_subpage_gamepad_new (ManetteDevice* device);
VALA_EXTERN GamesPreferencesSubpageGamepad* games_preferences_subpage_gamepad_construct (GType object_type,
                                                                             ManetteDevice* device);
static void games_preferences_subpage_gamepad_on_reset_clicked (GamesPreferencesSubpageGamepad* self);
static void games_preferences_subpage_gamepad_reset_mapping (GamesPreferencesSubpageGamepad* self);
static void _games_preferences_subpage_gamepad_on_reset_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                             gpointer self);
static void games_preferences_subpage_gamepad_on_configure_clicked (GamesPreferencesSubpageGamepad* self);
static void games_preferences_subpage_gamepad_set_state (GamesPreferencesSubpageGamepad* self,
                                                  GamesPreferencesSubpageGamepadState value);
static void _games_preferences_subpage_gamepad_on_configure_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                                 gpointer self);
static void games_preferences_subpage_gamepad_on_skip_clicked (GamesPreferencesSubpageGamepad* self);
VALA_EXTERN void games_gamepad_mapper_skip (GamesGamepadMapper* self);
static void _games_preferences_subpage_gamepad_on_skip_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                            gpointer self);
static void games_preferences_subpage_gamepad_on_back_clicked (GamesPreferencesSubpageGamepad* self);
static void _games_preferences_subpage_gamepad_on_back_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                            gpointer self);
static void games_preferences_subpage_gamepad_on_cancel_clicked (GamesPreferencesSubpageGamepad* self);
static void _games_preferences_subpage_gamepad_on_cancel_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                              gpointer self);
static Block20Data* block20_data_ref (Block20Data* _data20_);
static void block20_data_unref (void * _userdata_);
static void __lambda85_ (Block20Data* _data20_,
                  gint response);
VALA_EXTERN ManetteDevice* games_preferences_subpage_gamepad_get_device (GamesPreferencesSubpageGamepad* self);
static void ___lambda85__gtk_dialog_response (GtkDialog* _sender,
                                       gint response_id,
                                       gpointer self);
static void games_preferences_subpage_gamepad_on_mapper_finished (GamesPreferencesSubpageGamepad* self,
                                                           const gchar* sdl_string);
static GamesPreferencesSubpageGamepadState games_preferences_subpage_gamepad_get_state (GamesPreferencesSubpageGamepad* self);
VALA_EXTERN void games_preferences_subpage_set_allow_back (GamesPreferencesSubpage* self,
                                               gboolean value);
VALA_EXTERN void games_gamepad_tester_start (GamesGamepadTester* self);
VALA_EXTERN void games_gamepad_mapper_stop (GamesGamepadMapper* self);
static void _games_preferences_subpage_gamepad_on_mapper_finished_games_gamepad_mapper_finished (GamesGamepadMapper* _sender,
                                                                                          const gchar* sdl_string,
                                                                                          gpointer self);
VALA_EXTERN void games_gamepad_tester_stop (GamesGamepadTester* self);
VALA_EXTERN void games_gamepad_mapper_start (GamesGamepadMapper* self);
VALA_EXTERN const gchar* games_preferences_subpage_gamepad_get_info_message (GamesPreferencesSubpageGamepad* self);
VALA_EXTERN void games_preferences_subpage_gamepad_set_info_message (GamesPreferencesSubpageGamepad* self,
                                                         const gchar* value);
static void games_preferences_subpage_gamepad_set_device (GamesPreferencesSubpageGamepad* self,
                                                   ManetteDevice* value);
VALA_EXTERN GType games_gamepad_view_configuration_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType games_gamepad_button_path_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GamesGamepadButtonPath* games_gamepad_button_path_dup (const GamesGamepadButtonPath* self);
VALA_EXTERN void games_gamepad_button_path_free (GamesGamepadButtonPath* self);
VALA_EXTERN void games_gamepad_button_path_copy (const GamesGamepadButtonPath* self,
                                     GamesGamepadButtonPath* dest);
VALA_EXTERN void games_gamepad_button_path_destroy (GamesGamepadButtonPath* self);
VALA_EXTERN GType games_gamepad_analog_path_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GamesGamepadAnalogPath* games_gamepad_analog_path_dup (const GamesGamepadAnalogPath* self);
VALA_EXTERN void games_gamepad_analog_path_free (GamesGamepadAnalogPath* self);
VALA_EXTERN void games_gamepad_analog_path_copy (const GamesGamepadAnalogPath* self,
                                     GamesGamepadAnalogPath* dest);
VALA_EXTERN void games_gamepad_analog_path_destroy (GamesGamepadAnalogPath* self);
VALA_EXTERN GamesGamepadViewConfiguration* games_gamepad_view_configuration_dup (const GamesGamepadViewConfiguration* self);
VALA_EXTERN void games_gamepad_view_configuration_free (GamesGamepadViewConfiguration* self);
VALA_EXTERN void games_gamepad_view_configuration_copy (const GamesGamepadViewConfiguration* self,
                                            GamesGamepadViewConfiguration* dest);
VALA_EXTERN void games_gamepad_view_configuration_destroy (GamesGamepadViewConfiguration* self);
VALA_EXTERN void games_gamepad_view_configuration_get_default (GamesGamepadViewConfiguration* result);
VALA_EXTERN GamesGamepadMapper* games_gamepad_mapper_new (ManetteDevice* device,
                                              GamesGamepadViewConfiguration* configuration,
                                              GamesGamepadInput* mapping_inputs,
                                              gint mapping_inputs_length1);
VALA_EXTERN GamesGamepadMapper* games_gamepad_mapper_construct (GType object_type,
                                                    ManetteDevice* device,
                                                    GamesGamepadViewConfiguration* configuration,
                                                    GamesGamepadInput* mapping_inputs,
                                                    gint mapping_inputs_length1);
VALA_EXTERN GamesGamepadTester* games_gamepad_tester_new (ManetteDevice* device,
                                              GamesGamepadViewConfiguration* configuration);
VALA_EXTERN GamesGamepadTester* games_gamepad_tester_construct (GType object_type,
                                                    ManetteDevice* device,
                                                    GamesGamepadViewConfiguration* configuration);
static GObject * games_preferences_subpage_gamepad_constructor (GType type,
                                                         guint n_construct_properties,
                                                         GObjectConstructParam * construct_properties);
VALA_EXTERN gboolean games_preferences_subpage_get_allow_back (GamesPreferencesSubpage* self);
static void games_preferences_subpage_gamepad_finalize (GObject * obj);
static GType games_preferences_subpage_gamepad_get_type_once (void);
static void _vala_games_preferences_subpage_gamepad_get_property (GObject * object,
                                                           guint property_id,
                                                           GValue * value,
                                                           GParamSpec * pspec);
static void _vala_games_preferences_subpage_gamepad_set_property (GObject * object,
                                                           guint property_id,
                                                           const GValue * value,
                                                           GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static const GamesGamepadInput GAMES_PREFERENCES_SUBPAGE_GAMEPAD_STANDARD_GAMEPAD_INPUTS[21] = {{EV_KEY, BTN_EAST}, {EV_KEY, BTN_SOUTH}, {EV_KEY, BTN_WEST}, {EV_KEY, BTN_NORTH}, {EV_KEY, BTN_START}, {EV_KEY, BTN_MODE}, {EV_KEY, BTN_SELECT}, {EV_KEY, BTN_THUMBL}, {EV_KEY, BTN_THUMBR}, {EV_KEY, BTN_TL}, {EV_KEY, BTN_TR}, {EV_KEY, BTN_DPAD_UP}, {EV_KEY, BTN_DPAD_LEFT}, {EV_KEY, BTN_DPAD_DOWN}, {EV_KEY, BTN_DPAD_RIGHT}, {EV_ABS, ABS_X}, {EV_ABS, ABS_Y}, {EV_ABS, ABS_RX}, {EV_ABS, ABS_RY}, {EV_KEY, BTN_TL2}, {EV_KEY, BTN_TR2}};

static inline gpointer
games_preferences_subpage_gamepad_get_instance_private (GamesPreferencesSubpageGamepad* self)
{
	return G_STRUCT_MEMBER_P (self, GamesPreferencesSubpageGamepad_private_offset);
}

static GType
games_preferences_subpage_gamepad_state_get_type_once (void)
{
	static const GEnumValue values[] = {{GAMES_PREFERENCES_SUBPAGE_GAMEPAD_STATE_TEST, "GAMES_PREFERENCES_SUBPAGE_GAMEPAD_STATE_TEST", "test"}, {GAMES_PREFERENCES_SUBPAGE_GAMEPAD_STATE_CONFIGURE, "GAMES_PREFERENCES_SUBPAGE_GAMEPAD_STATE_CONFIGURE", "configure"}, {0, NULL, NULL}};
	GType games_preferences_subpage_gamepad_state_type_id;
	games_preferences_subpage_gamepad_state_type_id = g_enum_register_static ("GamesPreferencesSubpageGamepadState", values);
	return games_preferences_subpage_gamepad_state_type_id;
}

static GType
games_preferences_subpage_gamepad_state_get_type (void)
{
	static volatile gsize games_preferences_subpage_gamepad_state_type_id__once = 0;
	if (g_once_init_enter (&games_preferences_subpage_gamepad_state_type_id__once)) {
		GType games_preferences_subpage_gamepad_state_type_id;
		games_preferences_subpage_gamepad_state_type_id = games_preferences_subpage_gamepad_state_get_type_once ();
		g_once_init_leave (&games_preferences_subpage_gamepad_state_type_id__once, games_preferences_subpage_gamepad_state_type_id);
	}
	return games_preferences_subpage_gamepad_state_type_id__once;
}

GamesPreferencesSubpageGamepad*
games_preferences_subpage_gamepad_construct (GType object_type,
                                             ManetteDevice* device)
{
	GamesPreferencesSubpageGamepad * self = NULL;
	g_return_val_if_fail (device != NULL, NULL);
	self = (GamesPreferencesSubpageGamepad*) g_object_new (object_type, "device", device, NULL);
	return self;
}

GamesPreferencesSubpageGamepad*
games_preferences_subpage_gamepad_new (ManetteDevice* device)
{
	return games_preferences_subpage_gamepad_construct (GAMES_TYPE_PREFERENCES_SUBPAGE_GAMEPAD, device);
}

static void
games_preferences_subpage_gamepad_on_reset_clicked (GamesPreferencesSubpageGamepad* self)
{
	g_return_if_fail (self != NULL);
	games_preferences_subpage_gamepad_reset_mapping (self);
}

static void
_games_preferences_subpage_gamepad_on_reset_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                        gpointer self)
{
	games_preferences_subpage_gamepad_on_reset_clicked ((GamesPreferencesSubpageGamepad*) self);
}

static void
games_preferences_subpage_gamepad_on_configure_clicked (GamesPreferencesSubpageGamepad* self)
{
	g_return_if_fail (self != NULL);
	games_preferences_subpage_gamepad_set_state (self, GAMES_PREFERENCES_SUBPAGE_GAMEPAD_STATE_CONFIGURE);
}

static void
_games_preferences_subpage_gamepad_on_configure_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                            gpointer self)
{
	games_preferences_subpage_gamepad_on_configure_clicked ((GamesPreferencesSubpageGamepad*) self);
}

static void
games_preferences_subpage_gamepad_on_skip_clicked (GamesPreferencesSubpageGamepad* self)
{
	GamesGamepadMapper* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->mapper;
	games_gamepad_mapper_skip (_tmp0_);
}

static void
_games_preferences_subpage_gamepad_on_skip_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                       gpointer self)
{
	games_preferences_subpage_gamepad_on_skip_clicked ((GamesPreferencesSubpageGamepad*) self);
}

static void
games_preferences_subpage_gamepad_on_back_clicked (GamesPreferencesSubpageGamepad* self)
{
	g_return_if_fail (self != NULL);
	g_signal_emit_by_name ((GamesPreferencesSubpage*) self, "back");
}

static void
_games_preferences_subpage_gamepad_on_back_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                       gpointer self)
{
	games_preferences_subpage_gamepad_on_back_clicked ((GamesPreferencesSubpageGamepad*) self);
}

static void
games_preferences_subpage_gamepad_on_cancel_clicked (GamesPreferencesSubpageGamepad* self)
{
	g_return_if_fail (self != NULL);
	games_preferences_subpage_gamepad_set_state (self, GAMES_PREFERENCES_SUBPAGE_GAMEPAD_STATE_TEST);
}

static void
_games_preferences_subpage_gamepad_on_cancel_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                         gpointer self)
{
	games_preferences_subpage_gamepad_on_cancel_clicked ((GamesPreferencesSubpageGamepad*) self);
}

static Block20Data*
block20_data_ref (Block20Data* _data20_)
{
	g_atomic_int_inc (&_data20_->_ref_count_);
	return _data20_;
}

static void
block20_data_unref (void * _userdata_)
{
	Block20Data* _data20_;
	_data20_ = (Block20Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data20_->_ref_count_)) {
		GamesPreferencesSubpageGamepad* self;
		self = _data20_->self;
		_g_object_unref0 (_data20_->dialog);
		_g_object_unref0 (self);
		g_slice_free (Block20Data, _data20_);
	}
}

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

static void
__lambda85_ (Block20Data* _data20_,
             gint response)
{
	GamesPreferencesSubpageGamepad* self;
	self = _data20_->self;
	switch (response) {
		case GTK_RESPONSE_ACCEPT:
		{
			ManetteDevice* _tmp0_;
			ManetteDevice* _tmp1_;
			GtkButton* _tmp2_;
			_tmp0_ = games_preferences_subpage_gamepad_get_device (self);
			_tmp1_ = _tmp0_;
			manette_device_remove_user_mapping (_tmp1_);
			_tmp2_ = self->priv->reset_button;
			gtk_widget_set_sensitive ((GtkWidget*) _tmp2_, FALSE);
			break;
		}
		default:
		{
			break;
		}
	}
	gtk_widget_destroy ((GtkWidget*) _data20_->dialog);
}

static void
___lambda85__gtk_dialog_response (GtkDialog* _sender,
                                  gint response_id,
                                  gpointer self)
{
	__lambda85_ (self, response_id);
}

static void
games_preferences_subpage_gamepad_reset_mapping (GamesPreferencesSubpageGamepad* self)
{
	Block20Data* _data20_;
	GtkWidget* _tmp0_;
	GtkMessageDialog* _tmp1_;
	GtkWidget* button = NULL;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	GtkStyleContext* _tmp4_;
	g_return_if_fail (self != NULL);
	_data20_ = g_slice_new0 (Block20Data);
	_data20_->_ref_count_ = 1;
	_data20_->self = g_object_ref (self);
	_tmp0_ = gtk_widget_get_toplevel ((GtkWidget*) self);
	_tmp1_ = (GtkMessageDialog*) gtk_message_dialog_new (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, gtk_window_get_type ()) ? ((GtkWindow*) _tmp0_) : NULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_CANCEL, "%s", _ ("Factory reset mapping for this controller?"));
	g_object_ref_sink (_tmp1_);
	_data20_->dialog = _tmp1_;
	gtk_message_dialog_format_secondary_text (_data20_->dialog, "%s", _ ("Your mapping will be lost"));
	_tmp2_ = gtk_dialog_add_button ((GtkDialog*) _data20_->dialog, C_ ("Confirm controller configuration factory reset", "_Reset"), (gint) GTK_RESPONSE_ACCEPT);
	_tmp3_ = _g_object_ref0 (_tmp2_);
	button = _tmp3_;
	_tmp4_ = gtk_widget_get_style_context (button);
	gtk_style_context_add_class (_tmp4_, "destructive-action");
	g_signal_connect_data ((GtkDialog*) _data20_->dialog, "response", (GCallback) ___lambda85__gtk_dialog_response, block20_data_ref (_data20_), (GClosureNotify) block20_data_unref, 0);
	gtk_window_present ((GtkWindow*) _data20_->dialog);
	_g_object_unref0 (button);
	block20_data_unref (_data20_);
	_data20_ = NULL;
}

static void
games_preferences_subpage_gamepad_on_mapper_finished (GamesPreferencesSubpageGamepad* self,
                                                      const gchar* sdl_string)
{
	ManetteDevice* _tmp0_;
	ManetteDevice* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (sdl_string != NULL);
	_tmp0_ = games_preferences_subpage_gamepad_get_device (self);
	_tmp1_ = _tmp0_;
	manette_device_save_user_mapping (_tmp1_, sdl_string);
	games_preferences_subpage_gamepad_set_state (self, GAMES_PREFERENCES_SUBPAGE_GAMEPAD_STATE_TEST);
}

static GamesPreferencesSubpageGamepadState
games_preferences_subpage_gamepad_get_state (GamesPreferencesSubpageGamepad* self)
{
	GamesPreferencesSubpageGamepadState result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_state;
	return result;
}

static void
_games_preferences_subpage_gamepad_on_mapper_finished_games_gamepad_mapper_finished (GamesGamepadMapper* _sender,
                                                                                     const gchar* sdl_string,
                                                                                     gpointer self)
{
	games_preferences_subpage_gamepad_on_mapper_finished ((GamesPreferencesSubpageGamepad*) self, sdl_string);
}

static void
games_preferences_subpage_gamepad_set_state (GamesPreferencesSubpageGamepad* self,
                                             GamesPreferencesSubpageGamepadState value)
{
	GamesPreferencesSubpageGamepadState _tmp0_;
	GamesPreferencesSubpageGamepadState _tmp1_;
	g_return_if_fail (self != NULL);
	self->priv->_state = value;
	_tmp0_ = games_preferences_subpage_gamepad_get_state (self);
	_tmp1_ = _tmp0_;
	games_preferences_subpage_set_allow_back ((GamesPreferencesSubpage*) self, _tmp1_ == GAMES_PREFERENCES_SUBPAGE_GAMEPAD_STATE_TEST);
	switch (value) {
		case GAMES_PREFERENCES_SUBPAGE_GAMEPAD_STATE_TEST:
		{
			GtkButton* _tmp2_;
			ManetteDevice* _tmp3_;
			ManetteDevice* _tmp4_;
			GtkStack* _tmp5_;
			GtkBox* _tmp6_;
			GamesGamepadTester* _tmp7_;
			GamesGamepadMapper* _tmp8_;
			GamesGamepadMapper* _tmp9_;
			guint _tmp10_;
			_tmp2_ = self->priv->reset_button;
			_tmp3_ = games_preferences_subpage_gamepad_get_device (self);
			_tmp4_ = _tmp3_;
			gtk_widget_set_sensitive ((GtkWidget*) _tmp2_, manette_device_has_user_mapping (_tmp4_));
			_tmp5_ = self->priv->stack;
			_tmp6_ = self->priv->tester_box;
			gtk_stack_set_visible_child (_tmp5_, (GtkWidget*) _tmp6_);
			_tmp7_ = self->priv->tester;
			games_gamepad_tester_start (_tmp7_);
			_tmp8_ = self->priv->mapper;
			games_gamepad_mapper_stop (_tmp8_);
			_tmp9_ = self->priv->mapper;
			g_signal_parse_name ("finished", GAMES_TYPE_GAMEPAD_MAPPER, &_tmp10_, NULL, FALSE);
			g_signal_handlers_disconnect_matched (_tmp9_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp10_, 0, NULL, (GCallback) _games_preferences_subpage_gamepad_on_mapper_finished_games_gamepad_mapper_finished, self);
			break;
		}
		case GAMES_PREFERENCES_SUBPAGE_GAMEPAD_STATE_CONFIGURE:
		{
			GtkStack* _tmp11_;
			GtkBox* _tmp12_;
			GamesGamepadTester* _tmp13_;
			GamesGamepadMapper* _tmp14_;
			GamesGamepadMapper* _tmp15_;
			_tmp11_ = self->priv->stack;
			_tmp12_ = self->priv->mapper_box;
			gtk_stack_set_visible_child (_tmp11_, (GtkWidget*) _tmp12_);
			_tmp13_ = self->priv->tester;
			games_gamepad_tester_stop (_tmp13_);
			_tmp14_ = self->priv->mapper;
			games_gamepad_mapper_start (_tmp14_);
			_tmp15_ = self->priv->mapper;
			g_signal_connect_object (_tmp15_, "finished", (GCallback) _games_preferences_subpage_gamepad_on_mapper_finished_games_gamepad_mapper_finished, self, 0);
			break;
		}
		default:
		break;
	}
}

static gboolean
games_preferences_subpage_gamepad_real_get_allow_back (GamesPreferencesSubpage* base)
{
	gboolean result;
	GamesPreferencesSubpageGamepad* self;
	self = (GamesPreferencesSubpageGamepad*) base;
	result = self->priv->_allow_back;
	return result;
}

static void
games_preferences_subpage_gamepad_real_set_allow_back (GamesPreferencesSubpage* base,
                                                       gboolean value)
{
	GamesPreferencesSubpageGamepad* self;
	gboolean old_value;
	self = (GamesPreferencesSubpageGamepad*) base;
	old_value = games_preferences_subpage_gamepad_real_get_allow_back (base);
	if (old_value != value) {
		self->priv->_allow_back = value;
		g_object_notify_by_pspec ((GObject *) self, games_preferences_subpage_gamepad_properties[GAMES_PREFERENCES_SUBPAGE_GAMEPAD_ALLOW_BACK_PROPERTY]);
	}
}

const gchar*
games_preferences_subpage_gamepad_get_info_message (GamesPreferencesSubpageGamepad* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_info_message;
	result = _tmp0_;
	return result;
}

void
games_preferences_subpage_gamepad_set_info_message (GamesPreferencesSubpageGamepad* self,
                                                    const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = games_preferences_subpage_gamepad_get_info_message (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_info_message);
		self->priv->_info_message = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, games_preferences_subpage_gamepad_properties[GAMES_PREFERENCES_SUBPAGE_GAMEPAD_INFO_MESSAGE_PROPERTY]);
	}
}

ManetteDevice*
games_preferences_subpage_gamepad_get_device (GamesPreferencesSubpageGamepad* self)
{
	ManetteDevice* result;
	ManetteDevice* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_device;
	result = _tmp0_;
	return result;
}

static void
games_preferences_subpage_gamepad_set_device (GamesPreferencesSubpageGamepad* self,
                                              ManetteDevice* value)
{
	ManetteDevice* _tmp0_;
	GamesGamepadViewConfiguration _tmp1_ = {0};
	GamesGamepadViewConfiguration _tmp2_;
	GamesGamepadMapper* _tmp3_;
	GamesGamepadViewConfiguration _tmp4_ = {0};
	GamesGamepadViewConfiguration _tmp5_;
	GamesGamepadTester* _tmp6_;
	GtkBox* _tmp7_;
	GamesGamepadTester* _tmp8_;
	GtkBox* _tmp9_;
	GamesGamepadTester* _tmp10_;
	GtkBox* _tmp11_;
	GamesGamepadMapper* _tmp12_;
	GtkBox* _tmp13_;
	GamesGamepadMapper* _tmp14_;
	GamesGamepadMapper* _tmp15_;
	GtkHeaderBar* _tmp16_;
	ManetteDevice* _tmp17_;
	ManetteDevice* _tmp18_;
	const gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	GtkHeaderBar* _tmp22_;
	ManetteDevice* _tmp23_;
	ManetteDevice* _tmp24_;
	const gchar* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_device);
	self->priv->_device = _tmp0_;
	games_gamepad_view_configuration_get_default (&_tmp1_);
	_tmp2_ = _tmp1_;
	_tmp3_ = games_gamepad_mapper_new (value, &_tmp2_, GAMES_PREFERENCES_SUBPAGE_GAMEPAD_STANDARD_GAMEPAD_INPUTS, G_N_ELEMENTS (GAMES_PREFERENCES_SUBPAGE_GAMEPAD_STANDARD_GAMEPAD_INPUTS));
	g_object_ref_sink (_tmp3_);
	_g_object_unref0 (self->priv->mapper);
	self->priv->mapper = _tmp3_;
	games_gamepad_view_configuration_destroy (&_tmp2_);
	games_gamepad_view_configuration_get_default (&_tmp4_);
	_tmp5_ = _tmp4_;
	_tmp6_ = games_gamepad_tester_new (value, &_tmp5_);
	g_object_ref_sink (_tmp6_);
	_g_object_unref0 (self->priv->tester);
	self->priv->tester = _tmp6_;
	games_gamepad_view_configuration_destroy (&_tmp5_);
	_tmp7_ = self->priv->tester_box;
	_tmp8_ = self->priv->tester;
	gtk_container_add ((GtkContainer*) _tmp7_, (GtkWidget*) _tmp8_);
	_tmp9_ = self->priv->tester_box;
	_tmp10_ = self->priv->tester;
	gtk_box_reorder_child (_tmp9_, (GtkWidget*) _tmp10_, 1);
	_tmp11_ = self->priv->mapper_box;
	_tmp12_ = self->priv->mapper;
	gtk_container_add ((GtkContainer*) _tmp11_, (GtkWidget*) _tmp12_);
	_tmp13_ = self->priv->mapper_box;
	_tmp14_ = self->priv->mapper;
	gtk_box_reorder_child (_tmp13_, (GtkWidget*) _tmp14_, 1);
	_tmp15_ = self->priv->mapper;
	g_object_bind_property_with_closures ((GObject*) _tmp15_, "info-message", (GObject*) self, "info-message", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp16_ = self->priv->tester_header_bar;
	_tmp17_ = games_preferences_subpage_gamepad_get_device (self);
	_tmp18_ = _tmp17_;
	_tmp19_ = manette_device_get_name (_tmp18_);
	_tmp20_ = g_strdup_printf (_ ("Testing %s"), _tmp19_);
	_tmp21_ = _tmp20_;
	gtk_header_bar_set_title (_tmp16_, _tmp21_);
	_g_free0 (_tmp21_);
	_tmp22_ = self->priv->mapper_header_bar;
	_tmp23_ = games_preferences_subpage_gamepad_get_device (self);
	_tmp24_ = _tmp23_;
	_tmp25_ = manette_device_get_name (_tmp24_);
	_tmp26_ = g_strdup_printf (_ ("Configuring %s"), _tmp25_);
	_tmp27_ = _tmp26_;
	gtk_header_bar_set_title (_tmp22_, _tmp27_);
	_g_free0 (_tmp27_);
	g_object_notify_by_pspec ((GObject *) self, games_preferences_subpage_gamepad_properties[GAMES_PREFERENCES_SUBPAGE_GAMEPAD_DEVICE_PROPERTY]);
}

static GObject *
games_preferences_subpage_gamepad_constructor (GType type,
                                               guint n_construct_properties,
                                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GamesPreferencesSubpageGamepad * self;
	parent_class = G_OBJECT_CLASS (games_preferences_subpage_gamepad_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_PREFERENCES_SUBPAGE_GAMEPAD, GamesPreferencesSubpageGamepad);
	games_preferences_subpage_gamepad_set_state (self, GAMES_PREFERENCES_SUBPAGE_GAMEPAD_STATE_TEST);
	return obj;
}

static void
games_preferences_subpage_gamepad_class_init (GamesPreferencesSubpageGamepadClass * klass,
                                              gpointer klass_data)
{
	games_preferences_subpage_gamepad_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesPreferencesSubpageGamepad_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_games_preferences_subpage_gamepad_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_games_preferences_subpage_gamepad_set_property;
	G_OBJECT_CLASS (klass)->constructor = games_preferences_subpage_gamepad_constructor;
	G_OBJECT_CLASS (klass)->finalize = games_preferences_subpage_gamepad_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_PREFERENCES_SUBPAGE_GAMEPAD_ALLOW_BACK_PROPERTY, games_preferences_subpage_gamepad_properties[GAMES_PREFERENCES_SUBPAGE_GAMEPAD_ALLOW_BACK_PROPERTY] = g_param_spec_boolean ("allow-back", "allow-back", "allow-back", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_PREFERENCES_SUBPAGE_GAMEPAD_INFO_MESSAGE_PROPERTY, games_preferences_subpage_gamepad_properties[GAMES_PREFERENCES_SUBPAGE_GAMEPAD_INFO_MESSAGE_PROPERTY] = g_param_spec_string ("info-message", "info-message", "info-message", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_PREFERENCES_SUBPAGE_GAMEPAD_DEVICE_PROPERTY, games_preferences_subpage_gamepad_properties[GAMES_PREFERENCES_SUBPAGE_GAMEPAD_DEVICE_PROPERTY] = g_param_spec_object ("device", "device", "device", manette_device_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Games/preferences/preferences-subpage-gamepad.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "stack", FALSE, GamesPreferencesSubpageGamepad_private_offset + G_STRUCT_OFFSET (GamesPreferencesSubpageGamepadPrivate, stack));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "tester_box", FALSE, GamesPreferencesSubpageGamepad_private_offset + G_STRUCT_OFFSET (GamesPreferencesSubpageGamepadPrivate, tester_box));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "mapper_box", FALSE, GamesPreferencesSubpageGamepad_private_offset + G_STRUCT_OFFSET (GamesPreferencesSubpageGamepadPrivate, mapper_box));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "tester_header_bar", FALSE, GamesPreferencesSubpageGamepad_private_offset + G_STRUCT_OFFSET (GamesPreferencesSubpageGamepadPrivate, tester_header_bar));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "mapper_header_bar", FALSE, GamesPreferencesSubpageGamepad_private_offset + G_STRUCT_OFFSET (GamesPreferencesSubpageGamepadPrivate, mapper_header_bar));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "reset_button", FALSE, GamesPreferencesSubpageGamepad_private_offset + G_STRUCT_OFFSET (GamesPreferencesSubpageGamepadPrivate, reset_button));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_reset_clicked", G_CALLBACK(_games_preferences_subpage_gamepad_on_reset_clicked_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_configure_clicked", G_CALLBACK(_games_preferences_subpage_gamepad_on_configure_clicked_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_skip_clicked", G_CALLBACK(_games_preferences_subpage_gamepad_on_skip_clicked_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_back_clicked", G_CALLBACK(_games_preferences_subpage_gamepad_on_back_clicked_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_cancel_clicked", G_CALLBACK(_games_preferences_subpage_gamepad_on_cancel_clicked_gtk_button_clicked));
}

static void
games_preferences_subpage_gamepad_games_preferences_subpage_interface_init (GamesPreferencesSubpageIface * iface,
                                                                            gpointer iface_data)
{
	games_preferences_subpage_gamepad_games_preferences_subpage_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_allow_back = games_preferences_subpage_gamepad_real_get_allow_back;
	iface->set_allow_back = games_preferences_subpage_gamepad_real_set_allow_back;
}

static void
games_preferences_subpage_gamepad_instance_init (GamesPreferencesSubpageGamepad * self,
                                                 gpointer klass)
{
	self->priv = games_preferences_subpage_gamepad_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
games_preferences_subpage_gamepad_finalize (GObject * obj)
{
	GamesPreferencesSubpageGamepad * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_PREFERENCES_SUBPAGE_GAMEPAD, GamesPreferencesSubpageGamepad);
	_g_free0 (self->priv->_info_message);
	_g_object_unref0 (self->priv->mapper);
	_g_object_unref0 (self->priv->tester);
	_g_object_unref0 (self->priv->_device);
	G_OBJECT_CLASS (games_preferences_subpage_gamepad_parent_class)->finalize (obj);
}

static GType
games_preferences_subpage_gamepad_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesPreferencesSubpageGamepadClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_preferences_subpage_gamepad_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesPreferencesSubpageGamepad), 0, (GInstanceInitFunc) games_preferences_subpage_gamepad_instance_init, NULL };
	static const GInterfaceInfo games_preferences_subpage_info = { (GInterfaceInitFunc) games_preferences_subpage_gamepad_games_preferences_subpage_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType games_preferences_subpage_gamepad_type_id;
	games_preferences_subpage_gamepad_type_id = g_type_register_static (gtk_bin_get_type (), "GamesPreferencesSubpageGamepad", &g_define_type_info, 0);
	g_type_add_interface_static (games_preferences_subpage_gamepad_type_id, GAMES_TYPE_PREFERENCES_SUBPAGE, &games_preferences_subpage_info);
	GamesPreferencesSubpageGamepad_private_offset = g_type_add_instance_private (games_preferences_subpage_gamepad_type_id, sizeof (GamesPreferencesSubpageGamepadPrivate));
	return games_preferences_subpage_gamepad_type_id;
}

GType
games_preferences_subpage_gamepad_get_type (void)
{
	static volatile gsize games_preferences_subpage_gamepad_type_id__once = 0;
	if (g_once_init_enter (&games_preferences_subpage_gamepad_type_id__once)) {
		GType games_preferences_subpage_gamepad_type_id;
		games_preferences_subpage_gamepad_type_id = games_preferences_subpage_gamepad_get_type_once ();
		g_once_init_leave (&games_preferences_subpage_gamepad_type_id__once, games_preferences_subpage_gamepad_type_id);
	}
	return games_preferences_subpage_gamepad_type_id__once;
}

static void
_vala_games_preferences_subpage_gamepad_get_property (GObject * object,
                                                      guint property_id,
                                                      GValue * value,
                                                      GParamSpec * pspec)
{
	GamesPreferencesSubpageGamepad * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_PREFERENCES_SUBPAGE_GAMEPAD, GamesPreferencesSubpageGamepad);
	switch (property_id) {
		case GAMES_PREFERENCES_SUBPAGE_GAMEPAD_ALLOW_BACK_PROPERTY:
		g_value_set_boolean (value, games_preferences_subpage_get_allow_back ((GamesPreferencesSubpage*) self));
		break;
		case GAMES_PREFERENCES_SUBPAGE_GAMEPAD_INFO_MESSAGE_PROPERTY:
		g_value_set_string (value, games_preferences_subpage_gamepad_get_info_message (self));
		break;
		case GAMES_PREFERENCES_SUBPAGE_GAMEPAD_DEVICE_PROPERTY:
		g_value_set_object (value, games_preferences_subpage_gamepad_get_device (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_games_preferences_subpage_gamepad_set_property (GObject * object,
                                                      guint property_id,
                                                      const GValue * value,
                                                      GParamSpec * pspec)
{
	GamesPreferencesSubpageGamepad * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_PREFERENCES_SUBPAGE_GAMEPAD, GamesPreferencesSubpageGamepad);
	switch (property_id) {
		case GAMES_PREFERENCES_SUBPAGE_GAMEPAD_ALLOW_BACK_PROPERTY:
		games_preferences_subpage_set_allow_back ((GamesPreferencesSubpage*) self, g_value_get_boolean (value));
		break;
		case GAMES_PREFERENCES_SUBPAGE_GAMEPAD_INFO_MESSAGE_PROPERTY:
		games_preferences_subpage_gamepad_set_info_message (self, g_value_get_string (value));
		break;
		case GAMES_PREFERENCES_SUBPAGE_GAMEPAD_DEVICE_PROPERTY:
		games_preferences_subpage_gamepad_set_device (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

