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

/* This file is part of GNOME Games. License: GPLv3*/

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>


#define GAMES_TYPE_RAW_GAMEPAD (games_raw_gamepad_get_type ())
#define GAMES_RAW_GAMEPAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_RAW_GAMEPAD, GamesRawGamepad))
#define GAMES_IS_RAW_GAMEPAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_RAW_GAMEPAD))
#define GAMES_RAW_GAMEPAD_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GAMES_TYPE_RAW_GAMEPAD, GamesRawGamepadIface))

typedef struct _GamesRawGamepad GamesRawGamepad;
typedef struct _GamesRawGamepadIface GamesRawGamepadIface;

#define GAMES_TYPE_STANDARD_GAMEPAD_BUTTON (games_standard_gamepad_button_get_type ())

#define GAMES_TYPE_STANDARD_GAMEPAD_AXIS (games_standard_gamepad_axis_get_type ())
enum  {
	GAMES_RAW_GAMEPAD_STANDARD_BUTTON_EVENT_SIGNAL,
	GAMES_RAW_GAMEPAD_BUTTON_EVENT_SIGNAL,
	GAMES_RAW_GAMEPAD_STANDARD_AXIS_EVENT_SIGNAL,
	GAMES_RAW_GAMEPAD_AXIS_EVENT_SIGNAL,
	GAMES_RAW_GAMEPAD_DPAD_EVENT_SIGNAL,
	GAMES_RAW_GAMEPAD_UNPLUGGED_SIGNAL,
	GAMES_RAW_GAMEPAD_LAST_SIGNAL
};
static guint games_raw_gamepad_signals[GAMES_RAW_GAMEPAD_LAST_SIGNAL] = {0};

struct _GamesRawGamepadIface {
	GTypeInterface parent_iface;
	const gchar* (*get_guid) (GamesRawGamepad* self);
};

typedef enum  {
	GAMES_STANDARD_GAMEPAD_BUTTON_UNKNOWN,
	GAMES_STANDARD_GAMEPAD_BUTTON_A,
	GAMES_STANDARD_GAMEPAD_BUTTON_B,
	GAMES_STANDARD_GAMEPAD_BUTTON_X,
	GAMES_STANDARD_GAMEPAD_BUTTON_Y,
	GAMES_STANDARD_GAMEPAD_BUTTON_SHOULDER_L,
	GAMES_STANDARD_GAMEPAD_BUTTON_SHOULDER_R,
	GAMES_STANDARD_GAMEPAD_BUTTON_TRIGGER_L,
	GAMES_STANDARD_GAMEPAD_BUTTON_TRIGGER_R,
	GAMES_STANDARD_GAMEPAD_BUTTON_SELECT,
	GAMES_STANDARD_GAMEPAD_BUTTON_START,
	GAMES_STANDARD_GAMEPAD_BUTTON_STICK_L,
	GAMES_STANDARD_GAMEPAD_BUTTON_STICK_R,
	GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_UP,
	GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_DOWN,
	GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_LEFT,
	GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_RIGHT,
	GAMES_STANDARD_GAMEPAD_BUTTON_HOME
} GamesStandardGamepadButton;

typedef enum  {
	GAMES_STANDARD_GAMEPAD_AXIS_UNKNOWN,
	GAMES_STANDARD_GAMEPAD_AXIS_LEFT_X,
	GAMES_STANDARD_GAMEPAD_AXIS_LEFT_Y,
	GAMES_STANDARD_GAMEPAD_AXIS_RIGHT_X,
	GAMES_STANDARD_GAMEPAD_AXIS_RIGHT_Y
} GamesStandardGamepadAxis;



GType games_raw_gamepad_get_type (void) G_GNUC_CONST;
const gchar* games_raw_gamepad_get_guid (GamesRawGamepad* self);
GType games_standard_gamepad_button_get_type (void) G_GNUC_CONST;
static void g_cclosure_user_marshal_VOID__ENUM_BOOLEAN (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
static void g_cclosure_user_marshal_VOID__INT_BOOLEAN (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
GType games_standard_gamepad_axis_get_type (void) G_GNUC_CONST;
static void g_cclosure_user_marshal_VOID__ENUM_DOUBLE (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
static void g_cclosure_user_marshal_VOID__INT_DOUBLE (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
static void g_cclosure_user_marshal_VOID__INT_INT_INT (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);


const gchar* games_raw_gamepad_get_guid (GamesRawGamepad* self) {
	g_return_val_if_fail (self != NULL, NULL);
	return GAMES_RAW_GAMEPAD_GET_INTERFACE (self)->get_guid (self);
}


static void g_cclosure_user_marshal_VOID__ENUM_BOOLEAN (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
	typedef void (*GMarshalFunc_VOID__ENUM_BOOLEAN) (gpointer data1, gint arg_1, gboolean arg_2, gpointer data2);
	register GMarshalFunc_VOID__ENUM_BOOLEAN callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__ENUM_BOOLEAN) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_enum (param_values + 1), g_value_get_boolean (param_values + 2), data2);
}


static void g_cclosure_user_marshal_VOID__INT_BOOLEAN (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
	typedef void (*GMarshalFunc_VOID__INT_BOOLEAN) (gpointer data1, gint arg_1, gboolean arg_2, gpointer data2);
	register GMarshalFunc_VOID__INT_BOOLEAN callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__INT_BOOLEAN) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_int (param_values + 1), g_value_get_boolean (param_values + 2), data2);
}


static void g_cclosure_user_marshal_VOID__ENUM_DOUBLE (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
	typedef void (*GMarshalFunc_VOID__ENUM_DOUBLE) (gpointer data1, gint arg_1, gdouble arg_2, gpointer data2);
	register GMarshalFunc_VOID__ENUM_DOUBLE callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__ENUM_DOUBLE) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_enum (param_values + 1), g_value_get_double (param_values + 2), data2);
}


static void g_cclosure_user_marshal_VOID__INT_DOUBLE (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
	typedef void (*GMarshalFunc_VOID__INT_DOUBLE) (gpointer data1, gint arg_1, gdouble arg_2, gpointer data2);
	register GMarshalFunc_VOID__INT_DOUBLE callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__INT_DOUBLE) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_int (param_values + 1), g_value_get_double (param_values + 2), data2);
}


static void g_cclosure_user_marshal_VOID__INT_INT_INT (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
	typedef void (*GMarshalFunc_VOID__INT_INT_INT) (gpointer data1, gint arg_1, gint arg_2, gint arg_3, gpointer data2);
	register GMarshalFunc_VOID__INT_INT_INT callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 4);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__INT_INT_INT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_int (param_values + 1), g_value_get_int (param_values + 2), g_value_get_int (param_values + 3), data2);
}


static void games_raw_gamepad_base_init (GamesRawGamepadIface * iface) {
	static gboolean initialized = FALSE;
	if (!initialized) {
		initialized = TRUE;
		g_object_interface_install_property (iface, g_param_spec_string ("guid", "guid", "guid", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
		games_raw_gamepad_signals[GAMES_RAW_GAMEPAD_STANDARD_BUTTON_EVENT_SIGNAL] = g_signal_new ("standard_button_event", GAMES_TYPE_RAW_GAMEPAD, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__ENUM_BOOLEAN, G_TYPE_NONE, 2, GAMES_TYPE_STANDARD_GAMEPAD_BUTTON, G_TYPE_BOOLEAN);
		/**
		 * Emitted when a button is pressed/released
		 * @param  code          The button code from 0 to buttons_number
		 * @param  value         True if pressed, False if released
		 */
		games_raw_gamepad_signals[GAMES_RAW_GAMEPAD_BUTTON_EVENT_SIGNAL] = g_signal_new ("button_event", GAMES_TYPE_RAW_GAMEPAD, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__INT_BOOLEAN, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_BOOLEAN);
		games_raw_gamepad_signals[GAMES_RAW_GAMEPAD_STANDARD_AXIS_EVENT_SIGNAL] = g_signal_new ("standard_axis_event", GAMES_TYPE_RAW_GAMEPAD, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__ENUM_DOUBLE, G_TYPE_NONE, 2, GAMES_TYPE_STANDARD_GAMEPAD_AXIS, G_TYPE_DOUBLE);
		/**
		 * Emitted when an axis's value changes
		 * @param  axis          The axis number from 0 to axes_number
		 * @param  value         The value of the axis ranging from -1 to 1
		 */
		games_raw_gamepad_signals[GAMES_RAW_GAMEPAD_AXIS_EVENT_SIGNAL] = g_signal_new ("axis_event", GAMES_TYPE_RAW_GAMEPAD, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__INT_DOUBLE, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_DOUBLE);
		/**
		 * Emitted when a dpad's axis's value changes
		 * @param  dpad          The dpad number from 0 to
		 * @param  axis          The axis: 0 for X, 1 for Y
		 * @param  value         The value of the axis ranging from -1 to 1
		 */
		games_raw_gamepad_signals[GAMES_RAW_GAMEPAD_DPAD_EVENT_SIGNAL] = g_signal_new ("dpad_event", GAMES_TYPE_RAW_GAMEPAD, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__INT_INT_INT, G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
		/**
		 * Emitted when the gamepad is unplugged
		 */
		games_raw_gamepad_signals[GAMES_RAW_GAMEPAD_UNPLUGGED_SIGNAL] = g_signal_new ("unplugged", GAMES_TYPE_RAW_GAMEPAD, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	}
}


/**
 * This is one of the interfaces that needs to be implemented by the driver.
 *
 * This interface represents a gamepad and deals with handling events that are
 * emitted by a gamepad and also provide properties like name and guid along
 * with number of buttons, axes and dpads.
 */
GType games_raw_gamepad_get_type (void) {
	static volatile gsize games_raw_gamepad_type_id__volatile = 0;
	if (g_once_init_enter (&games_raw_gamepad_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GamesRawGamepadIface), (GBaseInitFunc) games_raw_gamepad_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
		GType games_raw_gamepad_type_id;
		games_raw_gamepad_type_id = g_type_register_static (G_TYPE_INTERFACE, "GamesRawGamepad", &g_define_type_info, 0);
		g_type_interface_add_prerequisite (games_raw_gamepad_type_id, G_TYPE_OBJECT);
		g_once_init_leave (&games_raw_gamepad_type_id__volatile, games_raw_gamepad_type_id);
	}
	return games_raw_gamepad_type_id__volatile;
}



