From 13f67a7cdbdd4c3f7e4fa90b6698e35946937f2b Mon Sep 17 00:00:00 2001 From: Nigel Barink Date: Wed, 4 Jan 2023 19:01:58 +0100 Subject: [PATCH] Basic input handling, Editor camera Movement --- Editor/src/AssetManagement/AssetManager.cpp | 4 +- Editor/src/UI/EditorWindow.h | 3 - Editor/src/UI/GUIRenderer.h | 1 - Editor/src/UI/widgets.h | 15 +- Editor/src/app.cpp | 77 +++++++- YoggieEngine/src/Application.cpp | 3 + YoggieEngine/src/EntryPoint.h | 5 +- .../src/Graphics/Primitives/Camera.cpp | 26 ++- YoggieEngine/src/Graphics/Primitives/Camera.h | 8 +- YoggieEngine/src/Input/InputManager.cpp | 151 +++++++--------- YoggieEngine/src/Input/InputManager.h | 26 +-- YoggieEngine/src/Input/Keyboard.h | 170 ++++++++++++++++++ YoggieEngine/src/PerfCounter.cpp | 22 +-- YoggieEngine/src/PerfCounter.h | 20 +-- YoggieEngine/src/YoggieEngine.h | 3 + 15 files changed, 382 insertions(+), 152 deletions(-) create mode 100644 YoggieEngine/src/Input/Keyboard.h diff --git a/Editor/src/AssetManagement/AssetManager.cpp b/Editor/src/AssetManagement/AssetManager.cpp index 3aa6879..dd96a0e 100644 --- a/Editor/src/AssetManagement/AssetManager.cpp +++ b/Editor/src/AssetManagement/AssetManager.cpp @@ -7,7 +7,6 @@ std::vector AssetManager::assets; std::filesystem::path AssetManager::currentPath; - void AssetManager::Init() { assets = std::vector(); @@ -38,7 +37,6 @@ void AssetManager::setAssetPath(std::filesystem::path path) currentPath = path; } - YoggieEngine::Mesh* AssetManager::LoadFromAssetFile(const std::filesystem::path assetPath) { YoggieEngine::Mesh* imported = nullptr; @@ -147,4 +145,4 @@ YoggieEngine::Renderable* AssetManager::LoadFromSource(const std::filesystem::pa return model->renderable; -} \ No newline at end of file +} diff --git a/Editor/src/UI/EditorWindow.h b/Editor/src/UI/EditorWindow.h index 283619c..4745f61 100644 --- a/Editor/src/UI/EditorWindow.h +++ b/Editor/src/UI/EditorWindow.h @@ -6,9 +6,6 @@ class EditorWindow { public: EditorWindow(const std::string& name, ImGuiWindowFlags_ flags = ImGuiWindowFlags_None ) { ImGui::Begin(name.c_str(), false ,flags); } - - - ~EditorWindow() { ImGui::End(); } }; \ No newline at end of file diff --git a/Editor/src/UI/GUIRenderer.h b/Editor/src/UI/GUIRenderer.h index 4788e3a..749af2e 100644 --- a/Editor/src/UI/GUIRenderer.h +++ b/Editor/src/UI/GUIRenderer.h @@ -16,7 +16,6 @@ public: io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_DockingEnable; io.Fonts->AddFontFromFileTTF("build/Debug/Fonts/Roboto-Regular.ttf", 18); - ImGui::StyleColorsDark(); ImGui_ImplGlfw_InitForOpenGL(window.GetGLFWHandle(), true); diff --git a/Editor/src/UI/widgets.h b/Editor/src/UI/widgets.h index 9e6ddfe..1547e77 100644 --- a/Editor/src/UI/widgets.h +++ b/Editor/src/UI/widgets.h @@ -151,14 +151,25 @@ public: glm::mat4 transposed_view = glm::transpose(cam.ViewMatrix); - ImGuizmo::ViewManipulate(glm::value_ptr(transposed_view), 1, { ScreenSpaceMin.x,ScreenSpaceMin.y }, { 90,90 }, 0x22CCCCCC); ImGuizmo::DrawGrid(glm::value_ptr(cam.ViewMatrix), glm::value_ptr(cam.ProjectionMatrix), glm::value_ptr(worldOrigin), 100.0f); - + ImGuizmo::ViewManipulate(glm::value_ptr(transposed_view), 1, { ScreenSpaceMin.x,ScreenSpaceMin.y }, { 90,90 }, 0x22CCCCCC); + // Matrix is the model matrix we would want to manipulate //ImGuizmo::Manipulate(glm::value_ptr(cam.ViewMatrix), glm::value_ptr(cam.ProjectionMatrix), ImGuizmo::TRANSLATE, ImGuizmo::WORLD, glm::value_ptr(cam.ViewMatrix)); + if (ImGui::IsWindowFocused() ) + { + isFocused = true; + + } + else { + isFocused = false; + } + } + bool isFocused = false; + }; diff --git a/Editor/src/app.cpp b/Editor/src/app.cpp index 9259ca6..73a66f9 100644 --- a/Editor/src/app.cpp +++ b/Editor/src/app.cpp @@ -22,9 +22,10 @@ RendererConfig EditorSceneRendererConfig{ glm::vec3{0,0,0}, // Clear Color true // Depth testing }; - glm::vec3 temp = glm::vec3(0); Camera cam = Camera(glm::vec3(14.0f, 1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), 90); + + class Editor : public Application { public: Editor() @@ -35,6 +36,8 @@ public: EditorGUIRenderer(AppWindow), Selected((entt::entity)-1) { + + init_inputSystem(&AppWindow); viewportRenderer.setCurrentFrameBuffer(*framebuffer); } @@ -71,6 +74,74 @@ public: { Viewport sceneview = Viewport(*framebuffer, viewportRenderer.getCamera()); + if (sceneview.isFocused) + { + const float movement_speed = 0.1f; + static float lastX = 400, lastY = 300; + const float sensitivity = 0.1; + static bool firstMouse = true; + + + if (MouseButtonPressed(YOGGIE_MOUSE_BUTTON_MIDDLE) ){ + + + auto newX = getCursorPosX(&AppWindow); + auto newY = getCursorPosY(&AppWindow); + + + if (firstMouse) + { + lastX = newX; + lastY = newY; + firstMouse = false; + } + + + float xoffset = newX - lastX; + float yoffset = newY - lastY; + + lastX = newX; + lastY = newY; + + xoffset *= sensitivity; + yoffset *= sensitivity; + + cam.yaw += xoffset; + cam.pitch += yoffset; + + if (cam.pitch > 89.0f) + cam.pitch = 89.0f; + if (cam.pitch < -89.0f) + cam.pitch = -89.0f; + + } + + + // Check for Camara movement input here! + if (keyIsPressed(YOGGIE_KEY_W)) { + cam.Position += cam.Front * movement_speed; + } + + if (keyIsPressed(YOGGIE_KEY_A)) + { + cam.Position -= cam.Right * movement_speed; + + } + + if (keyIsPressed(YOGGIE_KEY_S)) { + cam.Position -= cam.Front * movement_speed; + + } + + if (keyIsPressed(YOGGIE_KEY_D)) { + cam.Position += cam.Right * movement_speed; + + } + + + + } + } { @@ -136,7 +207,7 @@ public: lag += elapsed; AppWindow.Poll(); - + cam.Update(); Physics.Step(elapsed); ActiveScene.Update(); @@ -170,6 +241,8 @@ private: bool SimulatePhysics = true; entt::entity Selected; + + std::unique_ptr CurrentProject; Scene ActiveScene; diff --git a/YoggieEngine/src/Application.cpp b/YoggieEngine/src/Application.cpp index dbd4274..8baf113 100644 --- a/YoggieEngine/src/Application.cpp +++ b/YoggieEngine/src/Application.cpp @@ -6,8 +6,11 @@ namespace YoggieEngine { Application::Application(const std::string& name) : m_AppName(name) { + // Initialize engine should possibly happen here EngineInstrumentation::PerfomanceSamplerInit(); + + } diff --git a/YoggieEngine/src/EntryPoint.h b/YoggieEngine/src/EntryPoint.h index 59188a0..de5d323 100644 --- a/YoggieEngine/src/EntryPoint.h +++ b/YoggieEngine/src/EntryPoint.h @@ -15,8 +15,7 @@ namespace YoggieEngine } } -int main(int argc, char** argv) { - +int main(int argc, char** argv) +{ return YoggieEngine::entryPoint(); - } \ No newline at end of file diff --git a/YoggieEngine/src/Graphics/Primitives/Camera.cpp b/YoggieEngine/src/Graphics/Primitives/Camera.cpp index a599cba..698578d 100644 --- a/YoggieEngine/src/Graphics/Primitives/Camera.cpp +++ b/YoggieEngine/src/Graphics/Primitives/Camera.cpp @@ -9,16 +9,25 @@ namespace YoggieEngine { Camera::Camera(glm::vec3 position, glm::vec3 rotation, float zoom) : Position(position), Rotation( rotation) { - glm::vec3 WorldUp = glm::vec3(0.0f, 1.0f, 0.0f); Front = glm::vec3(0.0f, 0.0f, 1.0f); Right = glm::vec3(-1.0f, 0.0f, 0.0f); Up = glm::vec3(0.0f, 1.0f, 0.0f); Zoom = zoom; + ProjectionMatrix = glm::perspective(glm::radians(Zoom), (800.0f / 600.0f), 0.001f, 100.0f); + Update(); + + } + Camera::~Camera() { + + } + + void Camera::Update() { + glm::vec3 WorldUp = glm::vec3(0.0f, 1.0f, 0.0f); + glm::vec3(direction); - float yaw = 180; - float pitch = 0; + direction.x = cos(glm::radians(yaw)) * cos(glm::radians(pitch)); direction.z = sin(glm::radians(yaw)); @@ -32,17 +41,6 @@ namespace YoggieEngine { Position, Position + Front, Up); - - ProjectionMatrix = glm::perspective(glm::radians(Zoom), (800.0f / 600.0f), 0.001f, 100.0f); - - } - - Camera::~Camera() { - - } - - void Camera::Update() { - ViewMatrix = glm::lookAt(Position,Position + Front,Up); } } diff --git a/YoggieEngine/src/Graphics/Primitives/Camera.h b/YoggieEngine/src/Graphics/Primitives/Camera.h index a1018ea..db6392a 100644 --- a/YoggieEngine/src/Graphics/Primitives/Camera.h +++ b/YoggieEngine/src/Graphics/Primitives/Camera.h @@ -9,15 +9,17 @@ namespace YoggieEngine { void Update(); - glm::vec3 Position; - glm::vec3 Rotation; + + float yaw = 180; + float pitch = 0; float Zoom; glm::mat4 ViewMatrix; glm::mat4 ProjectionMatrix; + glm::vec3 Position; + glm::vec3 Rotation; - private: glm::vec3 Front; glm::vec3 Right; glm::vec3 Up; diff --git a/YoggieEngine/src/Input/InputManager.cpp b/YoggieEngine/src/Input/InputManager.cpp index 58964db..766b776 100644 --- a/YoggieEngine/src/Input/InputManager.cpp +++ b/YoggieEngine/src/Input/InputManager.cpp @@ -1,115 +1,98 @@ #include #include "InputManager.h" -namespace YoggieEngine { - InputManager InputSystem; - void InputManager::PollEvents() - { - for (auto it = windows.begin(); it != windows.end(); ++it) { - auto window = *it; - window->Poll(); +namespace YoggieEngine { + double cursor_pos_x; + double cursor_pos_y; + int key_status[YOGGIE_KEY_LAST]; + int mouseButton_status[7]; - } + + void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods); + void cursorPos_callback(GLFWwindow* window, double xpos, double ypos); + void cursorEnter_callback(GLFWwindow* window, int entered); + void mouseButton_callback(GLFWwindow* window, int button, int action, int mods); + + + void init_inputSystem(NativeWindow* window) { + cursor_pos_x = 0; + cursor_pos_y = 0; + glfwSetKeyCallback(window->GetGLFWHandle(), key_callback); + glfwSetMouseButtonCallback(window->GetGLFWHandle(), mouseButton_callback); + glfwSetCursorPosCallback(window->GetGLFWHandle(), cursorPos_callback); + glfwSetCursorEnterCallback(window->GetGLFWHandle(), cursorEnter_callback); } - void InputManager::KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods) + void ReceiveInput() { + glfwPollEvents(); + + } + + + bool keyIsPressed(int key) { + return (key_status[key] == GLFW_PRESS) || (key_status[key] == GLFW_REPEAT); + } - Event KeyEvent{}; - KeyEvent.name = "KEY"; - - InputSystem.EmitEvent(KeyEvent); + bool MouseButtonPressed(int key) + { + return (mouseButton_status[key] == GLFW_PRESS ) || (mouseButton_status[key] == GLFW_REPEAT); + + } - if (key == GLFW_KEY_A && action == GLFW_PRESS) - { + double getCursorPosX(NativeWindow* window) + { + glfwGetCursorPos(window->GetGLFWHandle(), &cursor_pos_x, nullptr); + return cursor_pos_x; + } + + double getCursorPosY(NativeWindow* window) + { + glfwGetCursorPos(window->GetGLFWHandle(), nullptr, &cursor_pos_y); + return cursor_pos_y; + } + + void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) + { + key_status[key] = action; + } + + void mouseButton_callback(GLFWwindow* window, int button, int action, int mods) + { + + auto& io = ImGui::GetIO(); + io.AddMouseButtonEvent(button , action == GLFW_PRESS); - std::cout << "'a' key was pressed" << std::endl; - } - + + mouseButton_status[button] = action; } - void InputManager::CursorPositionCallback(GLFWwindow* window, double x, double y) + + + void cursorPos_callback(GLFWwindow* window, double xpos, double ypos) { - //std::cout << "Cursor Position x: " << x << ", y: " << y << std::endl; - Event CursorPosUpdate{}; - CursorPosUpdate.name = "UPDATE::CURSOR:POSITION"; - - InputSystem.EmitEvent(CursorPosUpdate); - - - + //std::cout << "Cursor moved!" << std::endl; } - void InputManager::CursorEnterCallback(GLFWwindow* window, int entered) + void cursorEnter_callback(GLFWwindow* window, int entered) { if (entered) { - Event mouseEntered {}; - mouseEntered.name = "Mouse Entered Window's confines!"; - mouseEntered.argc = 0; - - InputSystem.EmitEvent(mouseEntered); - - - + // window is in focus + //std::cout << "Cursor Entered!" << std::endl; } else { - Event mouseLeft{}; - mouseLeft.name = "Mouse Left Window's confines!"; - mouseLeft.argc = 0; - - InputSystem.EmitEvent(mouseLeft); - - + // window is not in focus + //std::cout << "Cursor Left!" << std::endl; } } - void InputManager::MouseButtonCallback(GLFWwindow* window, int button, int action, int mods) - { - - Event MouseButtonEvent{}; - MouseButtonEvent.name = "MOUSEBUTTON"; - - InputSystem.EmitEvent(MouseButtonEvent); - if (button == GLFW_MOUSE_BUTTON_RIGHT && action == GLFW_PRESS) { - std::cout << "Right mouse button was pressed!" << std::endl; - } - - } - - void InputManager::ScrollCallback(GLFWwindow* window, double xoffset, double yoffset) - { - std::cout << "Scroll: x: " << xoffset << ", y: " << yoffset << std::endl; - - Event ScrollEvent{}; - ScrollEvent.name = "SCROLL"; - - InputSystem.EmitEvent(ScrollEvent); - } - void InputManager::attach(BarinkWindow* window) - { - windows.push_back(window); - - // Attach callbacks - glfwSetKeyCallback(window->windowptr(), KeyCallback); - glfwSetCursorPosCallback(window->windowptr(), CursorPositionCallback); - glfwSetCursorEnterCallback(window->windowptr(), CursorEnterCallback); - glfwSetMouseButtonCallback(window->windowptr(), MouseButtonCallback); - glfwSetScrollCallback(window->windowptr(), ScrollCallback); - - this->Subscribe( (EventListener&)(*window)); - - } - - InputManager::InputManager() : EventEmitter () - { - windows = std::vector(); - } } + diff --git a/YoggieEngine/src/Input/InputManager.h b/YoggieEngine/src/Input/InputManager.h index 88930aa..2734df5 100644 --- a/YoggieEngine/src/Input/InputManager.h +++ b/YoggieEngine/src/Input/InputManager.h @@ -1,23 +1,15 @@ #pragma once - namespace YoggieEngine { + // Lets just take the dumb approach for now - class InputManager : EventEmitter { - public: - InputManager(); + void init_inputSystem(NativeWindow* window); + void ReceiveInput(); + + bool keyIsPressed(int key); + bool MouseButtonPressed(int key); - void PollEvents(); - void attach(BarinkWindow* window); + double getCursorPosX(NativeWindow* window); + double getCursorPosY(NativeWindow* window); - // GLFW Handlers - static void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods); - static void CursorPositionCallback(GLFWwindow* window, double x, double y); - static void CursorEnterCallback(GLFWwindow* window, int entered); - static void MouseButtonCallback(GLFWwindow* window, int button, int action, int mods); - static void ScrollCallback(GLFWwindow* window, double xoffset, double yoffset); - private: - std::vector windows; - }; - extern InputManager InputSystem; -} +} \ No newline at end of file diff --git a/YoggieEngine/src/Input/Keyboard.h b/YoggieEngine/src/Input/Keyboard.h new file mode 100644 index 0000000..b4158cc --- /dev/null +++ b/YoggieEngine/src/Input/Keyboard.h @@ -0,0 +1,170 @@ +#pragma once +namespace YoggieEngine{ +/* +* Based on GLFW +*/ + +/* The unknown key */ +#define YOGGIE_KEY_UNKNOWN -1 + +/* Printable keys */ +#define YOGGIE_KEY_SPACE 32 +#define YOGGIE_KEY_APOSTROPHE 39 /* ' */ +#define YOGGIE_KEY_COMMA 44 /* , */ +#define YOGGIE_KEY_MINUS 45 /* - */ +#define YOGGIE_KEY_PERIOD 46 /* . */ +#define YOGGIE_KEY_SLASH 47 /* / */ +#define YOGGIE_KEY_0 48 +#define YOGGIE_KEY_1 49 +#define YOGGIE_KEY_2 50 +#define YOGGIE_KEY_3 51 +#define YOGGIE_KEY_4 52 +#define YOGGIE_KEY_5 53 +#define YOGGIE_KEY_6 54 +#define YOGGIE_KEY_7 55 +#define YOGGIE_KEY_8 56 +#define YOGGIE_KEY_9 57 +#define YOGGIE_KEY_SEMICOLON 59 /* ; */ +#define YOGGIE_KEY_EQUAL 61 /* = */ +#define YOGGIE_KEY_A 65 +#define YOGGIE_KEY_B 66 +#define YOGGIE_KEY_C 67 +#define YOGGIE_KEY_D 68 +#define YOGGIE_KEY_E 69 +#define YOGGIE_KEY_F 70 +#define YOGGIE_KEY_G 71 +#define YOGGIE_KEY_H 72 +#define YOGGIE_KEY_I 73 +#define YOGGIE_KEY_J 74 +#define YOGGIE_KEY_K 75 +#define YOGGIE_KEY_L 76 +#define YOGGIE_KEY_M 77 +#define YOGGIE_KEY_N 78 +#define YOGGIE_KEY_O 79 +#define YOGGIE_KEY_P 80 +#define YOGGIE_KEY_Q 81 +#define YOGGIE_KEY_R 82 +#define YOGGIE_KEY_S 83 +#define YOGGIE_KEY_T 84 +#define YOGGIE_KEY_U 85 +#define YOGGIE_KEY_V 86 +#define YOGGIE_KEY_W 87 +#define YOGGIE_KEY_X 88 +#define YOGGIE_KEY_Y 89 +#define YOGGIE_KEY_Z 90 +#define YOGGIE_KEY_LEFT_BRACKET 91 /* [ */ +#define YOGGIE_KEY_BACKSLASH 92 /* \ */ +#define YOGGIE_KEY_RIGHT_BRACKET 93 /* ] */ +#define YOGGIE_KEY_GRAVE_ACCENT 96 /* ` */ +#define YOGGIE_KEY_WORLD_1 161 /* non-US #1 */ +#define YOGGIE_KEY_WORLD_2 162 /* non-US #2 */ + +/* Function keys */ +#define YOGGIE_KEY_ESCAPE 256 +#define YOGGIE_KEY_ENTER 257 +#define YOGGIE_KEY_TAB 258 +#define YOGGIE_KEY_BACKSPACE 259 +#define YOGGIE_KEY_INSERT 260 +#define YOGGIE_KEY_DELETE 261 +#define YOGGIE_KEY_RIGHT 262 +#define YOGGIE_KEY_LEFT 263 +#define YOGGIE_KEY_DOWN 264 +#define YOGGIE_KEY_UP 265 +#define YOGGIE_KEY_PAGE_UP 266 +#define YOGGIE_KEY_PAGE_DOWN 267 +#define YOGGIE_KEY_HOME 268 +#define YOGGIE_KEY_END 269 +#define YOGGIE_KEY_CAPS_LOCK 280 +#define YOGGIE_KEY_SCROLL_LOCK 281 +#define YOGGIE_KEY_NUM_LOCK 282 +#define YOGGIE_KEY_PRINT_SCREEN 283 +#define YOGGIE_KEY_PAUSE 284 +#define YOGGIE_KEY_F1 290 +#define YOGGIE_KEY_F2 291 +#define YOGGIE_KEY_F3 292 +#define YOGGIE_KEY_F4 293 +#define YOGGIE_KEY_F5 294 +#define YOGGIE_KEY_F6 295 +#define YOGGIE_KEY_F7 296 +#define YOGGIE_KEY_F8 297 +#define YOGGIE_KEY_F9 298 +#define YOGGIE_KEY_F10 299 +#define YOGGIE_KEY_F11 300 +#define YOGGIE_KEY_F12 301 +#define YOGGIE_KEY_F13 302 +#define YOGGIE_KEY_F14 303 +#define YOGGIE_KEY_F15 304 +#define YOGGIE_KEY_F16 305 +#define YOGGIE_KEY_F17 306 +#define YOGGIE_KEY_F18 307 +#define YOGGIE_KEY_F19 308 +#define YOGGIE_KEY_F20 309 +#define YOGGIE_KEY_F21 310 +#define YOGGIE_KEY_F22 311 +#define YOGGIE_KEY_F23 312 +#define YOGGIE_KEY_F24 313 +#define YOGGIE_KEY_F25 314 +#define YOGGIE_KEY_KP_0 320 +#define YOGGIE_KEY_KP_1 321 +#define YOGGIE_KEY_KP_2 322 +#define YOGGIE_KEY_KP_3 323 +#define YOGGIE_KEY_KP_4 324 +#define YOGGIE_KEY_KP_5 325 +#define YOGGIE_KEY_KP_6 326 +#define YOGGIE_KEY_KP_7 327 +#define YOGGIE_KEY_KP_8 328 +#define YOGGIE_KEY_KP_9 329 +#define YOGGIE_KEY_KP_DECIMAL 330 +#define YOGGIE_KEY_KP_DIVIDE 331 +#define YOGGIE_KEY_KP_MULTIPLY 332 +#define YOGGIE_KEY_KP_SUBTRACT 333 +#define YOGGIE_KEY_KP_ADD 334 +#define YOGGIE_KEY_KP_ENTER 335 +#define YOGGIE_KEY_KP_EQUAL 336 +#define YOGGIE_KEY_LEFT_SHIFT 340 +#define YOGGIE_KEY_LEFT_CONTROL 341 +#define YOGGIE_KEY_LEFT_ALT 342 +#define YOGGIE_KEY_LEFT_SUPER 343 +#define YOGGIE_KEY_RIGHT_SHIFT 344 +#define YOGGIE_KEY_RIGHT_CONTROL 345 +#define YOGGIE_KEY_RIGHT_ALT 346 +#define YOGGIE_KEY_RIGHT_SUPER 347 +#define YOGGIE_KEY_MENU 348 + +#define YOGGIE_KEY_LAST YOGGIE_KEY_MENU +/* +* Modifier keys +*/ + // If set one or more Shift keys were held down. +#define YOGGIE_MOD_SHIFT 0x0001 +//If set one or more Control keys were held down. +#define YOGGIE_MOD_CONTROL 0x0002 + +// If set one or more Alt keys were held down. +#define YOGGIE_MOD_ALT 0x0004 + +// SuperKey(s) (if set, One or more superkeys is held down) +#define YOGGIE_MOD_SUPER 0x0008 + +// Capslock (if set, Capslock is enabeld) +#define YOGGIE_MOD_CAPS_LOCK 0x0010 + +// Numlock (if set, numlock is enabled) +#define YOGGIE_MOD_NUM_LOCK 0x0020 + +/* +* Mouse Keys +*/ +#define YOGGIE_MOUSE_BUTTON_1 0 +#define YOGGIE_MOUSE_BUTTON_2 1 +#define YOGGIE_MOUSE_BUTTON_3 2 +#define YOGGIE_MOUSE_BUTTON_4 3 +#define YOGGIE_MOUSE_BUTTON_5 4 +#define YOGGIE_MOUSE_BUTTON_6 5 +#define YOGGIE_MOUSE_BUTTON_7 6 +#define YOGGIE_MOUSE_BUTTON_8 7 +#define YOGGIE_MOUSE_BUTTON_LAST YOGGIE_MOUSE_BUTTON_8 +#define YOGGIE_MOUSE_BUTTON_LEFT YOGGIE_MOUSE_BUTTON_1 +#define YOGGIE_MOUSE_BUTTON_RIGHT YOGGIE_MOUSE_BUTTON_2 +#define YOGGIE_MOUSE_BUTTON_MIDDLE YOGGIE_MOUSE_BUTTON_3 +} \ No newline at end of file diff --git a/YoggieEngine/src/PerfCounter.cpp b/YoggieEngine/src/PerfCounter.cpp index 230b38e..e9e989f 100644 --- a/YoggieEngine/src/PerfCounter.cpp +++ b/YoggieEngine/src/PerfCounter.cpp @@ -8,24 +8,26 @@ namespace YoggieEngine { } void EngineInstrumentation::PerfomanceSamplerInit() { - //ES.frames = 0; - //EngineInstrumentation::lastSampleTime = GetPrecisionTime(); + + std::cout << "Initialize perf sampler" << std::endl; + /*EngineInstrumentation::frames = 0; + EngineInstrumentation::lastSampleTime = GetPrecisionTime();*/ } void EngineInstrumentation::Update() { - /* - uint64_t MilliSecondsPast = GetPrecisionTime() - EngineInstrumentation::lastSampleTime; + + /* uint64_t MilliSecondsPast = GetPrecisionTime() - EngineInstrumentation::lastSampleTime; if (MilliSecondsPast >= 1000) { - ES.frameTime = (float)1000 / ES.frames; - ES.FPS = ES.frames; - ES.frames = 0; - //EngineInstrumentation::lastSampleTime = GetPrecisionTime(); - } - */ + EngineInstrumentation::frameTime = (float)1000 / EngineInstrumentation::frames; + EngineInstrumentation::FPS = frames; + EngineInstrumentation::frames = 0; + EngineInstrumentation::lastSampleTime = GetPrecisionTime(); + }*/ + } diff --git a/YoggieEngine/src/PerfCounter.h b/YoggieEngine/src/PerfCounter.h index 120f0bd..9bfdb13 100644 --- a/YoggieEngine/src/PerfCounter.h +++ b/YoggieEngine/src/PerfCounter.h @@ -1,20 +1,11 @@ #pragma once #include "YoggieEngine.h" namespace YoggieEngine { - struct EngineStatistics { - float frameTime; - uint32_t verts; - uint32_t DC; - - int64_t frames; - int64_t FPS; - - }; class EngineInstrumentation { public: - //static int64_t lastSampleTime; + static int64_t lastSampleTime; static uint64_t GetPrecisionTime(); static void PerfomanceSamplerInit(); @@ -22,6 +13,15 @@ namespace YoggieEngine { static void Update(); static void ShowStats(); + private: + + static float frameTime; + static uint32_t verts; + static uint32_t DC; + + static int64_t frames; + static int64_t FPS; + }; class PerfSampler { diff --git a/YoggieEngine/src/YoggieEngine.h b/YoggieEngine/src/YoggieEngine.h index 2dbe613..7d78f5c 100644 --- a/YoggieEngine/src/YoggieEngine.h +++ b/YoggieEngine/src/YoggieEngine.h @@ -46,6 +46,9 @@ extern "C" #include "EventSystem/EventEmitter.h" #include "EventSystem/EventListener.h" +#include "Input/Keyboard.h" +#include "Input/InputManager.h" + #include "Scene/Entity.h" #include "Scene/Scene.h" #include "Scene/Components.h"