#ifndef KEYBOARD_H
#define KEYBOARD_H

#include <keyboard/key.h>
#include <keyboard/combo.h>
#include <keyboard/port.h>
#include <stdbool.h>
#include <stddef.h>

#ifdef __cplusplus
extern "C"
{
#endif

#define KEYBOARD_COMBO(...) (const struct keyboard_combo){.keys = {__VA_ARGS__}}

struct keyboard
{
    struct keyboard_input
    {
        struct keyboard_combo
        {
            enum keyboard_key keys[KEYBOARD_MAX_COMBO_KEYS];
        } combo;

        struct keyboard_chars
        {
            char c[KEYBOARD_MAX_COMBO_KEYS];
        } chars;
    } input, oldinput;

    size_t i;
    struct keyboard_port port;
};

void keyboard_init(struct keyboard *k);
void keyboard_update(struct keyboard *k);
bool keyboard_available(void);
bool keyboard_justpressed(const struct keyboard *k, const struct keyboard_combo *c);
bool keyboard_pressed(const struct keyboard *k, const struct keyboard_combo *c);
bool keyboard_justreleased(const struct keyboard *k, const struct keyboard_combo *c);
bool keyboard_any_justpressed(const struct keyboard *k, struct keyboard_input *in);
bool keyboard_any_pressed(const struct keyboard *k, struct keyboard_input *in);
const char *keyboard_key_str(enum keyboard_key k);

#ifdef __cplusplus
}
#endif

#endif /* KEYBOARD_H */
