diff --git a/inferno/src/inferno/application.cpp b/inferno/src/inferno/application.cpp index 86a4070..1b6f38a 100644 --- a/inferno/src/inferno/application.cpp +++ b/inferno/src/inferno/application.cpp @@ -5,7 +5,7 @@ #include "inferno/event/event.h" #include "inferno/event/keyevent.h" #include "inferno/event/mouseevent.h" -#include "inferno/inputcodes.h" +#include "inferno/keycodes.h" #include "inferno/io/input.h" #include "inferno/io/log.h" #include "inferno/render/buffer.h" @@ -202,7 +202,7 @@ namespace Inferno { e.getKey()); // Stop the main loop on 'Escape' keypress - if (e.getKey() == KeyCode("GLFW_KEY_ESCAPE")) { + if (e.getKey() == keyCode("GLFW_KEY_ESCAPE")) { m_window->setShouldClose(true); } diff --git a/inferno/src/inferno/inputcodes.cpp b/inferno/src/inferno/keycodes.cpp similarity index 98% rename from inferno/src/inferno/inputcodes.cpp rename to inferno/src/inferno/keycodes.cpp index cd3e229..a46d108 100644 --- a/inferno/src/inferno/inputcodes.cpp +++ b/inferno/src/inferno/keycodes.cpp @@ -4,7 +4,7 @@ #include "GLFW/glfw3.h" #include "inferno/assert.h" -#include "inferno/inputcodes.h" +#include "inferno/keycodes.h" namespace Inferno { @@ -134,7 +134,7 @@ namespace Inferno { // ----------------------------------------- - int KeyCode(const char* name) + int keyCode(const char* name) { ASSERT(keys.find(name) != keys.end(), "keyCode could not find '{}'", name); return keys.at(name); diff --git a/inferno/src/inferno/inputcodes.h b/inferno/src/inferno/keycodes.h similarity index 79% rename from inferno/src/inferno/inputcodes.h rename to inferno/src/inferno/keycodes.h index 2183231..23b70aa 100644 --- a/inferno/src/inferno/inputcodes.h +++ b/inferno/src/inferno/keycodes.h @@ -5,7 +5,7 @@ namespace Inferno { - int KeyCode(const char* name); + int keyCode(const char* name); } diff --git a/inferno/src/inferno/script/cameracontroller.cpp b/inferno/src/inferno/script/cameracontroller.cpp index c6d18b7..8d7b5e6 100644 --- a/inferno/src/inferno/script/cameracontroller.cpp +++ b/inferno/src/inferno/script/cameracontroller.cpp @@ -1,6 +1,6 @@ #include "glm/ext/matrix_transform.hpp" // glm::radians -#include "inferno/inputcodes.h" +#include "inferno/keycodes.h" #include "inferno/io/input.h" #include "inferno/script/cameracontroller.h" @@ -12,10 +12,10 @@ namespace Inferno { float cameraRotateSpeed = ROTATE_SPEED * deltaTime; - if (Input::isKeyPressed(KeyCode("GLFW_KEY_Q"))) { + if (Input::isKeyPressed(keyCode("GLFW_KEY_Q"))) { transform->rotate.z -= cameraRotateSpeed; } - if (Input::isKeyPressed(KeyCode("GLFW_KEY_E"))) { + if (Input::isKeyPressed(keyCode("GLFW_KEY_E"))) { transform->rotate.z += cameraRotateSpeed; } @@ -31,19 +31,19 @@ namespace Inferno { float cameraTranslateSpeed = TRANSLATE_SPEED * deltaTime; // WASD movement - if (Input::isKeyPressed(KeyCode("GLFW_KEY_W"))) { + if (Input::isKeyPressed(keyCode("GLFW_KEY_W"))) { transform->translate.x += -sin(glm::radians(transform->rotate.z)) * cameraTranslateSpeed; transform->translate.y += cos(glm::radians(transform->rotate.z)) * cameraTranslateSpeed; } - if (Input::isKeyPressed(KeyCode("GLFW_KEY_S"))) { + if (Input::isKeyPressed(keyCode("GLFW_KEY_S"))) { transform->translate.x -= -sin(glm::radians(transform->rotate.z)) * cameraTranslateSpeed; transform->translate.y -= cos(glm::radians(transform->rotate.z)) * cameraTranslateSpeed; } - if (Input::isKeyPressed(KeyCode("GLFW_KEY_A"))) { + if (Input::isKeyPressed(keyCode("GLFW_KEY_A"))) { transform->translate.x -= cos(glm::radians(transform->rotate.z)) * cameraTranslateSpeed; transform->translate.y -= sin(glm::radians(transform->rotate.z)) * cameraTranslateSpeed; } - if (Input::isKeyPressed(KeyCode("GLFW_KEY_D"))) { + if (Input::isKeyPressed(keyCode("GLFW_KEY_D"))) { transform->translate.x += cos(glm::radians(transform->rotate.z)) * cameraTranslateSpeed; transform->translate.y += sin(glm::radians(transform->rotate.z)) * cameraTranslateSpeed; } @@ -52,10 +52,10 @@ namespace Inferno { float zoomSpeed = ZOOM_SENSITIVITY * deltaTime; - if (Input::isKeyPressed(KeyCode("GLFW_KEY_EQUAL"))) { + if (Input::isKeyPressed(keyCode("GLFW_KEY_EQUAL"))) { m_camera->zoomLevel -= zoomSpeed; } - if (Input::isKeyPressed(KeyCode("GLFW_KEY_MINUS"))) { + if (Input::isKeyPressed(keyCode("GLFW_KEY_MINUS"))) { m_camera->zoomLevel += zoomSpeed; } m_camera->zoomLevel = std::max(m_camera->zoomLevel, 0.25f); @@ -97,23 +97,23 @@ namespace Inferno { float cameraSpeed = TRANSLATE_SPEED * deltaTime; // WASD movement - if (Input::isKeyPressed(KeyCode("GLFW_KEY_W"))) { + if (Input::isKeyPressed(keyCode("GLFW_KEY_W"))) { transform->translate += transform->rotate * cameraSpeed; } - if (Input::isKeyPressed(KeyCode("GLFW_KEY_S"))) { + if (Input::isKeyPressed(keyCode("GLFW_KEY_S"))) { transform->translate -= transform->rotate * cameraSpeed; } - if (Input::isKeyPressed(KeyCode("GLFW_KEY_A"))) { + if (Input::isKeyPressed(keyCode("GLFW_KEY_A"))) { transform->translate -= glm::normalize(glm::cross(transform->rotate, m_camera->up)) * cameraSpeed; } - if (Input::isKeyPressed(KeyCode("GLFW_KEY_D"))) { + if (Input::isKeyPressed(keyCode("GLFW_KEY_D"))) { transform->translate += glm::normalize(glm::cross(transform->rotate, m_camera->up)) * cameraSpeed; } // Up / down movement - if (Input::isKeyPressed(KeyCode("GLFW_KEY_SPACE"))) { + if (Input::isKeyPressed(keyCode("GLFW_KEY_SPACE"))) { transform->translate.y += cameraSpeed; } - if (Input::isKeyPressed(KeyCode("GLFW_KEY_LEFT_SHIFT"))) { + if (Input::isKeyPressed(keyCode("GLFW_KEY_LEFT_SHIFT"))) { transform->translate.y -= cameraSpeed; } } diff --git a/inferno/src/inferno/script/registration.cpp b/inferno/src/inferno/script/registration.cpp index 9d53f15..f3a5e9d 100644 --- a/inferno/src/inferno/script/registration.cpp +++ b/inferno/src/inferno/script/registration.cpp @@ -3,7 +3,7 @@ #include "glm/ext/vector_float4.hpp" // glm::vec4 #include "glm/ext/matrix_transform.hpp" // glm::radians -#include "inferno/inputcodes.h" +#include "inferno/keycodes.h" #include "inferno/io/input.h" #include "inferno/scene/components.h" #include "inferno/script/registration.h" @@ -106,7 +106,7 @@ namespace Inferno { void Registration::input(sol::state_view& state) { - state.set_function("keyCode", &KeyCode); + state.set_function("keyCode", &keyCode); // state["keyCode"] = &KeyCode; auto input = state.new_usertype("Input", sol::no_constructor); diff --git a/inferno/src/inferno/systems/camera.cpp b/inferno/src/inferno/systems/camera.cpp index 1ccbe7d..cea0622 100644 --- a/inferno/src/inferno/systems/camera.cpp +++ b/inferno/src/inferno/systems/camera.cpp @@ -3,7 +3,6 @@ #include "inferno/application.h" #include "inferno/assert.h" -#include "inferno/inputcodes.h" #include "inferno/io/input.h" #include "inferno/io/log.h" #include "inferno/systems/camera.h" diff --git a/inferno/src/inferno/window.cpp b/inferno/src/inferno/window.cpp index ef80cf0..e98fd3f 100644 --- a/inferno/src/inferno/window.cpp +++ b/inferno/src/inferno/window.cpp @@ -5,7 +5,7 @@ #include "inferno/event/applicationevent.h" #include "inferno/event/keyevent.h" #include "inferno/event/mouseevent.h" -#include "inferno/inputcodes.h" +#include "inferno/keycodes.h" #include "inferno/io/input.h" #include "inferno/io/log.h" #include "inferno/render/context.h" @@ -165,7 +165,7 @@ namespace Inferno { glfwPollEvents(); // Lock mouse in window - if (Input::isKeyPressed(KeyCode("GLFW_KEY_LEFT_SUPER"))) { + if (Input::isKeyPressed(keyCode("GLFW_KEY_LEFT_SUPER"))) { glfwSetInputMode(m_window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); } else {