#ifndef _ROCCAT_ARVO_ORIG_MACRO_H_
#define _ROCCAT_ARVO_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 ARVO_ORIGINAL_MACRO_MAIN_GROUP_NAME "Main"
#define ARVO_ORIGINAL_MACRO_COUNT_NAME "Count"

typedef struct _ArvoOriginalMacroKeystroke ArvoOriginalMacroKeystroke;
typedef struct _ArvoOriginalMacro ArvoOriginalMacro;

enum {
	ARVO_ORIGINAL_MACRO_KEYSTROKES_NUM = 512,
	ARVO_ORIGINAL_MACRO_NAME_LENGTH = 52,
};

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

typedef enum {
	ARVO_ORIGINAL_MACRO_KEYSTROKE_ACTION_PRESS = 0,
	ARVO_ORIGINAL_MACRO_KEYSTROKE_ACTION_RELEASE = 1,
} ArvoOriginalMacroKeystrokeAction;

struct _ArvoOriginalMacro {
	guint8 macro_name[ARVO_ORIGINAL_MACRO_NAME_LENGTH];
	guint32 unused;
	guint32 count;
	ArvoOriginalMacroKeystroke keystrokes[ARVO_ORIGINAL_MACRO_KEYSTROKES_NUM];
	guint8 checksum;
} __attribute__ ((packed));

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

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

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

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

G_END_DECLS

#endif
