#pragma once #ifndef INPUT_PTR #define INPUT_PTR void* #endif #include #include #include enum InputModifierBit { eNONE = 0x00, eSHIFT = 0x01, eCNTRL = 0x02, }; constexpr InputModifierBit operator & (const InputModifierBit a, const InputModifierBit b) { return static_cast(static_cast(a) & static_cast(b)); } constexpr InputModifierBit operator | (const InputModifierBit a, const InputModifierBit b) { return static_cast(static_cast(a) & static_cast(b)); } constexpr InputModifierBit& operator |=(InputModifierBit& a, const InputModifierBit b) { a = static_cast(static_cast(a) | static_cast(b)); return a; } constexpr u32 operator ~ (InputModifierBit a) { return ~static_cast(a); } struct InputEvent { enum Tag { eEXIT, eRESIZE, eCURSOR, eKEY, eBUTTON, } tag; union { struct { int width, height; } resize; struct { double x, y; } pos; struct { int key; int state; InputModifierBit mods; } key; }; }; struct Renderer; struct Input { Input(INPUT_PTR in); INPUT_PTR in; glm::vec2 last_mouse = glm::vec2(0.0f, 0.0f); void poll(); std::queue queue; void handleMovementKeys(Renderer& ren); void handleCursorMovement(Renderer& ren, double x, double y); void setCursor(bool enabled); bool shouldClose(); };