#ifndef _ROCCAT_VALO_ORIG_MACRO_H_
#define _ROCCAT_VALO_ORIG_MACRO_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.h>

G_BEGIN_DECLS

#define VALO_ORIGINAL_MACRO_MAIN_GROUP_NAME "SetMacro"
#define VALO_ORIGINAL_MACRO_COUNT_NAME "number"

typedef struct _ValoOriginalMacroKeystroke ValoOriginalMacroKeystroke;
typedef struct _ValoOriginalMacro ValoOriginalMacro;

struct _ValoOriginalMacroKeystroke {
	guint8 key;
	guint8 action;
	guint16 period;
} __attribute__ ((packed));

typedef enum {
	VALO_ORIGINAL_MACRO_KEYSTROKE_ACTION_PRESS = 1,
	VALO_ORIGINAL_MACRO_KEYSTROKE_ACTION_RELEASE = 2,
} ValoOriginalMacroKeystrokeAction;

enum {
	VALO_ORIGINAL_MACRO_KEYSTROKES_NUM = 500,
	VALO_ORIGINAL_MACRO_NAME_LENGTH = 52,
};

/*!
 * \brief Valo macro as stored in sequence.dat
 */
struct _ValoOriginalMacro {
	guint8 macro_name[VALO_ORIGINAL_MACRO_NAME_LENGTH];
	guint32 count;
	ValoOriginalMacroKeystroke keystrokes[VALO_ORIGINAL_MACRO_KEYSTROKES_NUM];
	guint8 checksum;
} __attribute__ ((packed));

static inline guint16 valo_original_macro_keystroke_get_period(ValoOriginalMacroKeystroke const *keystroke) {
	return GUINT16_FROM_LE(keystroke->period);
}

static inline void valo_original_macro_keystroke_set_period(ValoOriginalMacroKeystroke *keystroke, guint16 new_value) {
	keystroke->period = GUINT16_TO_LE(new_value);
}

static inline guint32 valo_original_macro_get_count(ValoOriginalMacro const *macro) {
	return GUINT32_FROM_LE(macro->count);
}

static inline void valo_original_macro_set_count(ValoOriginalMacro *macro, guint32 new_value) {
	macro->count = GUINT32_TO_LE(new_value);
}

G_END_DECLS

#endif
