You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lunarium_OLD/src/input/inputManager.h

88 lines
1.7 KiB
C

/******************************************************************************
* 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 <vector>
#include <string>
#include <glm/glm.hpp>
#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<KeyPress> KeysPressed;
std::vector<Keyboard::Key> 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<KeyCode> mModifiers;
};
}
#endif // WIN_INPUT_MANAGER_H_