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

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

#include <glib.h>
#include <glib-object.h>
#include <retro-gtk.h>
#include <libmanette.h>
#include <gtk/gtk.h>


#define GAMES_TYPE_RETRO_INPUT_MANAGER (games_retro_input_manager_get_type ())
#define GAMES_RETRO_INPUT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_RETRO_INPUT_MANAGER, GamesRetroInputManager))
#define GAMES_RETRO_INPUT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_RETRO_INPUT_MANAGER, GamesRetroInputManagerClass))
#define GAMES_IS_RETRO_INPUT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_RETRO_INPUT_MANAGER))
#define GAMES_IS_RETRO_INPUT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_RETRO_INPUT_MANAGER))
#define GAMES_RETRO_INPUT_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_RETRO_INPUT_MANAGER, GamesRetroInputManagerClass))

typedef struct _GamesRetroInputManager GamesRetroInputManager;
typedef struct _GamesRetroInputManagerClass GamesRetroInputManagerClass;
typedef struct _GamesRetroInputManagerPrivate GamesRetroInputManagerPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block2Data Block2Data;

#define GAMES_TYPE_RETRO_GAMEPAD (games_retro_gamepad_get_type ())
#define GAMES_RETRO_GAMEPAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_RETRO_GAMEPAD, GamesRetroGamepad))
#define GAMES_RETRO_GAMEPAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_RETRO_GAMEPAD, GamesRetroGamepadClass))
#define GAMES_IS_RETRO_GAMEPAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_RETRO_GAMEPAD))
#define GAMES_IS_RETRO_GAMEPAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_RETRO_GAMEPAD))
#define GAMES_RETRO_GAMEPAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_RETRO_GAMEPAD, GamesRetroGamepadClass))

typedef struct _GamesRetroGamepad GamesRetroGamepad;
typedef struct _GamesRetroGamepadClass GamesRetroGamepadClass;
#define __vala_ManetteMonitorIter_free0(var) ((var == NULL) ? NULL : (var = (_vala_ManetteMonitorIter_free (var), NULL)))
typedef struct _Block3Data Block3Data;

struct _GamesRetroInputManager {
	GObject parent_instance;
	GamesRetroInputManagerPrivate * priv;
};

struct _GamesRetroInputManagerClass {
	GObjectClass parent_class;
};

struct _GamesRetroInputManagerPrivate {
	RetroCore* core;
	RetroController* core_view_joypad;
	ManetteMonitor* monitor;
	RetroController** controllers;
	gint controllers_length1;
	gint _controllers_size_;
	gint core_view_joypad_port;
	gboolean present_analog_sticks;
};

struct _Block2Data {
	int _ref_count_;
	GamesRetroInputManager* self;
	gint port;
};

struct _Block3Data {
	int _ref_count_;
	GamesRetroInputManager* self;
	gint port;
};


static gpointer games_retro_input_manager_parent_class = NULL;

GType games_retro_input_manager_get_type (void) G_GNUC_CONST;
#define GAMES_RETRO_INPUT_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_RETRO_INPUT_MANAGER, GamesRetroInputManagerPrivate))
enum  {
	GAMES_RETRO_INPUT_MANAGER_0_PROPERTY
};
GamesRetroInputManager* games_retro_input_manager_new (RetroCore* core, RetroCoreView* view, gboolean present_analog_sticks);
GamesRetroInputManager* games_retro_input_manager_construct (GType object_type, RetroCore* core, RetroCoreView* view, gboolean present_analog_sticks);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
GType games_retro_gamepad_get_type (void) G_GNUC_CONST;
GamesRetroGamepad* games_retro_gamepad_new (ManetteDevice* device, gboolean present_analog_sticks);
GamesRetroGamepad* games_retro_gamepad_construct (GType object_type, ManetteDevice* device, gboolean present_analog_sticks);
static void _vala_array_add12 (RetroController** * array, int* length, int* size, RetroController* value);
static void ___lambda18_ (Block2Data* _data2_);
static void games_retro_input_manager_on_device_disconnected (GamesRetroInputManager* self, gint port);
static void ____lambda18__manette_device_disconnected (ManetteDevice* _sender, gpointer self);
static void _vala_array_add13 (RetroController** * array, int* length, int* size, RetroController* value);
static void games_retro_input_manager_on_device_connected (GamesRetroInputManager* self, ManetteDevice* device);
static void _games_retro_input_manager_on_device_connected_manette_monitor_device_connected (ManetteMonitor* _sender, ManetteDevice* device, gpointer self);
static void _vala_ManetteMonitorIter_free (ManetteMonitorIter* self);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (void * _userdata_);
static void __lambda19_ (Block3Data* _data3_);
static void ___lambda19__manette_device_disconnected (ManetteDevice* _sender, gpointer self);
static void _vala_array_add14 (RetroController** * array, int* length, int* size, RetroController* value);
static void games_retro_input_manager_finalize (GObject * obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);


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


static Block2Data* block2_data_ref (Block2Data* _data2_) {
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}


static void block2_data_unref (void * _userdata_) {
	Block2Data* _data2_;
	_data2_ = (Block2Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		GamesRetroInputManager* self;
		self = _data2_->self;
		_g_object_unref0 (self);
		g_slice_free (Block2Data, _data2_);
	}
}


static void _vala_array_add12 (RetroController** * array, int* length, int* size, RetroController* value) {
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (RetroController*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}


static void ___lambda18_ (Block2Data* _data2_) {
	GamesRetroInputManager* self;
	gint _tmp0_;
	self = _data2_->self;
	_tmp0_ = _data2_->port;
	games_retro_input_manager_on_device_disconnected (self, _tmp0_);
}


static void ____lambda18__manette_device_disconnected (ManetteDevice* _sender, gpointer self) {
	___lambda18_ (self);
}


static void _vala_array_add13 (RetroController** * array, int* length, int* size, RetroController* value) {
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (RetroController*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}


static void _games_retro_input_manager_on_device_connected_manette_monitor_device_connected (ManetteMonitor* _sender, ManetteDevice* device, gpointer self) {
	games_retro_input_manager_on_device_connected ((GamesRetroInputManager*) self, device);
}


static void _vala_ManetteMonitorIter_free (ManetteMonitorIter* self) {
	g_boxed_free (manette_monitor_iter_get_type (), self);
}


GamesRetroInputManager* games_retro_input_manager_construct (GType object_type, RetroCore* core, RetroCoreView* view, gboolean present_analog_sticks) {
	GamesRetroInputManager * self = NULL;
	RetroCore* _tmp0_;
	RetroCore* _tmp1_;
	gboolean _tmp2_;
	RetroCoreView* _tmp3_;
	RetroController* _tmp4_;
	RetroCore* _tmp5_;
	RetroCoreView* _tmp6_;
	RetroCoreView* _tmp7_;
	RetroCore* _tmp8_;
	ManetteMonitor* _tmp9_;
	ManetteMonitorIter* iterator = NULL;
	ManetteMonitor* _tmp10_;
	ManetteMonitorIter* _tmp11_;
	ManetteDevice* device = NULL;
	RetroController** _tmp27_;
	gint _tmp27__length1;
	RetroController** _tmp28_;
	gint _tmp28__length1;
	RetroController* _tmp29_;
	RetroController* _tmp30_;
	RetroCore* _tmp31_;
	gint _tmp32_;
	RetroController* _tmp33_;
	ManetteMonitor* _tmp34_;
	g_return_val_if_fail (core != NULL, NULL);
	g_return_val_if_fail (view != NULL, NULL);
	self = (GamesRetroInputManager*) g_object_new (object_type, NULL);
	_tmp0_ = core;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->core);
	self->priv->core = _tmp1_;
	_tmp2_ = present_analog_sticks;
	self->priv->present_analog_sticks = _tmp2_;
	_tmp3_ = view;
	_tmp4_ = retro_core_view_as_controller (_tmp3_, RETRO_CONTROLLER_TYPE_JOYPAD);
	_g_object_unref0 (self->priv->core_view_joypad);
	self->priv->core_view_joypad = _tmp4_;
	_tmp5_ = core;
	_tmp6_ = view;
	retro_core_set_keyboard (_tmp5_, (GtkWidget*) _tmp6_);
	_tmp7_ = view;
	_tmp8_ = core;
	retro_core_view_set_as_default_controller (_tmp7_, _tmp8_);
	_tmp9_ = manette_monitor_new ();
	_g_object_unref0 (self->priv->monitor);
	self->priv->monitor = _tmp9_;
	_tmp10_ = self->priv->monitor;
	_tmp11_ = manette_monitor_iterate (_tmp10_);
	iterator = _tmp11_;
	device = NULL;
	while (TRUE) {
		Block2Data* _data2_;
		ManetteMonitorIter* _tmp12_;
		ManetteDevice* _tmp13_ = NULL;
		gboolean _tmp14_;
		ManetteDevice* _tmp15_;
		RetroController** _tmp16_;
		gint _tmp16__length1;
		GamesRetroGamepad* retro_gamepad = NULL;
		ManetteDevice* _tmp17_;
		gboolean _tmp18_;
		GamesRetroGamepad* _tmp19_;
		RetroController** _tmp20_;
		gint _tmp20__length1;
		GamesRetroGamepad* _tmp21_;
		RetroController* _tmp22_;
		RetroCore* _tmp23_;
		gint _tmp24_;
		GamesRetroGamepad* _tmp25_;
		ManetteDevice* _tmp26_;
		_data2_ = g_slice_new0 (Block2Data);
		_data2_->_ref_count_ = 1;
		_data2_->self = g_object_ref (self);
		_tmp12_ = iterator;
		_tmp14_ = manette_monitor_iter_next (_tmp12_, &_tmp13_);
		_g_object_unref0 (device);
		_tmp15_ = _g_object_ref0 (_tmp13_);
		device = _tmp15_;
		if (!_tmp14_) {
			block2_data_unref (_data2_);
			_data2_ = NULL;
			break;
		}
		_tmp16_ = self->priv->controllers;
		_tmp16__length1 = self->priv->controllers_length1;
		_data2_->port = _tmp16__length1;
		_tmp17_ = device;
		_tmp18_ = present_analog_sticks;
		_tmp19_ = games_retro_gamepad_new (_tmp17_, _tmp18_);
		retro_gamepad = _tmp19_;
		_tmp20_ = self->priv->controllers;
		_tmp20__length1 = self->priv->controllers_length1;
		_tmp21_ = retro_gamepad;
		_tmp22_ = _g_object_ref0 ((RetroController*) _tmp21_);
		_vala_array_add12 (&self->priv->controllers, &self->priv->controllers_length1, &self->priv->_controllers_size_, _tmp22_);
		_tmp23_ = core;
		_tmp24_ = _data2_->port;
		_tmp25_ = retro_gamepad;
		retro_core_set_controller (_tmp23_, (guint) _tmp24_, (RetroController*) _tmp25_);
		_tmp26_ = device;
		g_signal_connect_data (_tmp26_, "disconnected", (GCallback) ____lambda18__manette_device_disconnected, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
		_g_object_unref0 (retro_gamepad);
		block2_data_unref (_data2_);
		_data2_ = NULL;
	}
	_tmp27_ = self->priv->controllers;
	_tmp27__length1 = self->priv->controllers_length1;
	self->priv->core_view_joypad_port = _tmp27__length1;
	_tmp28_ = self->priv->controllers;
	_tmp28__length1 = self->priv->controllers_length1;
	_tmp29_ = self->priv->core_view_joypad;
	_tmp30_ = _g_object_ref0 (_tmp29_);
	_vala_array_add13 (&self->priv->controllers, &self->priv->controllers_length1, &self->priv->_controllers_size_, _tmp30_);
	_tmp31_ = core;
	_tmp32_ = self->priv->core_view_joypad_port;
	_tmp33_ = self->priv->core_view_joypad;
	retro_core_set_controller (_tmp31_, (guint) _tmp32_, _tmp33_);
	_tmp34_ = self->priv->monitor;
	g_signal_connect_object (_tmp34_, "device-connected", (GCallback) _games_retro_input_manager_on_device_connected_manette_monitor_device_connected, self, 0);
	_g_object_unref0 (device);
	__vala_ManetteMonitorIter_free0 (iterator);
	return self;
}


GamesRetroInputManager* games_retro_input_manager_new (RetroCore* core, RetroCoreView* view, gboolean present_analog_sticks) {
	return games_retro_input_manager_construct (GAMES_TYPE_RETRO_INPUT_MANAGER, core, view, present_analog_sticks);
}


static Block3Data* block3_data_ref (Block3Data* _data3_) {
	g_atomic_int_inc (&_data3_->_ref_count_);
	return _data3_;
}


static void block3_data_unref (void * _userdata_) {
	Block3Data* _data3_;
	_data3_ = (Block3Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
		GamesRetroInputManager* self;
		self = _data3_->self;
		_g_object_unref0 (self);
		g_slice_free (Block3Data, _data3_);
	}
}


static void __lambda19_ (Block3Data* _data3_) {
	GamesRetroInputManager* self;
	gint _tmp0_;
	self = _data3_->self;
	_tmp0_ = _data3_->port;
	games_retro_input_manager_on_device_disconnected (self, _tmp0_);
}


static void ___lambda19__manette_device_disconnected (ManetteDevice* _sender, gpointer self) {
	__lambda19_ (self);
}


static void _vala_array_add14 (RetroController** * array, int* length, int* size, RetroController* value) {
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (RetroController*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}


static void games_retro_input_manager_on_device_connected (GamesRetroInputManager* self, ManetteDevice* device) {
	Block3Data* _data3_;
	gint _tmp0_;
	GamesRetroGamepad* retro_gamepad = NULL;
	ManetteDevice* _tmp1_;
	gboolean _tmp2_;
	GamesRetroGamepad* _tmp3_;
	RetroController** _tmp4_;
	gint _tmp4__length1;
	gint _tmp5_;
	GamesRetroGamepad* _tmp6_;
	RetroController* _tmp7_;
	RetroController* _tmp8_;
	RetroCore* _tmp9_;
	gint _tmp10_;
	GamesRetroGamepad* _tmp11_;
	ManetteDevice* _tmp12_;
	RetroController** _tmp30_;
	gint _tmp30__length1;
	RetroController** _tmp31_;
	gint _tmp31__length1;
	RetroController* _tmp32_;
	RetroController* _tmp33_;
	RetroCore* _tmp34_;
	gint _tmp35_;
	RetroController* _tmp36_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (device != NULL);
	_data3_ = g_slice_new0 (Block3Data);
	_data3_->_ref_count_ = 1;
	_data3_->self = g_object_ref (self);
	_tmp0_ = self->priv->core_view_joypad_port;
	_data3_->port = _tmp0_;
	_tmp1_ = device;
	_tmp2_ = self->priv->present_analog_sticks;
	_tmp3_ = games_retro_gamepad_new (_tmp1_, _tmp2_);
	retro_gamepad = _tmp3_;
	_tmp4_ = self->priv->controllers;
	_tmp4__length1 = self->priv->controllers_length1;
	_tmp5_ = _data3_->port;
	_tmp6_ = retro_gamepad;
	_tmp7_ = _g_object_ref0 ((RetroController*) _tmp6_);
	_g_object_unref0 (_tmp4_[_tmp5_]);
	_tmp4_[_tmp5_] = _tmp7_;
	_tmp8_ = _tmp4_[_tmp5_];
	_tmp9_ = self->priv->core;
	_tmp10_ = _data3_->port;
	_tmp11_ = retro_gamepad;
	retro_core_set_controller (_tmp9_, (guint) _tmp10_, (RetroController*) _tmp11_);
	_tmp12_ = device;
	g_signal_connect_data (_tmp12_, "disconnected", (GCallback) ___lambda19__manette_device_disconnected, block3_data_ref (_data3_), (GClosureNotify) block3_data_unref, 0);
	{
		gint i = 0;
		gint _tmp13_;
		_tmp13_ = self->priv->core_view_joypad_port;
		i = _tmp13_;
		{
			gboolean _tmp14_ = FALSE;
			_tmp14_ = TRUE;
			while (TRUE) {
				gint _tmp16_;
				RetroController** _tmp17_;
				gint _tmp17__length1;
				RetroController** _tmp18_;
				gint _tmp18__length1;
				gint _tmp19_;
				RetroController* _tmp20_;
				if (!_tmp14_) {
					gint _tmp15_;
					_tmp15_ = i;
					i = _tmp15_ + 1;
				}
				_tmp14_ = FALSE;
				_tmp16_ = i;
				_tmp17_ = self->priv->controllers;
				_tmp17__length1 = self->priv->controllers_length1;
				if (!(_tmp16_ < _tmp17__length1)) {
					break;
				}
				_tmp18_ = self->priv->controllers;
				_tmp18__length1 = self->priv->controllers_length1;
				_tmp19_ = i;
				_tmp20_ = _tmp18_[_tmp19_];
				if (_tmp20_ == NULL) {
					gint _tmp21_;
					RetroController** _tmp22_;
					gint _tmp22__length1;
					gint _tmp23_;
					RetroController* _tmp24_;
					RetroController* _tmp25_;
					RetroController* _tmp26_;
					RetroCore* _tmp27_;
					gint _tmp28_;
					RetroController* _tmp29_;
					_tmp21_ = i;
					self->priv->core_view_joypad_port = _tmp21_;
					_tmp22_ = self->priv->controllers;
					_tmp22__length1 = self->priv->controllers_length1;
					_tmp23_ = self->priv->core_view_joypad_port;
					_tmp24_ = self->priv->core_view_joypad;
					_tmp25_ = _g_object_ref0 (_tmp24_);
					_g_object_unref0 (_tmp22_[_tmp23_]);
					_tmp22_[_tmp23_] = _tmp25_;
					_tmp26_ = _tmp22_[_tmp23_];
					_tmp27_ = self->priv->core;
					_tmp28_ = self->priv->core_view_joypad_port;
					_tmp29_ = self->priv->core_view_joypad;
					retro_core_set_controller (_tmp27_, (guint) _tmp28_, _tmp29_);
					_g_object_unref0 (retro_gamepad);
					block3_data_unref (_data3_);
					_data3_ = NULL;
					return;
				}
			}
		}
	}
	_tmp30_ = self->priv->controllers;
	_tmp30__length1 = self->priv->controllers_length1;
	self->priv->core_view_joypad_port = _tmp30__length1;
	_tmp31_ = self->priv->controllers;
	_tmp31__length1 = self->priv->controllers_length1;
	_tmp32_ = self->priv->core_view_joypad;
	_tmp33_ = _g_object_ref0 (_tmp32_);
	_vala_array_add14 (&self->priv->controllers, &self->priv->controllers_length1, &self->priv->_controllers_size_, _tmp33_);
	_tmp34_ = self->priv->core;
	_tmp35_ = self->priv->core_view_joypad_port;
	_tmp36_ = self->priv->core_view_joypad;
	retro_core_set_controller (_tmp34_, (guint) _tmp35_, _tmp36_);
	_g_object_unref0 (retro_gamepad);
	block3_data_unref (_data3_);
	_data3_ = NULL;
}


static void games_retro_input_manager_on_device_disconnected (GamesRetroInputManager* self, gint port) {
	gint _tmp0_;
	gint _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->core_view_joypad_port;
	_tmp1_ = port;
	if (_tmp0_ > _tmp1_) {
		RetroController** _tmp2_;
		gint _tmp2__length1;
		gint _tmp3_;
		RetroController* _tmp4_;
		gint _tmp5_;
		RetroController** _tmp6_;
		gint _tmp6__length1;
		gint _tmp7_;
		RetroController* _tmp8_;
		RetroController* _tmp9_;
		RetroController* _tmp10_;
		RetroCore* _tmp11_;
		gint _tmp12_;
		RetroController* _tmp13_;
		_tmp2_ = self->priv->controllers;
		_tmp2__length1 = self->priv->controllers_length1;
		_tmp3_ = self->priv->core_view_joypad_port;
		_g_object_unref0 (_tmp2_[_tmp3_]);
		_tmp2_[_tmp3_] = NULL;
		_tmp4_ = _tmp2_[_tmp3_];
		_tmp5_ = port;
		self->priv->core_view_joypad_port = _tmp5_;
		_tmp6_ = self->priv->controllers;
		_tmp6__length1 = self->priv->controllers_length1;
		_tmp7_ = self->priv->core_view_joypad_port;
		_tmp8_ = self->priv->core_view_joypad;
		_tmp9_ = _g_object_ref0 (_tmp8_);
		_g_object_unref0 (_tmp6_[_tmp7_]);
		_tmp6_[_tmp7_] = _tmp9_;
		_tmp10_ = _tmp6_[_tmp7_];
		_tmp11_ = self->priv->core;
		_tmp12_ = self->priv->core_view_joypad_port;
		_tmp13_ = self->priv->core_view_joypad;
		retro_core_set_controller (_tmp11_, (guint) _tmp12_, _tmp13_);
	} else {
		RetroController** _tmp14_;
		gint _tmp14__length1;
		gint _tmp15_;
		RetroController* _tmp16_;
		RetroCore* _tmp17_;
		gint _tmp18_;
		_tmp14_ = self->priv->controllers;
		_tmp14__length1 = self->priv->controllers_length1;
		_tmp15_ = port;
		_g_object_unref0 (_tmp14_[_tmp15_]);
		_tmp14_[_tmp15_] = NULL;
		_tmp16_ = _tmp14_[_tmp15_];
		_tmp17_ = self->priv->core;
		_tmp18_ = port;
		retro_core_set_controller (_tmp17_, (guint) _tmp18_, NULL);
	}
}


static void games_retro_input_manager_class_init (GamesRetroInputManagerClass * klass) {
	games_retro_input_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesRetroInputManagerPrivate));
	G_OBJECT_CLASS (klass)->finalize = games_retro_input_manager_finalize;
}


static void games_retro_input_manager_instance_init (GamesRetroInputManager * self) {
	self->priv = GAMES_RETRO_INPUT_MANAGER_GET_PRIVATE (self);
}


static void games_retro_input_manager_finalize (GObject * obj) {
	GamesRetroInputManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_RETRO_INPUT_MANAGER, GamesRetroInputManager);
	_g_object_unref0 (self->priv->core);
	_g_object_unref0 (self->priv->core_view_joypad);
	_g_object_unref0 (self->priv->monitor);
	self->priv->controllers = (_vala_array_free (self->priv->controllers, self->priv->controllers_length1, (GDestroyNotify) g_object_unref), NULL);
	G_OBJECT_CLASS (games_retro_input_manager_parent_class)->finalize (obj);
}


GType games_retro_input_manager_get_type (void) {
	static volatile gsize games_retro_input_manager_type_id__volatile = 0;
	if (g_once_init_enter (&games_retro_input_manager_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GamesRetroInputManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_retro_input_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesRetroInputManager), 0, (GInstanceInitFunc) games_retro_input_manager_instance_init, NULL };
		GType games_retro_input_manager_type_id;
		games_retro_input_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "GamesRetroInputManager", &g_define_type_info, 0);
		g_once_init_leave (&games_retro_input_manager_type_id__volatile, games_retro_input_manager_type_id);
	}
	return games_retro_input_manager_type_id__volatile;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



