/*
 * This file is part of roccat-tools.
 *
 * roccat-tools is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * roccat-tools is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with roccat-tools. If not, see <http://www.gnu.org/licenses/>.
 */

#include "pyraconfig_sensitivity_selector.h"
#include <gaminggear/gaminggear_xy_scales.h>

#define PYRACONFIG_SENSITIVITY_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PYRACONFIG_SENSITIVITY_SELECTOR_TYPE, PyraconfigSensitivitySelectorClass))
#define IS_PYRACONFIG_SENSITIVITY_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PYRACONFIG_SENSITIVITY_SELECTOR_TYPE))

typedef struct _PyraconfigSensitivitySelectorClass PyraconfigSensitivitySelectorClass;

struct _PyraconfigSensitivitySelector {
	GaminggearXyScales parent;
};

struct _PyraconfigSensitivitySelectorClass {
	GaminggearXyScalesClass parent_class;
};

G_DEFINE_TYPE(PyraconfigSensitivitySelector, pyraconfig_sensitivity_selector, GAMINGGEAR_XY_SCALES_TYPE);

void pyraconfig_sensitivity_selector_set_from_rmp(PyraconfigSensitivitySelector *selector, PyraRMP *rmp) {
	GaminggearXyScales *gaminggear_selector = GAMINGGEAR_XY_SCALES(selector);
	gaminggear_xy_scales_set_x_value(gaminggear_selector, pyra_rmp_get_sensitivity_x(rmp));
	gaminggear_xy_scales_set_y_value(gaminggear_selector, pyra_rmp_get_sensitivity_y(rmp));
}

void pyraconfig_sensitivity_selector_update_rmp(PyraconfigSensitivitySelector *selector, PyraRMP *rmp) {
	GaminggearXyScales *gaminggear_selector = GAMINGGEAR_XY_SCALES(selector);
	pyra_rmp_set_sensitivity_x(rmp, gaminggear_xy_scales_get_x_value(gaminggear_selector));
	pyra_rmp_set_sensitivity_y(rmp, gaminggear_xy_scales_get_y_value(gaminggear_selector));
}

GtkWidget *pyraconfig_sensitivity_selector_new(void) {
	PyraconfigSensitivitySelector *selector;

	selector = PYRACONFIG_SENSITIVITY_SELECTOR(g_object_new(PYRACONFIG_SENSITIVITY_SELECTOR_TYPE,
			"min", (gdouble)PYRA_SENSITIVITY_MIN,
			"max", (gdouble)PYRA_SENSITIVITY_MAX,
			"step", (gdouble)1.0,
			NULL));

	return GTK_WIDGET(selector);
}

static void pyraconfig_sensitivity_selector_init(PyraconfigSensitivitySelector *selector) {}

static void pyraconfig_sensitivity_selector_class_init(PyraconfigSensitivitySelectorClass *klass) {}
