#ifndef JTK_EVENT_H
#define JTK_EVENT_H

#include <stdint.h>
#include <stdlib.h>

#define JTK_EVENT_WINDOW_CLOSE      1u
#define JTK_EVENT_WINDOW_EXPOSE     2u
#define JTK_EVENT_KEY_PRESS         3u
#define JTK_EVENT_KEY_RELEASE       4u
#define JTK_EVENT_BUTTON_PRESS      5u
#define JTK_EVENT_BUTTON_RELEASE    6u
#define JTK_EVENT_TIMER             7u
#define JTK_EVENT_WINDOW_RESIZE     8u

typedef struct
{
    bool repeat;
    uint32_t key;
#ifdef JTK_X
    unsigned int x_keycode;
#endif
} Jtk_KeyEvent;

typedef struct
{
    uint32_t mods;
    uint8_t button;
} Jtk_ButtonEvent;

typedef struct
{
    size_t timer_id;
    void * user1;
    void * user2;
} Jtk_TimerEvent;

typedef struct
{
    size_t width;
    size_t height;
} Jtk_WindowResizeEvent;

typedef struct
{
    uint8_t type;
    union
    {
        Jtk_KeyEvent key;
        Jtk_ButtonEvent button;
        Jtk_TimerEvent timer;
        Jtk_WindowResizeEvent resize;
    };
} Jtk_Event;

bool Jtk_CheckEvent(Jtk_Event * event);
void Jtk_WaitEvent(Jtk_Event * event);
#if 0
void Jtk_BeginKeyRepeat(Jtk_KeyEvent * key_event, uint32_t delay, uint32_t interval);
#endif

#endif
