/* gamepad-configuration.c generated by valac 0.36.4, the Vala compiler
 * generated from gamepad-configuration.vala, do not modify */

/* This file is part of retro-gtk. License: GPLv3*/

#include <glib.h>
#include <glib-object.h>


#define RETRO_TYPE_GAMEPAD_CONFIGURATION (retro_gamepad_configuration_get_type ())
#define RETRO_GAMEPAD_CONFIGURATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RETRO_TYPE_GAMEPAD_CONFIGURATION, RetroGamepadConfiguration))
#define RETRO_GAMEPAD_CONFIGURATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RETRO_TYPE_GAMEPAD_CONFIGURATION, RetroGamepadConfigurationClass))
#define RETRO_IS_GAMEPAD_CONFIGURATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RETRO_TYPE_GAMEPAD_CONFIGURATION))
#define RETRO_IS_GAMEPAD_CONFIGURATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RETRO_TYPE_GAMEPAD_CONFIGURATION))
#define RETRO_GAMEPAD_CONFIGURATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RETRO_TYPE_GAMEPAD_CONFIGURATION, RetroGamepadConfigurationClass))

typedef struct _RetroGamepadConfiguration RetroGamepadConfiguration;
typedef struct _RetroGamepadConfigurationClass RetroGamepadConfigurationClass;
typedef struct _RetroGamepadConfigurationPrivate RetroGamepadConfigurationPrivate;

#define RETRO_TYPE_GAMEPAD_BUTTON_TYPE (retro_gamepad_button_type_get_type ())

struct _RetroGamepadConfiguration {
	GObject parent_instance;
	RetroGamepadConfigurationPrivate * priv;
};

struct _RetroGamepadConfigurationClass {
	GObjectClass parent_class;
};

struct _RetroGamepadConfigurationPrivate {
	guint16* gamepad_keys;
	gint gamepad_keys_length1;
	gint _gamepad_keys_size_;
};

typedef enum  {
	RETRO_GAMEPAD_BUTTON_TYPE_ACTION_DOWN,
	RETRO_GAMEPAD_BUTTON_TYPE_ACTION_LEFT,
	RETRO_GAMEPAD_BUTTON_TYPE_SELECT,
	RETRO_GAMEPAD_BUTTON_TYPE_START,
	RETRO_GAMEPAD_BUTTON_TYPE_DIRECTION_UP,
	RETRO_GAMEPAD_BUTTON_TYPE_DIRECTION_DOWN,
	RETRO_GAMEPAD_BUTTON_TYPE_DIRECTION_LEFT,
	RETRO_GAMEPAD_BUTTON_TYPE_DIRECTION_RIGHT,
	RETRO_GAMEPAD_BUTTON_TYPE_ACTION_RIGHT,
	RETRO_GAMEPAD_BUTTON_TYPE_ACTION_UP,
	RETRO_GAMEPAD_BUTTON_TYPE_SHOULDER_L,
	RETRO_GAMEPAD_BUTTON_TYPE_SHOULDER_R,
	RETRO_GAMEPAD_BUTTON_TYPE_SHOULDER_L2,
	RETRO_GAMEPAD_BUTTON_TYPE_SHOULDER_R2,
	RETRO_GAMEPAD_BUTTON_TYPE_STICK_L,
	RETRO_GAMEPAD_BUTTON_TYPE_STICK_R,
	RETRO_GAMEPAD_BUTTON_TYPE_HOME
} RetroGamepadButtonType;


static gpointer retro_gamepad_configuration_parent_class = NULL;

GType retro_gamepad_configuration_get_type (void) G_GNUC_CONST;
#define RETRO_GAMEPAD_CONFIGURATION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RETRO_TYPE_GAMEPAD_CONFIGURATION, RetroGamepadConfigurationPrivate))
enum  {
	RETRO_GAMEPAD_CONFIGURATION_DUMMY_PROPERTY
};
void retro_gamepad_configuration_set_to_default (RetroGamepadConfiguration* self);
GType retro_gamepad_button_type_get_type (void) G_GNUC_CONST;
void retro_gamepad_configuration_set_button_key (RetroGamepadConfiguration* self, RetroGamepadButtonType button, guint16 key);
guint16 retro_gamepad_configuration_get_button_key (RetroGamepadConfiguration* self, RetroGamepadButtonType button);
RetroGamepadConfiguration* retro_gamepad_configuration_new (void);
RetroGamepadConfiguration* retro_gamepad_configuration_construct (GType object_type);
static GObject * retro_gamepad_configuration_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void retro_gamepad_configuration_finalize (GObject * obj);


void retro_gamepad_configuration_set_to_default (RetroGamepadConfiguration* self) {
	g_return_if_fail (self != NULL);
	retro_gamepad_configuration_set_button_key (self, RETRO_GAMEPAD_BUTTON_TYPE_ACTION_DOWN, (guint16) 39);
	retro_gamepad_configuration_set_button_key (self, RETRO_GAMEPAD_BUTTON_TYPE_ACTION_LEFT, (guint16) 38);
	retro_gamepad_configuration_set_button_key (self, RETRO_GAMEPAD_BUTTON_TYPE_SELECT, (guint16) 22);
	retro_gamepad_configuration_set_button_key (self, RETRO_GAMEPAD_BUTTON_TYPE_START, (guint16) 36);
	retro_gamepad_configuration_set_button_key (self, RETRO_GAMEPAD_BUTTON_TYPE_DIRECTION_UP, (guint16) 111);
	retro_gamepad_configuration_set_button_key (self, RETRO_GAMEPAD_BUTTON_TYPE_DIRECTION_DOWN, (guint16) 116);
	retro_gamepad_configuration_set_button_key (self, RETRO_GAMEPAD_BUTTON_TYPE_DIRECTION_LEFT, (guint16) 113);
	retro_gamepad_configuration_set_button_key (self, RETRO_GAMEPAD_BUTTON_TYPE_DIRECTION_RIGHT, (guint16) 114);
	retro_gamepad_configuration_set_button_key (self, RETRO_GAMEPAD_BUTTON_TYPE_ACTION_RIGHT, (guint16) 40);
	retro_gamepad_configuration_set_button_key (self, RETRO_GAMEPAD_BUTTON_TYPE_ACTION_UP, (guint16) 25);
	retro_gamepad_configuration_set_button_key (self, RETRO_GAMEPAD_BUTTON_TYPE_SHOULDER_L, (guint16) 24);
	retro_gamepad_configuration_set_button_key (self, RETRO_GAMEPAD_BUTTON_TYPE_SHOULDER_R, (guint16) 26);
	retro_gamepad_configuration_set_button_key (self, RETRO_GAMEPAD_BUTTON_TYPE_SHOULDER_L2, (guint16) 52);
	retro_gamepad_configuration_set_button_key (self, RETRO_GAMEPAD_BUTTON_TYPE_SHOULDER_R2, (guint16) 54);
	retro_gamepad_configuration_set_button_key (self, RETRO_GAMEPAD_BUTTON_TYPE_STICK_L, (guint16) 10);
	retro_gamepad_configuration_set_button_key (self, RETRO_GAMEPAD_BUTTON_TYPE_STICK_R, (guint16) 12);
	retro_gamepad_configuration_set_button_key (self, RETRO_GAMEPAD_BUTTON_TYPE_HOME, (guint16) 110);
}


void retro_gamepad_configuration_set_button_key (RetroGamepadConfiguration* self, RetroGamepadButtonType button, guint16 key) {
	guint16* _tmp0_;
	gint _tmp0__length1;
	RetroGamepadButtonType _tmp1_;
	guint16 _tmp2_;
	guint16 _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->gamepad_keys;
	_tmp0__length1 = self->priv->gamepad_keys_length1;
	_tmp1_ = button;
	_tmp2_ = key;
	_tmp0_[_tmp1_] = _tmp2_;
	_tmp3_ = _tmp0_[_tmp1_];
}


guint16 retro_gamepad_configuration_get_button_key (RetroGamepadConfiguration* self, RetroGamepadButtonType button) {
	guint16 result = 0U;
	guint16* _tmp0_;
	gint _tmp0__length1;
	RetroGamepadButtonType _tmp1_;
	guint16 _tmp2_;
	g_return_val_if_fail (self != NULL, 0U);
	_tmp0_ = self->priv->gamepad_keys;
	_tmp0__length1 = self->priv->gamepad_keys_length1;
	_tmp1_ = button;
	_tmp2_ = _tmp0_[_tmp1_];
	result = _tmp2_;
	return result;
}


RetroGamepadConfiguration* retro_gamepad_configuration_construct (GType object_type) {
	RetroGamepadConfiguration * self = NULL;
	self = (RetroGamepadConfiguration*) g_object_new (object_type, NULL);
	return self;
}


RetroGamepadConfiguration* retro_gamepad_configuration_new (void) {
	return retro_gamepad_configuration_construct (RETRO_TYPE_GAMEPAD_CONFIGURATION);
}


static GObject * retro_gamepad_configuration_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	RetroGamepadConfiguration * self;
	guint16* _tmp0_;
	parent_class = G_OBJECT_CLASS (retro_gamepad_configuration_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RETRO_TYPE_GAMEPAD_CONFIGURATION, RetroGamepadConfiguration);
	_tmp0_ = g_new0 (guint16, 17);
	self->priv->gamepad_keys = (g_free (self->priv->gamepad_keys), NULL);
	self->priv->gamepad_keys = _tmp0_;
	self->priv->gamepad_keys_length1 = 17;
	self->priv->_gamepad_keys_size_ = self->priv->gamepad_keys_length1;
	return obj;
}


static void retro_gamepad_configuration_class_init (RetroGamepadConfigurationClass * klass) {
	retro_gamepad_configuration_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (RetroGamepadConfigurationPrivate));
	G_OBJECT_CLASS (klass)->constructor = retro_gamepad_configuration_constructor;
	G_OBJECT_CLASS (klass)->finalize = retro_gamepad_configuration_finalize;
}


static void retro_gamepad_configuration_instance_init (RetroGamepadConfiguration * self) {
	self->priv = RETRO_GAMEPAD_CONFIGURATION_GET_PRIVATE (self);
}


static void retro_gamepad_configuration_finalize (GObject * obj) {
	RetroGamepadConfiguration * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RETRO_TYPE_GAMEPAD_CONFIGURATION, RetroGamepadConfiguration);
	self->priv->gamepad_keys = (g_free (self->priv->gamepad_keys), NULL);
	G_OBJECT_CLASS (retro_gamepad_configuration_parent_class)->finalize (obj);
}


GType retro_gamepad_configuration_get_type (void) {
	static volatile gsize retro_gamepad_configuration_type_id__volatile = 0;
	if (g_once_init_enter (&retro_gamepad_configuration_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RetroGamepadConfigurationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) retro_gamepad_configuration_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RetroGamepadConfiguration), 0, (GInstanceInitFunc) retro_gamepad_configuration_instance_init, NULL };
		GType retro_gamepad_configuration_type_id;
		retro_gamepad_configuration_type_id = g_type_register_static (G_TYPE_OBJECT, "RetroGamepadConfiguration", &g_define_type_info, 0);
		g_once_init_leave (&retro_gamepad_configuration_type_id__volatile, retro_gamepad_configuration_type_id);
	}
	return retro_gamepad_configuration_type_id__volatile;
}



