#ifndef __ROCCAT_DEVICE_H__
#define __ROCCAT_DEVICE_H__

/*
 * 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 <glib-object.h>

G_BEGIN_DECLS

#define ROCCAT_DEVICE_TYPE (roccat_device_get_type())
#define ROCCAT_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), ROCCAT_DEVICE_TYPE, RoccatDevice))
#define IS_ROCCAT_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), ROCCAT_DEVICE_TYPE))

typedef struct _RoccatDevice RoccatDevice;
typedef struct _RoccatDevicePrivate RoccatDevicePrivate;

struct _RoccatDevice {
	GObject parent;
	RoccatDevicePrivate *priv;
};

GType roccat_device_get_type(void);
RoccatDevice *roccat_device_new(gchar const *identifier);

gboolean roccat_device_equal(RoccatDevice const *one, RoccatDevice const *other);

gchar const *roccat_device_get_identifier(RoccatDevice const *roccat_dev);

guint roccat_device_get_product_id(RoccatDevice const *roccat_dev);
void roccat_device_set_product_id(RoccatDevice *roccat_dev, guint product_id);

gchar const *roccat_device_get_drivername(RoccatDevice const *roccat_dev);
void roccat_device_set_drivername(RoccatDevice *roccat_dev, gchar const *drivername);

gchar const *roccat_device_get_syspath(RoccatDevice const *roccat_dev);
void roccat_device_set_syspath(RoccatDevice *roccat_dev, gchar const *syspath);

void roccat_device_set_none_evdev(RoccatDevice *roccat_dev, gchar const *none_evdev);

/*!
 * \brief opens event device of interface type none
 * \retval If successful returns file descriptor that has to be closed with
 *         \c close(), -1 on error
 */
int roccat_device_open_none_evdev(RoccatDevice const *roccat_dev, GError **error);

void roccat_device_set_mouse_evdev(RoccatDevice *roccat_dev, gchar const *mouse_evdev);

/*!
 * \brief opens mouse event device
 * \retval If successful returns file descriptor that has to be closed with
 *         \c close(), -1 on error
 */
int roccat_device_open_mouse_evdev(RoccatDevice const *roccat_dev, GError **error);

void roccat_device_set_keyboard_evdev(RoccatDevice *roccat_dev, gchar const *keyboard_evdev);

/*!
 * \brief opens keyboard event device
 * \retval If successful returns file descriptor that has to be closed with
 *         \c close(), -1 on error
 */
int roccat_device_open_keyboard_evdev(RoccatDevice const *roccat_dev, GError **error);

gchar const *roccat_device_get_roccat_dev(RoccatDevice const *roccat_dev);
void roccat_device_set_roccat_dev(RoccatDevice *roccat_dev, gchar const *device);

/*!
 * \brief opens roccat device for reading
 * \retval If successful returns file descriptor that has to be closed with
 *         \c close(), -1 on error
 */
int roccat_device_open_roccat_dev(RoccatDevice const *roccat_dev, GError **error);

gchar const *roccat_device_get_hidraw_dev(RoccatDevice const *roccat_dev);
void roccat_device_set_hidraw_dev(RoccatDevice *roccat_dev, gchar const *device);

/*!
 * \brief opens hidraw device for reading
 * \retval If successful returns file descriptor that has to be closed with
 *         \c close(), -1 on error
 */
int roccat_device_open_hidraw_dev(RoccatDevice const *roccat_dev, GError **error);

/*!
 * \brief opens uinput device supporting mouse buttons and multimedia keys
 * \retval If successful returns file descriptor that has to be closed with
 *         \c roccat_device_close_misc_evdev(), -1 on error
 * It takes some time until device is created.
 */
int roccat_device_open_misc_evdev(RoccatDevice const *roccat_dev, GError **error);

void roccat_device_close_misc_evdev(int fd);

void roccat_device_lock(RoccatDevice *roccat_dev);
void roccat_device_unlock(RoccatDevice *roccat_dev);

void roccat_device_debug(RoccatDevice const *roccat_dev);

gchar const *roccat_device_get_name_static(RoccatDevice const *roccat_dev);

G_END_DECLS

#endif
