/* controller-input-policy.c generated by valac 0.56.19, the Vala compiler
 * generated from controller-input-policy.vala, do not modify */

#include "protonplus_core.h"
#include <glib.h>
#include <glib-object.h>
#include <gee.h>
#include <float.h>
#include <math.h>
#include <string.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

enum  {
	PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_0_PROPERTY,
	PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_OWNERSHIP_CHANGED_PROPERTY,
	PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_REPEAT_CHANGED_PROPERTY,
	PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_EMITTED_DIRECTION_PROPERTY,
	PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_NUM_PROPERTIES
};
static GParamSpec* proton_plus_utils_controller_navigation_update_properties[PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_NUM_PROPERTIES];

#define PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_TYPE_DEVICE_AXES (proton_plus_utils_controller_input_policy_device_axes_get_type ())
#define PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_DEVICE_AXES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_TYPE_DEVICE_AXES, ProtonPlusUtilsControllerInputPolicyDeviceAxes))
#define PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_DEVICE_AXES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_TYPE_DEVICE_AXES, ProtonPlusUtilsControllerInputPolicyDeviceAxesClass))
#define PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_IS_DEVICE_AXES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_TYPE_DEVICE_AXES))
#define PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_IS_DEVICE_AXES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_TYPE_DEVICE_AXES))
#define PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_DEVICE_AXES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_TYPE_DEVICE_AXES, ProtonPlusUtilsControllerInputPolicyDeviceAxesClass))

typedef struct _ProtonPlusUtilsControllerInputPolicyDeviceAxes ProtonPlusUtilsControllerInputPolicyDeviceAxes;
typedef struct _ProtonPlusUtilsControllerInputPolicyDeviceAxesClass ProtonPlusUtilsControllerInputPolicyDeviceAxesClass;
enum  {
	PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_0_PROPERTY,
	PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_HAS_ACTIVE_DEVICE_PROPERTY,
	PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_ACTIVE_DEVICE_ID_PROPERTY,
	PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_SCROLL_INTENT_PROPERTY,
	PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_HAS_REPEAT_PROPERTY,
	PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_REPEAT_DEVICE_ID_PROPERTY,
	PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_REPEAT_DIRECTION_PROPERTY,
	PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_REPEAT_SOURCE_PROPERTY,
	PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_NUM_PROPERTIES
};
static GParamSpec* proton_plus_utils_controller_input_policy_properties[PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _ProtonPlusUtilsControllerInputPolicyDeviceAxesPrivate ProtonPlusUtilsControllerInputPolicyDeviceAxesPrivate;
enum  {
	PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_DEVICE_AXES_0_PROPERTY,
	PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_DEVICE_AXES_NUM_PROPERTIES
};
static GParamSpec* proton_plus_utils_controller_input_policy_device_axes_properties[PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_DEVICE_AXES_NUM_PROPERTIES];

struct _ProtonPlusUtilsControllerNavigationUpdatePrivate {
	gboolean _ownership_changed;
	gboolean _repeat_changed;
	ProtonPlusUtilsControllerNavigationDirection _emitted_direction;
};

struct _ProtonPlusUtilsControllerInputPolicyPrivate {
	GeeArrayList* devices;
	gboolean owns_device;
	gint64 owned_device_id;
	ProtonPlusUtilsControllerNavigationDirection analog_direction;
	gboolean analog_suppressed;
	gboolean scroll_suppressed;
	gdouble owned_scroll_intent;
	gboolean repeat_active;
	gint64 repeating_device_id;
	ProtonPlusUtilsControllerNavigationDirection repeating_direction;
	ProtonPlusUtilsControllerNavigationSource repeating_source;
	gint64 last_controller_activity_us;
	gboolean has_pointer_position;
	gdouble pointer_x;
	gdouble pointer_y;
};

struct _ProtonPlusUtilsControllerInputPolicyDeviceAxes {
	GObject parent_instance;
	ProtonPlusUtilsControllerInputPolicyDeviceAxesPrivate * priv;
	gint64 id;
	gdouble left_x;
	gdouble left_y;
	gdouble right_y;
};

struct _ProtonPlusUtilsControllerInputPolicyDeviceAxesClass {
	GObjectClass parent_class;
};

static gint ProtonPlusUtilsControllerNavigationUpdate_private_offset;
static gpointer proton_plus_utils_controller_navigation_update_parent_class = NULL;
static gint ProtonPlusUtilsControllerInputPolicy_private_offset;
static gpointer proton_plus_utils_controller_input_policy_parent_class = NULL;
static gpointer proton_plus_utils_controller_input_policy_device_axes_parent_class = NULL;

VALA_EXTERN void proton_plus_utils_controller_navigation_update_set_ownership_changed (ProtonPlusUtilsControllerNavigationUpdate* self,
                                                                           gboolean value);
VALA_EXTERN void proton_plus_utils_controller_navigation_update_set_repeat_changed (ProtonPlusUtilsControllerNavigationUpdate* self,
                                                                        gboolean value);
VALA_EXTERN void proton_plus_utils_controller_navigation_update_set_emitted_direction (ProtonPlusUtilsControllerNavigationUpdate* self,
                                                                           ProtonPlusUtilsControllerNavigationDirection value);
static void proton_plus_utils_controller_navigation_update_finalize (GObject * obj);
static GType proton_plus_utils_controller_navigation_update_get_type_once (void);
static void _vala_proton_plus_utils_controller_navigation_update_get_property (GObject * object,
                                                                        guint property_id,
                                                                        GValue * value,
                                                                        GParamSpec * pspec);
static void _vala_proton_plus_utils_controller_navigation_update_set_property (GObject * object,
                                                                        guint property_id,
                                                                        const GValue * value,
                                                                        GParamSpec * pspec);
static GType proton_plus_utils_controller_input_policy_device_axes_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static gboolean proton_plus_utils_controller_input_policy_has_recent_controller_activity (ProtonPlusUtilsControllerInputPolicy* self,
                                                                                   gint64 now_us);
static ProtonPlusUtilsControllerInputPolicyDeviceAxes* proton_plus_utils_controller_input_policy_ensure_device (ProtonPlusUtilsControllerInputPolicy* self,
                                                                                                         gint64 device_id);
static gboolean proton_plus_utils_controller_input_policy_claim_device (ProtonPlusUtilsControllerInputPolicy* self,
                                                                 gint64 device_id,
                                                                 gboolean suppress_held_axes);
static gdouble proton_plus_utils_controller_input_policy_maximum_left_magnitude (ProtonPlusUtilsControllerInputPolicy* self,
                                                                          ProtonPlusUtilsControllerInputPolicyDeviceAxes* device);
static ProtonPlusUtilsControllerNavigationDirection proton_plus_utils_controller_input_policy_choose_latched_direction (ProtonPlusUtilsControllerInputPolicy* self,
                                                                                                                 ProtonPlusUtilsControllerInputPolicyDeviceAxes* device);
static ProtonPlusUtilsControllerInputPolicyDeviceAxes* proton_plus_utils_controller_input_policy_find_device (ProtonPlusUtilsControllerInputPolicy* self,
                                                                                                       gint64 device_id);
static void proton_plus_utils_controller_input_policy_clear_ownership (ProtonPlusUtilsControllerInputPolicy* self);
static ProtonPlusUtilsControllerInputPolicyDeviceAxes* proton_plus_utils_controller_input_policy_get_owned_device (ProtonPlusUtilsControllerInputPolicy* self);
static ProtonPlusUtilsControllerInputPolicyDeviceAxes* proton_plus_utils_controller_input_policy_device_axes_new (gint64 id);
static ProtonPlusUtilsControllerInputPolicyDeviceAxes* proton_plus_utils_controller_input_policy_device_axes_construct (GType object_type,
                                                                                                                 gint64 id);
static void proton_plus_utils_controller_input_policy_device_axes_finalize (GObject * obj);
static GType proton_plus_utils_controller_input_policy_device_axes_get_type_once (void);
static void proton_plus_utils_controller_input_policy_finalize (GObject * obj);
static GType proton_plus_utils_controller_input_policy_get_type_once (void);
static void _vala_proton_plus_utils_controller_input_policy_get_property (GObject * object,
                                                                   guint property_id,
                                                                   GValue * value,
                                                                   GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static GType
proton_plus_utils_controller_navigation_direction_get_type_once (void)
{
	static const GEnumValue values[] = {{PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_NONE, "PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_NONE", "none"}, {PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_UP, "PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_UP", "up"}, {PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_DOWN, "PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_DOWN", "down"}, {PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_LEFT, "PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_LEFT", "left"}, {PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_RIGHT, "PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_RIGHT", "right"}, {0, NULL, NULL}};
	GType proton_plus_utils_controller_navigation_direction_type_id;
	proton_plus_utils_controller_navigation_direction_type_id = g_enum_register_static ("ProtonPlusUtilsControllerNavigationDirection", values);
	return proton_plus_utils_controller_navigation_direction_type_id;
}

GType
proton_plus_utils_controller_navigation_direction_get_type (void)
{
	static volatile gsize proton_plus_utils_controller_navigation_direction_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_utils_controller_navigation_direction_type_id__once)) {
		GType proton_plus_utils_controller_navigation_direction_type_id;
		proton_plus_utils_controller_navigation_direction_type_id = proton_plus_utils_controller_navigation_direction_get_type_once ();
		g_once_init_leave (&proton_plus_utils_controller_navigation_direction_type_id__once, proton_plus_utils_controller_navigation_direction_type_id);
	}
	return proton_plus_utils_controller_navigation_direction_type_id__once;
}

static GType
proton_plus_utils_controller_confirm_button_get_type_once (void)
{
	static const GEnumValue values[] = {{PROTON_PLUS_UTILS_CONTROLLER_CONFIRM_BUTTON_SOUTH, "PROTON_PLUS_UTILS_CONTROLLER_CONFIRM_BUTTON_SOUTH", "south"}, {PROTON_PLUS_UTILS_CONTROLLER_CONFIRM_BUTTON_EAST, "PROTON_PLUS_UTILS_CONTROLLER_CONFIRM_BUTTON_EAST", "east"}, {0, NULL, NULL}};
	GType proton_plus_utils_controller_confirm_button_type_id;
	proton_plus_utils_controller_confirm_button_type_id = g_enum_register_static ("ProtonPlusUtilsControllerConfirmButton", values);
	return proton_plus_utils_controller_confirm_button_type_id;
}

GType
proton_plus_utils_controller_confirm_button_get_type (void)
{
	static volatile gsize proton_plus_utils_controller_confirm_button_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_utils_controller_confirm_button_type_id__once)) {
		GType proton_plus_utils_controller_confirm_button_type_id;
		proton_plus_utils_controller_confirm_button_type_id = proton_plus_utils_controller_confirm_button_get_type_once ();
		g_once_init_leave (&proton_plus_utils_controller_confirm_button_type_id__once, proton_plus_utils_controller_confirm_button_type_id);
	}
	return proton_plus_utils_controller_confirm_button_type_id__once;
}

static GType
proton_plus_utils_controller_face_button_get_type_once (void)
{
	static const GEnumValue values[] = {{PROTON_PLUS_UTILS_CONTROLLER_FACE_BUTTON_SOUTH, "PROTON_PLUS_UTILS_CONTROLLER_FACE_BUTTON_SOUTH", "south"}, {PROTON_PLUS_UTILS_CONTROLLER_FACE_BUTTON_EAST, "PROTON_PLUS_UTILS_CONTROLLER_FACE_BUTTON_EAST", "east"}, {0, NULL, NULL}};
	GType proton_plus_utils_controller_face_button_type_id;
	proton_plus_utils_controller_face_button_type_id = g_enum_register_static ("ProtonPlusUtilsControllerFaceButton", values);
	return proton_plus_utils_controller_face_button_type_id;
}

GType
proton_plus_utils_controller_face_button_get_type (void)
{
	static volatile gsize proton_plus_utils_controller_face_button_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_utils_controller_face_button_type_id__once)) {
		GType proton_plus_utils_controller_face_button_type_id;
		proton_plus_utils_controller_face_button_type_id = proton_plus_utils_controller_face_button_get_type_once ();
		g_once_init_leave (&proton_plus_utils_controller_face_button_type_id__once, proton_plus_utils_controller_face_button_type_id);
	}
	return proton_plus_utils_controller_face_button_type_id__once;
}

static GType
proton_plus_utils_controller_face_button_action_get_type_once (void)
{
	static const GEnumValue values[] = {{PROTON_PLUS_UTILS_CONTROLLER_FACE_BUTTON_ACTION_ACTIVATE, "PROTON_PLUS_UTILS_CONTROLLER_FACE_BUTTON_ACTION_ACTIVATE", "activate"}, {PROTON_PLUS_UTILS_CONTROLLER_FACE_BUTTON_ACTION_DISMISS, "PROTON_PLUS_UTILS_CONTROLLER_FACE_BUTTON_ACTION_DISMISS", "dismiss"}, {0, NULL, NULL}};
	GType proton_plus_utils_controller_face_button_action_type_id;
	proton_plus_utils_controller_face_button_action_type_id = g_enum_register_static ("ProtonPlusUtilsControllerFaceButtonAction", values);
	return proton_plus_utils_controller_face_button_action_type_id;
}

GType
proton_plus_utils_controller_face_button_action_get_type (void)
{
	static volatile gsize proton_plus_utils_controller_face_button_action_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_utils_controller_face_button_action_type_id__once)) {
		GType proton_plus_utils_controller_face_button_action_type_id;
		proton_plus_utils_controller_face_button_action_type_id = proton_plus_utils_controller_face_button_action_get_type_once ();
		g_once_init_leave (&proton_plus_utils_controller_face_button_action_type_id__once, proton_plus_utils_controller_face_button_action_type_id);
	}
	return proton_plus_utils_controller_face_button_action_type_id__once;
}

static GType
proton_plus_utils_controller_navigation_source_get_type_once (void)
{
	static const GEnumValue values[] = {{PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_SOURCE_DPAD, "PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_SOURCE_DPAD", "dpad"}, {PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_SOURCE_LEFT_STICK, "PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_SOURCE_LEFT_STICK", "left-stick"}, {0, NULL, NULL}};
	GType proton_plus_utils_controller_navigation_source_type_id;
	proton_plus_utils_controller_navigation_source_type_id = g_enum_register_static ("ProtonPlusUtilsControllerNavigationSource", values);
	return proton_plus_utils_controller_navigation_source_type_id;
}

GType
proton_plus_utils_controller_navigation_source_get_type (void)
{
	static volatile gsize proton_plus_utils_controller_navigation_source_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_utils_controller_navigation_source_type_id__once)) {
		GType proton_plus_utils_controller_navigation_source_type_id;
		proton_plus_utils_controller_navigation_source_type_id = proton_plus_utils_controller_navigation_source_get_type_once ();
		g_once_init_leave (&proton_plus_utils_controller_navigation_source_type_id__once, proton_plus_utils_controller_navigation_source_type_id);
	}
	return proton_plus_utils_controller_navigation_source_type_id__once;
}

static inline gpointer
proton_plus_utils_controller_navigation_update_get_instance_private (ProtonPlusUtilsControllerNavigationUpdate* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusUtilsControllerNavigationUpdate_private_offset);
}

ProtonPlusUtilsControllerNavigationUpdate*
proton_plus_utils_controller_navigation_update_construct (GType object_type)
{
	ProtonPlusUtilsControllerNavigationUpdate * self = NULL;
	self = (ProtonPlusUtilsControllerNavigationUpdate*) g_object_new (object_type, NULL);
	return self;
}

ProtonPlusUtilsControllerNavigationUpdate*
proton_plus_utils_controller_navigation_update_new (void)
{
	return proton_plus_utils_controller_navigation_update_construct (PROTON_PLUS_UTILS_TYPE_CONTROLLER_NAVIGATION_UPDATE);
}

gboolean
proton_plus_utils_controller_navigation_update_get_ownership_changed (ProtonPlusUtilsControllerNavigationUpdate* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_ownership_changed;
	return result;
}

void
proton_plus_utils_controller_navigation_update_set_ownership_changed (ProtonPlusUtilsControllerNavigationUpdate* self,
                                                                      gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_utils_controller_navigation_update_get_ownership_changed (self);
	if (old_value != value) {
		self->priv->_ownership_changed = value;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_utils_controller_navigation_update_properties[PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_OWNERSHIP_CHANGED_PROPERTY]);
	}
}

gboolean
proton_plus_utils_controller_navigation_update_get_repeat_changed (ProtonPlusUtilsControllerNavigationUpdate* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_repeat_changed;
	return result;
}

void
proton_plus_utils_controller_navigation_update_set_repeat_changed (ProtonPlusUtilsControllerNavigationUpdate* self,
                                                                   gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_utils_controller_navigation_update_get_repeat_changed (self);
	if (old_value != value) {
		self->priv->_repeat_changed = value;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_utils_controller_navigation_update_properties[PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_REPEAT_CHANGED_PROPERTY]);
	}
}

ProtonPlusUtilsControllerNavigationDirection
proton_plus_utils_controller_navigation_update_get_emitted_direction (ProtonPlusUtilsControllerNavigationUpdate* self)
{
	ProtonPlusUtilsControllerNavigationDirection result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_emitted_direction;
	return result;
}

void
proton_plus_utils_controller_navigation_update_set_emitted_direction (ProtonPlusUtilsControllerNavigationUpdate* self,
                                                                      ProtonPlusUtilsControllerNavigationDirection value)
{
	ProtonPlusUtilsControllerNavigationDirection old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_utils_controller_navigation_update_get_emitted_direction (self);
	if (old_value != value) {
		self->priv->_emitted_direction = value;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_utils_controller_navigation_update_properties[PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_EMITTED_DIRECTION_PROPERTY]);
	}
}

static void
proton_plus_utils_controller_navigation_update_class_init (ProtonPlusUtilsControllerNavigationUpdateClass * klass,
                                                           gpointer klass_data)
{
	proton_plus_utils_controller_navigation_update_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusUtilsControllerNavigationUpdate_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_proton_plus_utils_controller_navigation_update_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_proton_plus_utils_controller_navigation_update_set_property;
	G_OBJECT_CLASS (klass)->finalize = proton_plus_utils_controller_navigation_update_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_OWNERSHIP_CHANGED_PROPERTY, proton_plus_utils_controller_navigation_update_properties[PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_OWNERSHIP_CHANGED_PROPERTY] = g_param_spec_boolean ("ownership-changed", "ownership-changed", "ownership-changed", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_REPEAT_CHANGED_PROPERTY, proton_plus_utils_controller_navigation_update_properties[PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_REPEAT_CHANGED_PROPERTY] = g_param_spec_boolean ("repeat-changed", "repeat-changed", "repeat-changed", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_EMITTED_DIRECTION_PROPERTY, proton_plus_utils_controller_navigation_update_properties[PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_EMITTED_DIRECTION_PROPERTY] = g_param_spec_enum ("emitted-direction", "emitted-direction", "emitted-direction", PROTON_PLUS_UTILS_TYPE_CONTROLLER_NAVIGATION_DIRECTION, PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_NONE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
proton_plus_utils_controller_navigation_update_instance_init (ProtonPlusUtilsControllerNavigationUpdate * self,
                                                              gpointer klass)
{
	self->priv = proton_plus_utils_controller_navigation_update_get_instance_private (self);
	self->priv->_ownership_changed = FALSE;
	self->priv->_repeat_changed = FALSE;
	self->priv->_emitted_direction = PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_NONE;
}

static void
proton_plus_utils_controller_navigation_update_finalize (GObject * obj)
{
	ProtonPlusUtilsControllerNavigationUpdate * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_UTILS_TYPE_CONTROLLER_NAVIGATION_UPDATE, ProtonPlusUtilsControllerNavigationUpdate);
	G_OBJECT_CLASS (proton_plus_utils_controller_navigation_update_parent_class)->finalize (obj);
}

static GType
proton_plus_utils_controller_navigation_update_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusUtilsControllerNavigationUpdateClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_utils_controller_navigation_update_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusUtilsControllerNavigationUpdate), 0, (GInstanceInitFunc) proton_plus_utils_controller_navigation_update_instance_init, NULL };
	GType proton_plus_utils_controller_navigation_update_type_id;
	proton_plus_utils_controller_navigation_update_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusUtilsControllerNavigationUpdate", &g_define_type_info, 0);
	ProtonPlusUtilsControllerNavigationUpdate_private_offset = g_type_add_instance_private (proton_plus_utils_controller_navigation_update_type_id, sizeof (ProtonPlusUtilsControllerNavigationUpdatePrivate));
	return proton_plus_utils_controller_navigation_update_type_id;
}

GType
proton_plus_utils_controller_navigation_update_get_type (void)
{
	static volatile gsize proton_plus_utils_controller_navigation_update_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_utils_controller_navigation_update_type_id__once)) {
		GType proton_plus_utils_controller_navigation_update_type_id;
		proton_plus_utils_controller_navigation_update_type_id = proton_plus_utils_controller_navigation_update_get_type_once ();
		g_once_init_leave (&proton_plus_utils_controller_navigation_update_type_id__once, proton_plus_utils_controller_navigation_update_type_id);
	}
	return proton_plus_utils_controller_navigation_update_type_id__once;
}

static void
_vala_proton_plus_utils_controller_navigation_update_get_property (GObject * object,
                                                                   guint property_id,
                                                                   GValue * value,
                                                                   GParamSpec * pspec)
{
	ProtonPlusUtilsControllerNavigationUpdate * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_UTILS_TYPE_CONTROLLER_NAVIGATION_UPDATE, ProtonPlusUtilsControllerNavigationUpdate);
	switch (property_id) {
		case PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_OWNERSHIP_CHANGED_PROPERTY:
		g_value_set_boolean (value, proton_plus_utils_controller_navigation_update_get_ownership_changed (self));
		break;
		case PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_REPEAT_CHANGED_PROPERTY:
		g_value_set_boolean (value, proton_plus_utils_controller_navigation_update_get_repeat_changed (self));
		break;
		case PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_EMITTED_DIRECTION_PROPERTY:
		g_value_set_enum (value, proton_plus_utils_controller_navigation_update_get_emitted_direction (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_proton_plus_utils_controller_navigation_update_set_property (GObject * object,
                                                                   guint property_id,
                                                                   const GValue * value,
                                                                   GParamSpec * pspec)
{
	ProtonPlusUtilsControllerNavigationUpdate * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_UTILS_TYPE_CONTROLLER_NAVIGATION_UPDATE, ProtonPlusUtilsControllerNavigationUpdate);
	switch (property_id) {
		case PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_OWNERSHIP_CHANGED_PROPERTY:
		proton_plus_utils_controller_navigation_update_set_ownership_changed (self, g_value_get_boolean (value));
		break;
		case PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_REPEAT_CHANGED_PROPERTY:
		proton_plus_utils_controller_navigation_update_set_repeat_changed (self, g_value_get_boolean (value));
		break;
		case PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_UPDATE_EMITTED_DIRECTION_PROPERTY:
		proton_plus_utils_controller_navigation_update_set_emitted_direction (self, g_value_get_enum (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
proton_plus_utils_controller_input_policy_get_instance_private (ProtonPlusUtilsControllerInputPolicy* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusUtilsControllerInputPolicy_private_offset);
}

gdouble
proton_plus_utils_controller_input_policy_normalize_axis (gint16 raw)
{
	gdouble result;
	if (((gint) raw) < 0) {
		result = ((gdouble) raw) / 32768.0;
		return result;
	}
	if (((gint) raw) > 0) {
		result = ((gdouble) raw) / 32767.0;
		return result;
	}
	result = (gdouble) 0;
	return result;
}

ProtonPlusUtilsControllerFaceButtonAction
proton_plus_utils_controller_input_policy_get_face_button_action (ProtonPlusUtilsControllerConfirmButton confirm_button,
                                                                  ProtonPlusUtilsControllerFaceButton button)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	ProtonPlusUtilsControllerFaceButtonAction result;
	if (confirm_button == PROTON_PLUS_UTILS_CONTROLLER_CONFIRM_BUTTON_SOUTH) {
		_tmp1_ = button == PROTON_PLUS_UTILS_CONTROLLER_FACE_BUTTON_SOUTH;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		gboolean _tmp2_ = FALSE;
		if (confirm_button == PROTON_PLUS_UTILS_CONTROLLER_CONFIRM_BUTTON_EAST) {
			_tmp2_ = button == PROTON_PLUS_UTILS_CONTROLLER_FACE_BUTTON_EAST;
		} else {
			_tmp2_ = FALSE;
		}
		_tmp0_ = _tmp2_;
	}
	if (_tmp0_) {
		result = PROTON_PLUS_UTILS_CONTROLLER_FACE_BUTTON_ACTION_ACTIVATE;
		return result;
	}
	result = PROTON_PLUS_UTILS_CONTROLLER_FACE_BUTTON_ACTION_DISMISS;
	return result;
}

void
proton_plus_utils_controller_input_policy_note_controller_activity (ProtonPlusUtilsControllerInputPolicy* self,
                                                                    gint64 now_us)
{
	g_return_if_fail (self != NULL);
	self->priv->last_controller_activity_us = now_us;
}

gboolean
proton_plus_utils_controller_input_policy_should_accept_keyboard_handoff (ProtonPlusUtilsControllerInputPolicy* self,
                                                                          gboolean echo_candidate,
                                                                          gint64 now_us)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (!echo_candidate) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = !proton_plus_utils_controller_input_policy_has_recent_controller_activity (self, now_us);
	}
	result = _tmp0_;
	return result;
}

void
proton_plus_utils_controller_input_policy_note_pointer_position (ProtonPlusUtilsControllerInputPolicy* self,
                                                                 gdouble x,
                                                                 gdouble y)
{
	g_return_if_fail (self != NULL);
	self->priv->has_pointer_position = TRUE;
	self->priv->pointer_x = x;
	self->priv->pointer_y = y;
}

gboolean
proton_plus_utils_controller_input_policy_should_accept_pointer_motion_handoff (ProtonPlusUtilsControllerInputPolicy* self,
                                                                                gdouble x,
                                                                                gdouble y,
                                                                                gint64 now_us)
{
	gboolean _tmp0_ = FALSE;
	gboolean position_changed = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (!self->priv->has_pointer_position) {
		proton_plus_utils_controller_input_policy_note_pointer_position (self, x, y);
		result = FALSE;
		return result;
	}
	if (x != self->priv->pointer_x) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = y != self->priv->pointer_y;
	}
	position_changed = _tmp0_;
	proton_plus_utils_controller_input_policy_note_pointer_position (self, x, y);
	if (position_changed) {
		_tmp1_ = !proton_plus_utils_controller_input_policy_has_recent_controller_activity (self, now_us);
	} else {
		_tmp1_ = FALSE;
	}
	result = _tmp1_;
	return result;
}

gboolean
proton_plus_utils_controller_input_policy_note_button_press (ProtonPlusUtilsControllerInputPolicy* self,
                                                             gint64 device_id)
{
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp0_;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp1_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = proton_plus_utils_controller_input_policy_ensure_device (self, device_id);
	_tmp1_ = _tmp0_;
	_g_object_unref0 (_tmp1_);
	result = proton_plus_utils_controller_input_policy_claim_device (self, device_id, TRUE);
	return result;
}

gboolean
proton_plus_utils_controller_input_policy_begin_repeat (ProtonPlusUtilsControllerInputPolicy* self,
                                                        gint64 device_id,
                                                        ProtonPlusUtilsControllerNavigationDirection direction,
                                                        ProtonPlusUtilsControllerNavigationSource source)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean changed = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (!self->priv->owns_device) {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = self->priv->owned_device_id != device_id;
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = direction == PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_NONE;
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	if (!self->priv->repeat_active) {
		_tmp4_ = TRUE;
	} else {
		_tmp4_ = self->priv->repeating_device_id != device_id;
	}
	if (_tmp4_) {
		_tmp3_ = TRUE;
	} else {
		_tmp3_ = self->priv->repeating_direction != direction;
	}
	if (_tmp3_) {
		_tmp2_ = TRUE;
	} else {
		_tmp2_ = self->priv->repeating_source != source;
	}
	changed = _tmp2_;
	self->priv->repeat_active = TRUE;
	self->priv->repeating_device_id = device_id;
	self->priv->repeating_direction = direction;
	self->priv->repeating_source = source;
	result = changed;
	return result;
}

gboolean
proton_plus_utils_controller_input_policy_release_repeat (ProtonPlusUtilsControllerInputPolicy* self,
                                                          gint64 device_id,
                                                          ProtonPlusUtilsControllerNavigationDirection direction,
                                                          ProtonPlusUtilsControllerNavigationSource source)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (!self->priv->repeat_active) {
		_tmp2_ = TRUE;
	} else {
		_tmp2_ = self->priv->repeating_device_id != device_id;
	}
	if (_tmp2_) {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = self->priv->repeating_direction != direction;
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = self->priv->repeating_source != source;
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	proton_plus_utils_controller_input_policy_cancel_repeat (self);
	result = TRUE;
	return result;
}

void
proton_plus_utils_controller_input_policy_cancel_repeat (ProtonPlusUtilsControllerInputPolicy* self)
{
	g_return_if_fail (self != NULL);
	self->priv->repeat_active = FALSE;
	self->priv->repeating_device_id = (gint64) 0;
	self->priv->repeating_direction = PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_NONE;
	self->priv->repeating_source = PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_SOURCE_DPAD;
}

ProtonPlusUtilsControllerNavigationUpdate*
proton_plus_utils_controller_input_policy_update_left_axis (ProtonPlusUtilsControllerInputPolicy* self,
                                                            gint64 device_id,
                                                            gboolean horizontal,
                                                            gint16 raw)
{
	ProtonPlusUtilsControllerNavigationUpdate* update = NULL;
	ProtonPlusUtilsControllerNavigationUpdate* _tmp0_;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* device = NULL;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp1_;
	gboolean was_engaged = FALSE;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp2_;
	gboolean is_engaged = FALSE;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp5_;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_ = FALSE;
	gboolean _tmp8_ = FALSE;
	gboolean _tmp10_ = FALSE;
	ProtonPlusUtilsControllerNavigationDirection next_direction = 0;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp14_;
	ProtonPlusUtilsControllerNavigationDirection previous_direction = 0;
	ProtonPlusUtilsControllerNavigationUpdate* _tmp16_;
	ProtonPlusUtilsControllerNavigationUpdate* _tmp17_;
	ProtonPlusUtilsControllerNavigationUpdate* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = proton_plus_utils_controller_navigation_update_new ();
	update = _tmp0_;
	_tmp1_ = proton_plus_utils_controller_input_policy_ensure_device (self, device_id);
	device = _tmp1_;
	_tmp2_ = device;
	was_engaged = proton_plus_utils_controller_input_policy_maximum_left_magnitude (self, _tmp2_) >= PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_LEFT_STICK_ENGAGEMENT_THRESHOLD;
	if (horizontal) {
		ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp3_;
		_tmp3_ = device;
		_tmp3_->left_x = proton_plus_utils_controller_input_policy_normalize_axis (raw);
	} else {
		ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp4_;
		_tmp4_ = device;
		_tmp4_->left_y = proton_plus_utils_controller_input_policy_normalize_axis (raw);
	}
	_tmp5_ = device;
	is_engaged = proton_plus_utils_controller_input_policy_maximum_left_magnitude (self, _tmp5_) >= PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_LEFT_STICK_ENGAGEMENT_THRESHOLD;
	if (!self->priv->owns_device) {
		_tmp8_ = TRUE;
	} else {
		_tmp8_ = self->priv->owned_device_id != device_id;
	}
	if (_tmp8_) {
		_tmp7_ = !was_engaged;
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		_tmp6_ = is_engaged;
	} else {
		_tmp6_ = FALSE;
	}
	if (_tmp6_) {
		ProtonPlusUtilsControllerNavigationUpdate* _tmp9_;
		_tmp9_ = update;
		proton_plus_utils_controller_navigation_update_set_ownership_changed (_tmp9_, proton_plus_utils_controller_input_policy_claim_device (self, device_id, FALSE));
	}
	if (!self->priv->owns_device) {
		_tmp10_ = TRUE;
	} else {
		_tmp10_ = self->priv->owned_device_id != device_id;
	}
	if (_tmp10_) {
		result = update;
		_g_object_unref0 (device);
		return result;
	}
	if (self->priv->analog_suppressed) {
		gboolean _tmp11_ = FALSE;
		ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp12_;
		_tmp12_ = device;
		if (fabs (_tmp12_->left_x) < PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_LEFT_STICK_RELEASE_THRESHOLD) {
			ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp13_;
			_tmp13_ = device;
			_tmp11_ = fabs (_tmp13_->left_y) < PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_LEFT_STICK_RELEASE_THRESHOLD;
		} else {
			_tmp11_ = FALSE;
		}
		if (_tmp11_) {
			self->priv->analog_suppressed = FALSE;
		}
		result = update;
		_g_object_unref0 (device);
		return result;
	}
	_tmp14_ = device;
	next_direction = proton_plus_utils_controller_input_policy_choose_latched_direction (self, _tmp14_);
	if (next_direction == self->priv->analog_direction) {
		result = update;
		_g_object_unref0 (device);
		return result;
	}
	previous_direction = self->priv->analog_direction;
	self->priv->analog_direction = next_direction;
	if (next_direction == PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_NONE) {
		ProtonPlusUtilsControllerNavigationUpdate* _tmp15_;
		_tmp15_ = update;
		proton_plus_utils_controller_navigation_update_set_repeat_changed (_tmp15_, proton_plus_utils_controller_input_policy_release_repeat (self, device_id, previous_direction, PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_SOURCE_LEFT_STICK));
		result = update;
		_g_object_unref0 (device);
		return result;
	}
	_tmp16_ = update;
	proton_plus_utils_controller_navigation_update_set_emitted_direction (_tmp16_, next_direction);
	_tmp17_ = update;
	proton_plus_utils_controller_navigation_update_set_repeat_changed (_tmp17_, proton_plus_utils_controller_input_policy_begin_repeat (self, device_id, next_direction, PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_SOURCE_LEFT_STICK));
	result = update;
	_g_object_unref0 (device);
	return result;
}

gboolean
proton_plus_utils_controller_input_policy_update_right_axis (ProtonPlusUtilsControllerInputPolicy* self,
                                                             gint64 device_id,
                                                             gint16 raw)
{
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* device = NULL;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp0_;
	gboolean was_outside = FALSE;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp1_;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp2_;
	gboolean is_outside = FALSE;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp3_;
	gboolean ownership_changed = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = proton_plus_utils_controller_input_policy_ensure_device (self, device_id);
	device = _tmp0_;
	_tmp1_ = device;
	was_outside = fabs (_tmp1_->right_y) > PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_RIGHT_STICK_DEADZONE;
	_tmp2_ = device;
	_tmp2_->right_y = proton_plus_utils_controller_input_policy_normalize_axis (raw);
	_tmp3_ = device;
	is_outside = fabs (_tmp3_->right_y) > PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_RIGHT_STICK_DEADZONE;
	ownership_changed = FALSE;
	if (!self->priv->owns_device) {
		_tmp6_ = TRUE;
	} else {
		_tmp6_ = self->priv->owned_device_id != device_id;
	}
	if (_tmp6_) {
		_tmp5_ = !was_outside;
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		_tmp4_ = is_outside;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		ownership_changed = proton_plus_utils_controller_input_policy_claim_device (self, device_id, FALSE);
	}
	if (self->priv->owns_device) {
		_tmp7_ = self->priv->owned_device_id == device_id;
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		if (self->priv->scroll_suppressed) {
			if (!is_outside) {
				self->priv->scroll_suppressed = FALSE;
			}
			self->priv->owned_scroll_intent = (gdouble) 0;
		} else {
			gdouble _tmp8_ = 0.0;
			if (is_outside) {
				ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp9_;
				_tmp9_ = device;
				_tmp8_ = _tmp9_->right_y;
			} else {
				_tmp8_ = (gdouble) 0;
			}
			self->priv->owned_scroll_intent = _tmp8_;
		}
	}
	result = ownership_changed;
	_g_object_unref0 (device);
	return result;
}

gboolean
proton_plus_utils_controller_input_policy_disconnect_device (ProtonPlusUtilsControllerInputPolicy* self,
                                                             gint64 device_id)
{
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* device = NULL;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp0_;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp1_;
	gboolean _tmp4_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = proton_plus_utils_controller_input_policy_find_device (self, device_id);
	device = _tmp0_;
	_tmp1_ = device;
	if (_tmp1_ != NULL) {
		GeeArrayList* _tmp2_;
		ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp3_;
		_tmp2_ = self->priv->devices;
		_tmp3_ = device;
		gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp2_, _tmp3_);
	}
	if (!self->priv->owns_device) {
		_tmp4_ = TRUE;
	} else {
		_tmp4_ = self->priv->owned_device_id != device_id;
	}
	if (_tmp4_) {
		result = FALSE;
		_g_object_unref0 (device);
		return result;
	}
	proton_plus_utils_controller_input_policy_clear_ownership (self);
	result = TRUE;
	_g_object_unref0 (device);
	return result;
}

void
proton_plus_utils_controller_input_policy_surface_changed (ProtonPlusUtilsControllerInputPolicy* self)
{
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* device = NULL;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp5_ = FALSE;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp0_ = proton_plus_utils_controller_input_policy_get_owned_device (self);
	device = _tmp0_;
	if (self->priv->analog_direction != PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_NONE) {
		_tmp1_ = TRUE;
	} else {
		gboolean _tmp2_ = FALSE;
		ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp3_;
		_tmp3_ = device;
		if (_tmp3_ != NULL) {
			ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp4_;
			_tmp4_ = device;
			_tmp2_ = proton_plus_utils_controller_input_policy_maximum_left_magnitude (self, _tmp4_) >= PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_LEFT_STICK_RELEASE_THRESHOLD;
		} else {
			_tmp2_ = FALSE;
		}
		_tmp1_ = _tmp2_;
	}
	if (_tmp1_) {
		self->priv->analog_suppressed = TRUE;
	}
	_tmp6_ = device;
	if (_tmp6_ != NULL) {
		ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp7_;
		_tmp7_ = device;
		_tmp5_ = fabs (_tmp7_->right_y) > PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_RIGHT_STICK_DEADZONE;
	} else {
		_tmp5_ = FALSE;
	}
	self->priv->scroll_suppressed = _tmp5_;
	self->priv->analog_direction = PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_NONE;
	self->priv->owned_scroll_intent = (gdouble) 0;
	proton_plus_utils_controller_input_policy_cancel_repeat (self);
	_g_object_unref0 (device);
}

void
proton_plus_utils_controller_input_policy_reset_transient_input (ProtonPlusUtilsControllerInputPolicy* self)
{
	g_return_if_fail (self != NULL);
	{
		GeeArrayList* _device_list = NULL;
		GeeArrayList* _tmp0_;
		gint _device_size = 0;
		GeeArrayList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _device_index = 0;
		_tmp0_ = self->priv->devices;
		_device_list = _tmp0_;
		_tmp1_ = _device_list;
		_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_device_size = _tmp3_;
		_device_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			ProtonPlusUtilsControllerInputPolicyDeviceAxes* device = NULL;
			GeeArrayList* _tmp6_;
			gpointer _tmp7_;
			ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp8_;
			ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp9_;
			ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp10_;
			_device_index = _device_index + 1;
			_tmp4_ = _device_index;
			_tmp5_ = _device_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _device_list;
			_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp6_, _device_index);
			device = (ProtonPlusUtilsControllerInputPolicyDeviceAxes*) _tmp7_;
			_tmp8_ = device;
			_tmp8_->left_x = (gdouble) 0;
			_tmp9_ = device;
			_tmp9_->left_y = (gdouble) 0;
			_tmp10_ = device;
			_tmp10_->right_y = (gdouble) 0;
			_g_object_unref0 (device);
		}
	}
	self->priv->analog_direction = PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_NONE;
	self->priv->analog_suppressed = FALSE;
	self->priv->scroll_suppressed = FALSE;
	self->priv->owned_scroll_intent = (gdouble) 0;
	proton_plus_utils_controller_input_policy_cancel_repeat (self);
	self->priv->last_controller_activity_us = (gint64) -1;
	self->priv->has_pointer_position = FALSE;
}

void
proton_plus_utils_controller_input_policy_reset (ProtonPlusUtilsControllerInputPolicy* self)
{
	GeeArrayList* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->devices;
	gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp0_);
	proton_plus_utils_controller_input_policy_clear_ownership (self);
	self->priv->last_controller_activity_us = (gint64) -1;
	self->priv->has_pointer_position = FALSE;
}

static gboolean
proton_plus_utils_controller_input_policy_claim_device (ProtonPlusUtilsControllerInputPolicy* self,
                                                        gint64 device_id,
                                                        gboolean suppress_held_axes)
{
	gboolean _tmp0_ = FALSE;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* device = NULL;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (self->priv->owns_device) {
		_tmp0_ = self->priv->owned_device_id == device_id;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	_tmp1_ = proton_plus_utils_controller_input_policy_ensure_device (self, device_id);
	device = _tmp1_;
	self->priv->owns_device = TRUE;
	self->priv->owned_device_id = device_id;
	self->priv->analog_direction = PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_NONE;
	if (suppress_held_axes) {
		ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp3_;
		_tmp3_ = device;
		_tmp2_ = proton_plus_utils_controller_input_policy_maximum_left_magnitude (self, _tmp3_) >= PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_LEFT_STICK_RELEASE_THRESHOLD;
	} else {
		_tmp2_ = FALSE;
	}
	self->priv->analog_suppressed = _tmp2_;
	if (suppress_held_axes) {
		ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp5_;
		_tmp5_ = device;
		_tmp4_ = fabs (_tmp5_->right_y) > PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_RIGHT_STICK_DEADZONE;
	} else {
		_tmp4_ = FALSE;
	}
	self->priv->scroll_suppressed = _tmp4_;
	self->priv->owned_scroll_intent = (gdouble) 0;
	proton_plus_utils_controller_input_policy_cancel_repeat (self);
	result = TRUE;
	_g_object_unref0 (device);
	return result;
}

static void
proton_plus_utils_controller_input_policy_clear_ownership (ProtonPlusUtilsControllerInputPolicy* self)
{
	g_return_if_fail (self != NULL);
	self->priv->owns_device = FALSE;
	self->priv->owned_device_id = (gint64) 0;
	self->priv->analog_direction = PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_NONE;
	self->priv->analog_suppressed = FALSE;
	self->priv->scroll_suppressed = FALSE;
	self->priv->owned_scroll_intent = (gdouble) 0;
	proton_plus_utils_controller_input_policy_cancel_repeat (self);
}

static gboolean
proton_plus_utils_controller_input_policy_has_recent_controller_activity (ProtonPlusUtilsControllerInputPolicy* self,
                                                                          gint64 now_us)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (self->priv->last_controller_activity_us >= ((gint64) 0)) {
		_tmp1_ = now_us >= self->priv->last_controller_activity_us;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = (now_us - self->priv->last_controller_activity_us) <= PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_NON_CONTROLLER_ECHO_GUARD_US;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static ProtonPlusUtilsControllerNavigationDirection
proton_plus_utils_controller_input_policy_choose_latched_direction (ProtonPlusUtilsControllerInputPolicy* self,
                                                                    ProtonPlusUtilsControllerInputPolicyDeviceAxes* device)
{
	gdouble horizontal_magnitude = 0.0;
	gdouble vertical_magnitude = 0.0;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp6_ = FALSE;
	ProtonPlusUtilsControllerNavigationDirection _tmp8_ = 0;
	ProtonPlusUtilsControllerNavigationDirection result;
	g_return_val_if_fail (self != NULL, 0);
	g_return_val_if_fail (device != NULL, 0);
	horizontal_magnitude = fabs (device->left_x);
	vertical_magnitude = fabs (device->left_y);
	if (self->priv->analog_direction == PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_LEFT) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = self->priv->analog_direction == PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_RIGHT;
	}
	if (_tmp0_) {
		gboolean _tmp1_ = FALSE;
		if (horizontal_magnitude >= PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_LEFT_STICK_RELEASE_THRESHOLD) {
			gboolean _tmp2_ = FALSE;
			if (vertical_magnitude >= PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_LEFT_STICK_ENGAGEMENT_THRESHOLD) {
				_tmp2_ = vertical_magnitude > (horizontal_magnitude + PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_DOMINANT_AXIS_MARGIN);
			} else {
				_tmp2_ = FALSE;
			}
			_tmp1_ = !_tmp2_;
		} else {
			_tmp1_ = FALSE;
		}
		if (_tmp1_) {
			if (device->left_x < ((gdouble) 0)) {
				result = PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_LEFT;
				return result;
			}
			if (device->left_x > ((gdouble) 0)) {
				result = PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_RIGHT;
				return result;
			}
		}
	} else {
		gboolean _tmp3_ = FALSE;
		if (self->priv->analog_direction == PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_UP) {
			_tmp3_ = TRUE;
		} else {
			_tmp3_ = self->priv->analog_direction == PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_DOWN;
		}
		if (_tmp3_) {
			gboolean _tmp4_ = FALSE;
			if (vertical_magnitude >= PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_LEFT_STICK_RELEASE_THRESHOLD) {
				gboolean _tmp5_ = FALSE;
				if (horizontal_magnitude >= PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_LEFT_STICK_ENGAGEMENT_THRESHOLD) {
					_tmp5_ = horizontal_magnitude > (vertical_magnitude + PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_DOMINANT_AXIS_MARGIN);
				} else {
					_tmp5_ = FALSE;
				}
				_tmp4_ = !_tmp5_;
			} else {
				_tmp4_ = FALSE;
			}
			if (_tmp4_) {
				if (device->left_y < ((gdouble) 0)) {
					result = PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_UP;
					return result;
				}
				if (device->left_y > ((gdouble) 0)) {
					result = PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_DOWN;
					return result;
				}
			}
		}
	}
	if (horizontal_magnitude < PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_LEFT_STICK_ENGAGEMENT_THRESHOLD) {
		_tmp6_ = vertical_magnitude < PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_LEFT_STICK_ENGAGEMENT_THRESHOLD;
	} else {
		_tmp6_ = FALSE;
	}
	if (_tmp6_) {
		result = PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_NONE;
		return result;
	}
	if (horizontal_magnitude > vertical_magnitude) {
		ProtonPlusUtilsControllerNavigationDirection _tmp7_ = 0;
		if (device->left_x < ((gdouble) 0)) {
			_tmp7_ = PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_LEFT;
		} else {
			_tmp7_ = PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_RIGHT;
		}
		result = _tmp7_;
		return result;
	}
	if (device->left_y < ((gdouble) 0)) {
		_tmp8_ = PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_UP;
	} else {
		_tmp8_ = PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_DOWN;
	}
	result = _tmp8_;
	return result;
}

static gdouble
proton_plus_utils_controller_input_policy_maximum_left_magnitude (ProtonPlusUtilsControllerInputPolicy* self,
                                                                  ProtonPlusUtilsControllerInputPolicyDeviceAxes* device)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	g_return_val_if_fail (device != NULL, -1.0);
	result = MAX (fabs (device->left_x), fabs (device->left_y));
	return result;
}

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

static ProtonPlusUtilsControllerInputPolicyDeviceAxes*
proton_plus_utils_controller_input_policy_ensure_device (ProtonPlusUtilsControllerInputPolicy* self,
                                                         gint64 device_id)
{
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* device = NULL;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp0_;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp1_;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp5_;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp6_;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = proton_plus_utils_controller_input_policy_find_device (self, device_id);
	device = _tmp0_;
	_tmp1_ = device;
	if (_tmp1_ == NULL) {
		ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp2_;
		GeeArrayList* _tmp3_;
		ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp4_;
		_tmp2_ = proton_plus_utils_controller_input_policy_device_axes_new (device_id);
		_g_object_unref0 (device);
		device = _tmp2_;
		_tmp3_ = self->priv->devices;
		_tmp4_ = device;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp3_, _tmp4_);
	}
	_tmp5_ = device;
	_tmp6_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_TYPE_DEVICE_AXES, ProtonPlusUtilsControllerInputPolicyDeviceAxes));
	result = _tmp6_;
	_g_object_unref0 (device);
	return result;
}

static ProtonPlusUtilsControllerInputPolicyDeviceAxes*
proton_plus_utils_controller_input_policy_find_device (ProtonPlusUtilsControllerInputPolicy* self,
                                                       gint64 device_id)
{
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* result;
	g_return_val_if_fail (self != NULL, NULL);
	{
		GeeArrayList* _device_list = NULL;
		GeeArrayList* _tmp0_;
		gint _device_size = 0;
		GeeArrayList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _device_index = 0;
		_tmp0_ = self->priv->devices;
		_device_list = _tmp0_;
		_tmp1_ = _device_list;
		_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_device_size = _tmp3_;
		_device_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			ProtonPlusUtilsControllerInputPolicyDeviceAxes* device = NULL;
			GeeArrayList* _tmp6_;
			gpointer _tmp7_;
			ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp8_;
			_device_index = _device_index + 1;
			_tmp4_ = _device_index;
			_tmp5_ = _device_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _device_list;
			_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp6_, _device_index);
			device = (ProtonPlusUtilsControllerInputPolicyDeviceAxes*) _tmp7_;
			_tmp8_ = device;
			if (_tmp8_->id == device_id) {
				result = device;
				return result;
			}
			_g_object_unref0 (device);
		}
	}
	result = NULL;
	return result;
}

static ProtonPlusUtilsControllerInputPolicyDeviceAxes*
proton_plus_utils_controller_input_policy_get_owned_device (ProtonPlusUtilsControllerInputPolicy* self)
{
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp0_ = NULL;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp2_;
	ProtonPlusUtilsControllerInputPolicyDeviceAxes* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (self->priv->owns_device) {
		ProtonPlusUtilsControllerInputPolicyDeviceAxes* _tmp1_;
		_tmp1_ = proton_plus_utils_controller_input_policy_find_device (self, self->priv->owned_device_id);
		_g_object_unref0 (_tmp0_);
		_tmp0_ = _tmp1_;
	} else {
		_g_object_unref0 (_tmp0_);
		_tmp0_ = NULL;
	}
	_tmp2_ = _tmp0_;
	_tmp0_ = NULL;
	result = _tmp2_;
	_g_object_unref0 (_tmp0_);
	return result;
}

ProtonPlusUtilsControllerInputPolicy*
proton_plus_utils_controller_input_policy_construct (GType object_type)
{
	ProtonPlusUtilsControllerInputPolicy * self = NULL;
	self = (ProtonPlusUtilsControllerInputPolicy*) g_object_new (object_type, NULL);
	return self;
}

ProtonPlusUtilsControllerInputPolicy*
proton_plus_utils_controller_input_policy_new (void)
{
	return proton_plus_utils_controller_input_policy_construct (PROTON_PLUS_UTILS_TYPE_CONTROLLER_INPUT_POLICY);
}

gboolean
proton_plus_utils_controller_input_policy_get_has_active_device (ProtonPlusUtilsControllerInputPolicy* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->owns_device;
	return result;
}

gint64
proton_plus_utils_controller_input_policy_get_active_device_id (ProtonPlusUtilsControllerInputPolicy* self)
{
	gint64 result;
	g_return_val_if_fail (self != NULL, -1LL);
	result = self->priv->owned_device_id;
	return result;
}

gdouble
proton_plus_utils_controller_input_policy_get_scroll_intent (ProtonPlusUtilsControllerInputPolicy* self)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	result = self->priv->owned_scroll_intent;
	return result;
}

gboolean
proton_plus_utils_controller_input_policy_get_has_repeat (ProtonPlusUtilsControllerInputPolicy* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->repeat_active;
	return result;
}

gint64
proton_plus_utils_controller_input_policy_get_repeat_device_id (ProtonPlusUtilsControllerInputPolicy* self)
{
	gint64 result;
	g_return_val_if_fail (self != NULL, -1LL);
	result = self->priv->repeating_device_id;
	return result;
}

ProtonPlusUtilsControllerNavigationDirection
proton_plus_utils_controller_input_policy_get_repeat_direction (ProtonPlusUtilsControllerInputPolicy* self)
{
	ProtonPlusUtilsControllerNavigationDirection result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->repeating_direction;
	return result;
}

ProtonPlusUtilsControllerNavigationSource
proton_plus_utils_controller_input_policy_get_repeat_source (ProtonPlusUtilsControllerInputPolicy* self)
{
	ProtonPlusUtilsControllerNavigationSource result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->repeating_source;
	return result;
}

static ProtonPlusUtilsControllerInputPolicyDeviceAxes*
proton_plus_utils_controller_input_policy_device_axes_construct (GType object_type,
                                                                 gint64 id)
{
	ProtonPlusUtilsControllerInputPolicyDeviceAxes * self = NULL;
	self = (ProtonPlusUtilsControllerInputPolicyDeviceAxes*) g_object_new (object_type, NULL);
	self->id = id;
	return self;
}

static ProtonPlusUtilsControllerInputPolicyDeviceAxes*
proton_plus_utils_controller_input_policy_device_axes_new (gint64 id)
{
	return proton_plus_utils_controller_input_policy_device_axes_construct (PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_TYPE_DEVICE_AXES, id);
}

static void
proton_plus_utils_controller_input_policy_device_axes_class_init (ProtonPlusUtilsControllerInputPolicyDeviceAxesClass * klass,
                                                                  gpointer klass_data)
{
	proton_plus_utils_controller_input_policy_device_axes_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = proton_plus_utils_controller_input_policy_device_axes_finalize;
}

static void
proton_plus_utils_controller_input_policy_device_axes_instance_init (ProtonPlusUtilsControllerInputPolicyDeviceAxes * self,
                                                                     gpointer klass)
{
	self->left_x = (gdouble) 0;
	self->left_y = (gdouble) 0;
	self->right_y = (gdouble) 0;
}

static void
proton_plus_utils_controller_input_policy_device_axes_finalize (GObject * obj)
{
	ProtonPlusUtilsControllerInputPolicyDeviceAxes * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_TYPE_DEVICE_AXES, ProtonPlusUtilsControllerInputPolicyDeviceAxes);
	G_OBJECT_CLASS (proton_plus_utils_controller_input_policy_device_axes_parent_class)->finalize (obj);
}

static GType
proton_plus_utils_controller_input_policy_device_axes_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusUtilsControllerInputPolicyDeviceAxesClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_utils_controller_input_policy_device_axes_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusUtilsControllerInputPolicyDeviceAxes), 0, (GInstanceInitFunc) proton_plus_utils_controller_input_policy_device_axes_instance_init, NULL };
	GType proton_plus_utils_controller_input_policy_device_axes_type_id;
	proton_plus_utils_controller_input_policy_device_axes_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusUtilsControllerInputPolicyDeviceAxes", &g_define_type_info, 0);
	return proton_plus_utils_controller_input_policy_device_axes_type_id;
}

static GType
proton_plus_utils_controller_input_policy_device_axes_get_type (void)
{
	static volatile gsize proton_plus_utils_controller_input_policy_device_axes_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_utils_controller_input_policy_device_axes_type_id__once)) {
		GType proton_plus_utils_controller_input_policy_device_axes_type_id;
		proton_plus_utils_controller_input_policy_device_axes_type_id = proton_plus_utils_controller_input_policy_device_axes_get_type_once ();
		g_once_init_leave (&proton_plus_utils_controller_input_policy_device_axes_type_id__once, proton_plus_utils_controller_input_policy_device_axes_type_id);
	}
	return proton_plus_utils_controller_input_policy_device_axes_type_id__once;
}

static void
proton_plus_utils_controller_input_policy_class_init (ProtonPlusUtilsControllerInputPolicyClass * klass,
                                                      gpointer klass_data)
{
	proton_plus_utils_controller_input_policy_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusUtilsControllerInputPolicy_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_proton_plus_utils_controller_input_policy_get_property;
	G_OBJECT_CLASS (klass)->finalize = proton_plus_utils_controller_input_policy_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_HAS_ACTIVE_DEVICE_PROPERTY, proton_plus_utils_controller_input_policy_properties[PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_HAS_ACTIVE_DEVICE_PROPERTY] = g_param_spec_boolean ("has-active-device", "has-active-device", "has-active-device", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_ACTIVE_DEVICE_ID_PROPERTY, proton_plus_utils_controller_input_policy_properties[PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_ACTIVE_DEVICE_ID_PROPERTY] = g_param_spec_int64 ("active-device-id", "active-device-id", "active-device-id", G_MININT64, G_MAXINT64, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_SCROLL_INTENT_PROPERTY, proton_plus_utils_controller_input_policy_properties[PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_SCROLL_INTENT_PROPERTY] = g_param_spec_double ("scroll-intent", "scroll-intent", "scroll-intent", -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_HAS_REPEAT_PROPERTY, proton_plus_utils_controller_input_policy_properties[PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_HAS_REPEAT_PROPERTY] = g_param_spec_boolean ("has-repeat", "has-repeat", "has-repeat", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_REPEAT_DEVICE_ID_PROPERTY, proton_plus_utils_controller_input_policy_properties[PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_REPEAT_DEVICE_ID_PROPERTY] = g_param_spec_int64 ("repeat-device-id", "repeat-device-id", "repeat-device-id", G_MININT64, G_MAXINT64, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_REPEAT_DIRECTION_PROPERTY, proton_plus_utils_controller_input_policy_properties[PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_REPEAT_DIRECTION_PROPERTY] = g_param_spec_enum ("repeat-direction", "repeat-direction", "repeat-direction", PROTON_PLUS_UTILS_TYPE_CONTROLLER_NAVIGATION_DIRECTION, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_REPEAT_SOURCE_PROPERTY, proton_plus_utils_controller_input_policy_properties[PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_REPEAT_SOURCE_PROPERTY] = g_param_spec_enum ("repeat-source", "repeat-source", "repeat-source", PROTON_PLUS_UTILS_TYPE_CONTROLLER_NAVIGATION_SOURCE, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
proton_plus_utils_controller_input_policy_instance_init (ProtonPlusUtilsControllerInputPolicy * self,
                                                         gpointer klass)
{
	GeeArrayList* _tmp0_;
	self->priv = proton_plus_utils_controller_input_policy_get_instance_private (self);
	_tmp0_ = gee_array_list_new (PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_TYPE_DEVICE_AXES, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	self->priv->devices = _tmp0_;
	self->priv->owns_device = FALSE;
	self->priv->owned_device_id = (gint64) 0;
	self->priv->analog_direction = PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_NONE;
	self->priv->analog_suppressed = FALSE;
	self->priv->scroll_suppressed = FALSE;
	self->priv->owned_scroll_intent = (gdouble) 0;
	self->priv->repeat_active = FALSE;
	self->priv->repeating_device_id = (gint64) 0;
	self->priv->repeating_direction = PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_DIRECTION_NONE;
	self->priv->repeating_source = PROTON_PLUS_UTILS_CONTROLLER_NAVIGATION_SOURCE_DPAD;
	self->priv->last_controller_activity_us = (gint64) -1;
	self->priv->has_pointer_position = FALSE;
	self->priv->pointer_x = (gdouble) 0;
	self->priv->pointer_y = (gdouble) 0;
}

static void
proton_plus_utils_controller_input_policy_finalize (GObject * obj)
{
	ProtonPlusUtilsControllerInputPolicy * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_UTILS_TYPE_CONTROLLER_INPUT_POLICY, ProtonPlusUtilsControllerInputPolicy);
	_g_object_unref0 (self->priv->devices);
	G_OBJECT_CLASS (proton_plus_utils_controller_input_policy_parent_class)->finalize (obj);
}

static GType
proton_plus_utils_controller_input_policy_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusUtilsControllerInputPolicyClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_utils_controller_input_policy_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusUtilsControllerInputPolicy), 0, (GInstanceInitFunc) proton_plus_utils_controller_input_policy_instance_init, NULL };
	GType proton_plus_utils_controller_input_policy_type_id;
	proton_plus_utils_controller_input_policy_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusUtilsControllerInputPolicy", &g_define_type_info, 0);
	ProtonPlusUtilsControllerInputPolicy_private_offset = g_type_add_instance_private (proton_plus_utils_controller_input_policy_type_id, sizeof (ProtonPlusUtilsControllerInputPolicyPrivate));
	return proton_plus_utils_controller_input_policy_type_id;
}

GType
proton_plus_utils_controller_input_policy_get_type (void)
{
	static volatile gsize proton_plus_utils_controller_input_policy_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_utils_controller_input_policy_type_id__once)) {
		GType proton_plus_utils_controller_input_policy_type_id;
		proton_plus_utils_controller_input_policy_type_id = proton_plus_utils_controller_input_policy_get_type_once ();
		g_once_init_leave (&proton_plus_utils_controller_input_policy_type_id__once, proton_plus_utils_controller_input_policy_type_id);
	}
	return proton_plus_utils_controller_input_policy_type_id__once;
}

static void
_vala_proton_plus_utils_controller_input_policy_get_property (GObject * object,
                                                              guint property_id,
                                                              GValue * value,
                                                              GParamSpec * pspec)
{
	ProtonPlusUtilsControllerInputPolicy * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_UTILS_TYPE_CONTROLLER_INPUT_POLICY, ProtonPlusUtilsControllerInputPolicy);
	switch (property_id) {
		case PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_HAS_ACTIVE_DEVICE_PROPERTY:
		g_value_set_boolean (value, proton_plus_utils_controller_input_policy_get_has_active_device (self));
		break;
		case PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_ACTIVE_DEVICE_ID_PROPERTY:
		g_value_set_int64 (value, proton_plus_utils_controller_input_policy_get_active_device_id (self));
		break;
		case PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_SCROLL_INTENT_PROPERTY:
		g_value_set_double (value, proton_plus_utils_controller_input_policy_get_scroll_intent (self));
		break;
		case PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_HAS_REPEAT_PROPERTY:
		g_value_set_boolean (value, proton_plus_utils_controller_input_policy_get_has_repeat (self));
		break;
		case PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_REPEAT_DEVICE_ID_PROPERTY:
		g_value_set_int64 (value, proton_plus_utils_controller_input_policy_get_repeat_device_id (self));
		break;
		case PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_REPEAT_DIRECTION_PROPERTY:
		g_value_set_enum (value, proton_plus_utils_controller_input_policy_get_repeat_direction (self));
		break;
		case PROTON_PLUS_UTILS_CONTROLLER_INPUT_POLICY_REPEAT_SOURCE_PROPERTY:
		g_value_set_enum (value, proton_plus_utils_controller_input_policy_get_repeat_source (self));
		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;
}

