/*
PolyGun

Copyright (c) 2023 mrkubax10 <mrkubax10@onet.pl>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#ifndef POLYGUN_WINDOW_EVENT_HPP
#define POLYGUN_WINDOW_EVENT_HPP

#include "game/window/mouse.hpp"
#include "game/window/keyboard.hpp"

namespace polygun::window {
	enum EventType {
		EVENT_TYPE_NO_EVENT,
		EVENT_TYPE_KEY_DOWN,
		EVENT_TYPE_KEY_UP,
		EVENT_TYPE_TEXT_ENTER,
		EVENT_TYPE_MOUSE_BUTTON_UP,
		EVENT_TYPE_MOUSE_BUTTON_DOWN,
		EVENT_TYPE_MOUSE_MOVE,
		EVENT_TYPE_MOUSE_WHEEL,
		EVENT_TYPE_WINDOW_RESIZE,
		EVENT_TYPE_WINDOW_CLOSE
	};

	struct Event {
		union {
			struct {
				KeyCode m_key;
				// big endian
				char m_character_bytes[4];
				unsigned m_character_byte_count;
			} m_key_event;
			struct {
				MouseButton m_button;
				int m_wheel_offset;
				int m_x;
				int m_y;
			} m_mouse_event;
			struct {
				unsigned m_width;
				unsigned m_height;
			} m_window_event;
		} m_data;
		EventType m_type;
	};
}

#endif // POLYGUN_WINDOW_EVENT_HPP
