#ifndef KEY_EVENT_HPP
#define KEY_EVENT_HPP

#include "open_engine/events/event.hpp"
#include "open_engine/input/keycodes.hpp"

namespace OpenEngine {
    class KeyEvent
        : public Event
    {
        public:
            inline KeyCode GetKeyCode() const { return keycode; }
            inline int GetScanCode() const { return scancode; }
            inline int GetMods() const { return mods; }

            EVENT_CLASS_CATEGORY(EventCategoryInput | EventCategoryKeyboard)

        protected:
            KeyEvent(KeyCode keycode, int scancode, int mods)
                : keycode(keycode), scancode(scancode), mods(mods)
            {
            };

            KeyCode keycode;
            int scancode;
            int mods;
    };

    class KeyPressedEvent
        : public KeyEvent
    {
        public:
            KeyPressedEvent(KeyCode keycode, int scancode, int repeat_count, int mods)
                : KeyEvent(keycode, scancode, mods), repeat_count(repeat_count)
            {
            };

            inline int GetRepeatCount() { return repeat_count; };

            std::string ToString() const override;

            EVENT_CLASS_TYPE(KeyPressed)

        private:
            int repeat_count;
    };

    class KeyReleasedEvent
        : public KeyEvent
    {
        public:
            KeyReleasedEvent(KeyCode keycode, int scancode, int mods)
                : KeyEvent(keycode, scancode, mods)
            {
            };
            
            std::string ToString() const override;

            EVENT_CLASS_TYPE(KeyReleased)
    };

    class KeyTypedEvent
        : public KeyEvent
    {
        public:
            KeyTypedEvent(KeyCode keycode)
                : KeyEvent(keycode, 0, 0)
            {
            };

            std::string ToString() const override;

            EVENT_CLASS_TYPE(KeyTyped)
    };
}

#endif // KEY_EVENT_HPP
