/****************************************************************************** * File - InputManager.h * Author - Joey Pollack * Date - 2019/11/14 (y/m/d) * Mod Date - 2021/09/08 (y/m/d) * Description - Handles all input for windows systems * ******************************************************************************/ #ifndef INPUT_MANAGER_H_ #define INPUT_MANAGER_H_ #include #include #include #include "keyboard.h" namespace lunarium { class Window; class InputManager { public: struct KeyPress { Keyboard::Key Key; // Modifiers bool ShiftHeld; bool ControlHeld; bool AltHeld; }; struct MouseButton { KeyCode code; std::string Name; }; private: friend class Core; struct _KeyEvents { std::vector KeysPressed; std::vector KeysReleased; } mKeyEvents; const int KEY_UP = 0; const int KEY_DOWN = 0xFF; private: // ENGINE ONLY METHODS InputManager(); void Initialize(Window* pWindow); // Returns an array of keys that were pressed // Keys are only pressed if they were not held on the previous frame const _KeyEvents& PollKeys(); bool IsMouseButton(int keyCode); // TODO: Remove these functions // KeyCode TranslateKey(int k); // char GetAsciiFromKeyPress(KeyCode k, bool shiftHeld); public: bool IsKeyDown(KeyCode key); // Returns the mouse position in screen coordinates glm::vec2 GetMousePosition(); void SetMousePosition(glm::vec2 p); private: Window* mpWindow; unsigned char mKeyboardState[NUM_KEYS]; //unsigned char mKeyboardPreviousState[NUM_KEYS]; std::vector mModifiers; }; } #endif // WIN_INPUT_MANAGER_H_