diff --git a/cmake/sdk/CMakeLists.txt b/cmake/sdk/CMakeLists.txt index f0860760a..84d33e478 100644 --- a/cmake/sdk/CMakeLists.txt +++ b/cmake/sdk/CMakeLists.txt @@ -38,11 +38,6 @@ add_subdirectory(lib/external/libwolv EXCLUDE_FROM_ALL) set(LIBPL_ENABLE_CLI OFF CACHE BOOL "" FORCE) add_subdirectory(lib/external/pattern_language EXCLUDE_FROM_ALL) -find_package(CURL REQUIRED) -find_package(mbedTLS 3.4.0 REQUIRED) -set(CURL_LIBRARIES ${CURL_LIBRARIES} PARENT_SCOPE) -set(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARIES} PARENT_SCOPE) - add_subdirectory(lib/libimhex) if (WIN32) diff --git a/lib/libimhex/CMakeLists.txt b/lib/libimhex/CMakeLists.txt index 0e3b1d0af..31e9bb157 100644 --- a/lib/libimhex/CMakeLists.txt +++ b/lib/libimhex/CMakeLists.txt @@ -39,6 +39,7 @@ set(LIBIMHEX_SOURCES source/helpers/default_paths.cpp source/helpers/imgui_hooks.cpp source/helpers/semantic_version.cpp + source/helpers/keys.cpp source/test/tests.cpp diff --git a/lib/libimhex/include/hex/api/imhex_api.hpp b/lib/libimhex/include/hex/api/imhex_api.hpp index c07d87b8d..ff65b9286 100644 --- a/lib/libimhex/include/hex/api/imhex_api.hpp +++ b/lib/libimhex/include/hex/api/imhex_api.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -11,8 +12,7 @@ #include #include #include - -#include +#include using ImGuiID = unsigned int; struct ImVec2; diff --git a/lib/libimhex/include/hex/helpers/http_requests.hpp b/lib/libimhex/include/hex/helpers/http_requests.hpp index 5cadebde2..9f7a5951d 100644 --- a/lib/libimhex/include/hex/helpers/http_requests.hpp +++ b/lib/libimhex/include/hex/helpers/http_requests.hpp @@ -12,10 +12,6 @@ #if defined(OS_WEB) #include - - using curl_off_t = long; -#else - #include #endif typedef void CURL; @@ -121,18 +117,18 @@ namespace hex { static std::string urlDecode(const std::string &input); - protected: - void setDefaultConfig(); + void setProgress(float progress) { m_progress = progress; } + bool isCanceled() const { return m_canceled; } + + static size_t writeToVector(void *contents, size_t size, size_t nmemb, void *userdata); + static size_t writeToFile(void *contents, size_t size, size_t nmemb, void *userdata); template Result executeImpl(std::vector &data); - static size_t writeToVector(void *contents, size_t size, size_t nmemb, void *userdata); - static size_t writeToFile(void *contents, size_t size, size_t nmemb, void *userdata); - static int progressCallback(void *contents, curl_off_t dlTotal, curl_off_t dlNow, curl_off_t ulTotal, curl_off_t ulNow); - private: static void checkProxyErrors(); + void setDefaultConfig(); private: #if defined(OS_WEB) diff --git a/lib/libimhex/include/hex/helpers/http_requests_native.hpp b/lib/libimhex/include/hex/helpers/http_requests_native.hpp index b5323a41e..be35c2dd7 100644 --- a/lib/libimhex/include/hex/helpers/http_requests_native.hpp +++ b/lib/libimhex/include/hex/helpers/http_requests_native.hpp @@ -5,8 +5,6 @@ #include #include - #include - #include #include @@ -14,14 +12,26 @@ namespace hex { + namespace impl { + + void setWriteFunctions(CURL *curl, wolv::io::File &file); + void setWriteFunctions(CURL *curl, std::vector &data); + void setupFileUpload(CURL *curl, wolv::io::File &file, const std::string &fileName, const std::string &mimeName); + void setupFileUpload(CURL *curl, const std::vector &data, const std::fs::path &fileName, const std::string &mimeName); + int executeCurl(CURL *curl, const std::string &url, const std::string &method, const std::string &body, std::map &headers); + long getStatusCode(CURL *curl); + std::string getStatusText(int result); + + } + + template std::future> HttpRequest::downloadFile(const std::fs::path &path) { return std::async(std::launch::async, [this, path] { std::vector response; wolv::io::File file(path, wolv::io::File::Mode::Create); - curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, writeToFile); - curl_easy_setopt(m_curl, CURLOPT_WRITEDATA, &file); + impl::setWriteFunctions(m_curl, file); return this->executeImpl(response); }); @@ -31,40 +41,12 @@ std::future> HttpRequest::uploadFile(const std::fs::path &path, const std::string &mimeName) { return std::async(std::launch::async, [this, path, mimeName]{ auto fileName = wolv::util::toUTF8String(path.filename()); - - curl_mime *mime = curl_mime_init(m_curl); - curl_mimepart *part = curl_mime_addpart(mime); - wolv::io::File file(path, wolv::io::File::Mode::Read); - curl_mime_data_cb(part, file.getSize(), - [](char *buffer, size_t size, size_t nitems, void *arg) -> size_t { - auto handle = static_cast(arg); - - return fread(buffer, size, nitems, handle); - }, - [](void *arg, curl_off_t offset, int origin) -> int { - auto handle = static_cast(arg); - - if (fseek(handle, offset, origin) != 0) - return CURL_SEEKFUNC_CANTSEEK; - else - return CURL_SEEKFUNC_OK; - }, - [](void *arg) { - auto handle = static_cast(arg); - - fclose(handle); - }, - file.getHandle()); - curl_mime_filename(part, fileName.c_str()); - curl_mime_name(part, mimeName.c_str()); - - curl_easy_setopt(m_curl, CURLOPT_MIMEPOST, mime); + impl::setupFileUpload(m_curl, file, fileName, mimeName); std::vector responseData; - curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, writeToVector); - curl_easy_setopt(m_curl, CURLOPT_WRITEDATA, &responseData); + impl::setWriteFunctions(m_curl, responseData); return this->executeImpl(responseData); }); @@ -73,19 +55,10 @@ template std::future> HttpRequest::uploadFile(std::vector data, const std::string &mimeName, const std::fs::path &fileName) { return std::async(std::launch::async, [this, data = std::move(data), mimeName, fileName]{ - curl_mime *mime = curl_mime_init(m_curl); - curl_mimepart *part = curl_mime_addpart(mime); - - curl_mime_data(part, reinterpret_cast(data.data()), data.size()); - auto fileNameStr = wolv::util::toUTF8String(fileName.filename()); - curl_mime_filename(part, fileNameStr.c_str()); - curl_mime_name(part, mimeName.c_str()); - - curl_easy_setopt(m_curl, CURLOPT_MIMEPOST, mime); + impl::setupFileUpload(m_curl, data, fileName, mimeName); std::vector responseData; - curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, writeToVector); - curl_easy_setopt(m_curl, CURLOPT_WRITEDATA, &responseData); + impl::setWriteFunctions(m_curl, responseData); return this->executeImpl(responseData); }); @@ -96,8 +69,7 @@ return std::async(std::launch::async, [this] { std::vector responseData; - curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, writeToVector); - curl_easy_setopt(m_curl, CURLOPT_WRITEDATA, &responseData); + impl::setWriteFunctions(m_curl, responseData); return this->executeImpl(responseData); }); @@ -105,43 +77,16 @@ template HttpRequest::Result HttpRequest::executeImpl(std::vector &data) { - curl_easy_setopt(m_curl, CURLOPT_URL, m_url.c_str()); - curl_easy_setopt(m_curl, CURLOPT_CUSTOMREQUEST, m_method.c_str()); - setDefaultConfig(); - if (!m_body.empty()) { - curl_easy_setopt(m_curl, CURLOPT_POSTFIELDS, m_body.c_str()); + std::scoped_lock lock(m_transmissionMutex); + + if (auto result = impl::executeCurl(m_curl, m_url, m_method, m_body, m_headers); result != 0) { + log::error("Http request '{0} {1}' failed with error {2}: '{3}'", m_method, m_url, u32(result), impl::getStatusText(result)); + checkProxyErrors(); } - curl_slist *headers = nullptr; - headers = curl_slist_append(headers, "Cache-Control: no-cache"); - ON_SCOPE_EXIT { curl_slist_free_all(headers); }; - - for (auto &[key, value] : m_headers) { - std::string header = hex::format("{}: {}", key, value); - headers = curl_slist_append(headers, header.c_str()); - } - curl_easy_setopt(m_curl, CURLOPT_HTTPHEADER, headers); - - { - std::scoped_lock lock(m_transmissionMutex); - - auto result = curl_easy_perform(m_curl); - if (result != CURLE_OK){ - char *url = nullptr; - curl_easy_getinfo(m_curl, CURLINFO_EFFECTIVE_URL, &url); - log::error("Http request '{0} {1}' failed with error {2}: '{3}'", m_method, url, u32(result), curl_easy_strerror(result)); - checkProxyErrors(); - - return { }; - } - } - - long statusCode = 0; - curl_easy_getinfo(m_curl, CURLINFO_RESPONSE_CODE, &statusCode); - - return Result(statusCode, { data.begin(), data.end() }); + return Result(impl::getStatusCode(m_curl), { data.begin(), data.end() }); } } diff --git a/lib/libimhex/include/hex/helpers/keys.hpp b/lib/libimhex/include/hex/helpers/keys.hpp index 6fa03ee0c..341b6881b 100644 --- a/lib/libimhex/include/hex/helpers/keys.hpp +++ b/lib/libimhex/include/hex/helpers/keys.hpp @@ -1,122 +1,123 @@ #pragma once -#include - #if defined(__cplusplus) enum class Keys { #else enum Keys { #endif - Space = GLFW_KEY_SPACE, - Apostrophe = GLFW_KEY_APOSTROPHE, - Comma = GLFW_KEY_COMMA, - Minus = GLFW_KEY_MINUS, - Period = GLFW_KEY_PERIOD, - Slash = GLFW_KEY_SLASH, - Num0 = GLFW_KEY_0, - Num1 = GLFW_KEY_1, - Num2 = GLFW_KEY_2, - Num3 = GLFW_KEY_3, - Num4 = GLFW_KEY_4, - Num5 = GLFW_KEY_5, - Num6 = GLFW_KEY_6, - Num7 = GLFW_KEY_7, - Num8 = GLFW_KEY_8, - Num9 = GLFW_KEY_9, - Semicolon = GLFW_KEY_SEMICOLON, - Equals = GLFW_KEY_EQUAL, - A = GLFW_KEY_A, - B = GLFW_KEY_B, - C = GLFW_KEY_C, - D = GLFW_KEY_D, - E = GLFW_KEY_E, - F = GLFW_KEY_F, - G = GLFW_KEY_G, - H = GLFW_KEY_H, - I = GLFW_KEY_I, - J = GLFW_KEY_J, - K = GLFW_KEY_K, - L = GLFW_KEY_L, - M = GLFW_KEY_M, - N = GLFW_KEY_N, - O = GLFW_KEY_O, - P = GLFW_KEY_P, - Q = GLFW_KEY_Q, - R = GLFW_KEY_R, - S = GLFW_KEY_S, - T = GLFW_KEY_T, - U = GLFW_KEY_U, - V = GLFW_KEY_V, - W = GLFW_KEY_W, - X = GLFW_KEY_X, - Y = GLFW_KEY_Y, - Z = GLFW_KEY_Z, - LeftBracket = GLFW_KEY_LEFT_BRACKET, - Backslash = GLFW_KEY_BACKSLASH, - RightBracket = GLFW_KEY_RIGHT_BRACKET, - GraveAccent = GLFW_KEY_GRAVE_ACCENT, - World1 = GLFW_KEY_WORLD_1, - World2 = GLFW_KEY_WORLD_2, - Escape = GLFW_KEY_ESCAPE, - Enter = GLFW_KEY_ENTER, - Tab = GLFW_KEY_TAB, - Backspace = GLFW_KEY_BACKSPACE, - Insert = GLFW_KEY_INSERT, - Delete = GLFW_KEY_DELETE, - Right = GLFW_KEY_RIGHT, - Left = GLFW_KEY_LEFT, - Down = GLFW_KEY_DOWN, - Up = GLFW_KEY_UP, - PageUp = GLFW_KEY_PAGE_UP, - PageDown = GLFW_KEY_PAGE_DOWN, - Home = GLFW_KEY_HOME, - End = GLFW_KEY_END, - CapsLock = GLFW_KEY_CAPS_LOCK, - ScrollLock = GLFW_KEY_SCROLL_LOCK, - NumLock = GLFW_KEY_NUM_LOCK, - PrintScreen = GLFW_KEY_PRINT_SCREEN, - Pause = GLFW_KEY_PAUSE, - F1 = GLFW_KEY_F1, - F2 = GLFW_KEY_F2, - F3 = GLFW_KEY_F3, - F4 = GLFW_KEY_F4, - F5 = GLFW_KEY_F5, - F6 = GLFW_KEY_F6, - F7 = GLFW_KEY_F7, - F8 = GLFW_KEY_F8, - F9 = GLFW_KEY_F9, - F10 = GLFW_KEY_F10, - F11 = GLFW_KEY_F11, - F12 = GLFW_KEY_F12, - F13 = GLFW_KEY_F13, - F14 = GLFW_KEY_F14, - F15 = GLFW_KEY_F15, - F16 = GLFW_KEY_F16, - F17 = GLFW_KEY_F17, - F18 = GLFW_KEY_F18, - F19 = GLFW_KEY_F19, - F20 = GLFW_KEY_F20, - F21 = GLFW_KEY_F21, - F22 = GLFW_KEY_F22, - F23 = GLFW_KEY_F23, - F24 = GLFW_KEY_F24, - F25 = GLFW_KEY_F25, - KeyPad0 = GLFW_KEY_KP_0, - KeyPad1 = GLFW_KEY_KP_1, - KeyPad2 = GLFW_KEY_KP_2, - KeyPad3 = GLFW_KEY_KP_3, - KeyPad4 = GLFW_KEY_KP_4, - KeyPad5 = GLFW_KEY_KP_5, - KeyPad6 = GLFW_KEY_KP_6, - KeyPad7 = GLFW_KEY_KP_7, - KeyPad8 = GLFW_KEY_KP_8, - KeyPad9 = GLFW_KEY_KP_9, - KeyPadDecimal = GLFW_KEY_KP_DECIMAL, - KeyPadDivide = GLFW_KEY_KP_DIVIDE, - KeyPadMultiply = GLFW_KEY_KP_MULTIPLY, - KeyPadSubtract = GLFW_KEY_KP_SUBTRACT, - KeyPadAdd = GLFW_KEY_KP_ADD, - KeyPadEnter = GLFW_KEY_KP_ENTER, - KeyPadEqual = GLFW_KEY_KP_EQUAL, - Menu = GLFW_KEY_MENU, + Invalid, + Space, + Apostrophe, + Comma, + Minus, + Period, + Slash, + Num0, + Num1, + Num2, + Num3, + Num4, + Num5, + Num6, + Num7, + Num8, + Num9, + Semicolon, + Equals, + A, + B, + C, + D, + E, + F, + G, + H, + I, + J, + K, + L, + M, + N, + O, + P, + Q, + R, + S, + T, + U, + V, + W, + X, + Y, + Z, + LeftBracket, + Backslash, + RightBracket, + GraveAccent, + World1, + World2, + Escape, + Enter, + Tab, + Backspace, + Insert, + Delete, + Right, + Left, + Down, + Up, + PageUp, + PageDown, + Home, + End, + CapsLock, + ScrollLock, + NumLock, + PrintScreen, + Pause, + F1, + F2, + F3, + F4, + F5, + F6, + F7, + F8, + F9, + F10, + F11, + F12, + F13, + F14, + F15, + F16, + F17, + F18, + F19, + F20, + F21, + F22, + F23, + F24, + F25, + KeyPad0, + KeyPad1, + KeyPad2, + KeyPad3, + KeyPad4, + KeyPad5, + KeyPad6, + KeyPad7, + KeyPad8, + KeyPad9, + KeyPadDecimal, + KeyPadDivide, + KeyPadMultiply, + KeyPadSubtract, + KeyPadAdd, + KeyPadEnter, + KeyPadEqual, + Menu }; + +Keys scanCodeToKey(int scanCode); \ No newline at end of file diff --git a/lib/libimhex/include/hex/helpers/opengl.hpp b/lib/libimhex/include/hex/helpers/opengl.hpp index 16c008e3f..7525c3635 100644 --- a/lib/libimhex/include/hex/helpers/opengl.hpp +++ b/lib/libimhex/include/hex/helpers/opengl.hpp @@ -12,7 +12,6 @@ #include #include -#include #include "imgui.h" namespace hex::gl { diff --git a/lib/libimhex/source/api/shortcut_manager.cpp b/lib/libimhex/source/api/shortcut_manager.cpp index f1943b15c..bd57b66de 100644 --- a/lib/libimhex/source/api/shortcut_manager.cpp +++ b/lib/libimhex/source/api/shortcut_manager.cpp @@ -310,7 +310,7 @@ namespace hex { if (focused) pressedShortcut += CurrentView; - pressedShortcut += static_cast(keyCode); + pressedShortcut += scanCodeToKey(keyCode); return pressedShortcut; } diff --git a/lib/libimhex/source/helpers/http_requests_emscripten.cpp b/lib/libimhex/source/helpers/http_requests_emscripten.cpp index 094d4dcf2..55e9ab312 100644 --- a/lib/libimhex/source/helpers/http_requests_emscripten.cpp +++ b/lib/libimhex/source/helpers/http_requests_emscripten.cpp @@ -49,15 +49,6 @@ namespace hex { } void HttpRequest::checkProxyErrors() { } - - int HttpRequest::progressCallback(void *contents, curl_off_t dlTotal, curl_off_t dlNow, curl_off_t ulTotal, curl_off_t ulNow) { - std::ignore = contents; - std::ignore = dlTotal; - std::ignore = dlNow; - std::ignore = ulTotal; - std::ignore = ulNow; - return -1; - } } #endif \ No newline at end of file diff --git a/lib/libimhex/source/helpers/http_requests_native.cpp b/lib/libimhex/source/helpers/http_requests_native.cpp index 331371082..3b2d57049 100644 --- a/lib/libimhex/source/helpers/http_requests_native.cpp +++ b/lib/libimhex/source/helpers/http_requests_native.cpp @@ -1,6 +1,7 @@ #if !defined(OS_WEB) #include +#include namespace hex { @@ -11,6 +12,19 @@ namespace hex { } + int progressCallback(void *contents, curl_off_t dlTotal, curl_off_t dlNow, curl_off_t ulTotal, curl_off_t ulNow) { + auto &request = *static_cast(contents); + + if (dlTotal > 0) + request.setProgress(float(dlNow) / dlTotal); + else if (ulTotal > 0) + request.setProgress(float(ulNow) / ulTotal); + else + request.setProgress(0.0F); + + return request.isCanceled() ? CURLE_ABORTED_BY_CALLBACK : CURLE_OK; + } + HttpRequest::HttpRequest(std::string method, std::string url) : m_method(std::move(method)), m_url(std::move(url)) { AT_FIRST_TIME { curl_global_init(CURL_GLOBAL_ALL); @@ -95,19 +109,101 @@ namespace hex { } } - int HttpRequest::progressCallback(void *contents, curl_off_t dlTotal, curl_off_t dlNow, curl_off_t ulTotal, curl_off_t ulNow) { - auto &request = *static_cast(contents); + namespace impl { - if (dlTotal > 0) - request.m_progress = float(dlNow) / dlTotal; - else if (ulTotal > 0) - request.m_progress = float(ulNow) / ulTotal; - else - request.m_progress = 0.0F; + void setWriteFunctions(CURL *curl, wolv::io::File &file) { + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HttpRequest::writeToFile); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &file); + } + + void setWriteFunctions(CURL *curl, std::vector &data) { + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HttpRequest::writeToVector); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &data); + } + + void setupFileUpload(CURL *curl, wolv::io::File &file, const std::string &fileName, const std::string &mimeName) { + curl_mime *mime = curl_mime_init(curl); + curl_mimepart *part = curl_mime_addpart(mime); + + + curl_mime_data_cb(part, file.getSize(), + [](char *buffer, size_t size, size_t nitems, void *arg) -> size_t { + auto handle = static_cast(arg); + + return fread(buffer, size, nitems, handle); + }, + [](void *arg, curl_off_t offset, int origin) -> int { + auto handle = static_cast(arg); + + if (fseek(handle, offset, origin) != 0) + return CURL_SEEKFUNC_CANTSEEK; + else + return CURL_SEEKFUNC_OK; + }, + [](void *arg) { + auto handle = static_cast(arg); + + fclose(handle); + }, + file.getHandle()); + curl_mime_filename(part, fileName.c_str()); + curl_mime_name(part, mimeName.c_str()); + + curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime); + } + + void setupFileUpload(CURL *curl, const std::vector &data, const std::fs::path &fileName, const std::string &mimeName) { + curl_mime *mime = curl_mime_init(curl); + curl_mimepart *part = curl_mime_addpart(mime); + + curl_mime_data(part, reinterpret_cast(data.data()), data.size()); + auto fileNameStr = wolv::util::toUTF8String(fileName.filename()); + curl_mime_filename(part, fileNameStr.c_str()); + curl_mime_name(part, mimeName.c_str()); + + curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime); + } + + int executeCurl(CURL *curl, const std::string &url, const std::string &method, const std::string &body, std::map &headers) { + curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); + curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, method.c_str()); + + if (!body.empty()) { + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str()); + } + + curl_slist *headersList = nullptr; + headersList = curl_slist_append(headersList, "Cache-Control: no-cache"); + ON_SCOPE_EXIT { curl_slist_free_all(headersList); }; + + for (auto &[key, value] : headers) { + std::string header = hex::format("{}: {}", key, value); + headersList = curl_slist_append(headersList, header.c_str()); + } + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); + + auto result = curl_easy_perform(curl); + if (result != CURLE_OK){ + return result; + } + + return 0; + } + + long getStatusCode(CURL *curl) { + long statusCode = 0; + curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &statusCode); + + return statusCode; + } + + std::string getStatusText(int result) { + return curl_easy_strerror(CURLcode(result)); + } - return request.m_canceled ? CURLE_ABORTED_BY_CALLBACK : CURLE_OK; } + } diff --git a/lib/libimhex/source/helpers/keys.cpp b/lib/libimhex/source/helpers/keys.cpp new file mode 100644 index 000000000..ff22ede40 --- /dev/null +++ b/lib/libimhex/source/helpers/keys.cpp @@ -0,0 +1,121 @@ +#include + +#include + +Keys scanCodeToKey(int scanCode) { + switch (scanCode) { + case GLFW_KEY_SPACE: return Keys::Space; + case GLFW_KEY_APOSTROPHE: return Keys::Apostrophe; + case GLFW_KEY_COMMA: return Keys::Comma; + case GLFW_KEY_MINUS: return Keys::Minus; + case GLFW_KEY_PERIOD: return Keys::Period; + case GLFW_KEY_SLASH: return Keys::Slash; + case GLFW_KEY_0: return Keys::Num0; + case GLFW_KEY_1: return Keys::Num1; + case GLFW_KEY_2: return Keys::Num2; + case GLFW_KEY_3: return Keys::Num3; + case GLFW_KEY_4: return Keys::Num4; + case GLFW_KEY_5: return Keys::Num5; + case GLFW_KEY_6: return Keys::Num6; + case GLFW_KEY_7: return Keys::Num7; + case GLFW_KEY_8: return Keys::Num8; + case GLFW_KEY_9: return Keys::Num9; + case GLFW_KEY_SEMICOLON: return Keys::Semicolon; + case GLFW_KEY_EQUAL: return Keys::Equals; + case GLFW_KEY_A: return Keys::A; + case GLFW_KEY_B: return Keys::B; + case GLFW_KEY_C: return Keys::C; + case GLFW_KEY_D: return Keys::D; + case GLFW_KEY_E: return Keys::E; + case GLFW_KEY_F: return Keys::F; + case GLFW_KEY_G: return Keys::G; + case GLFW_KEY_H: return Keys::H; + case GLFW_KEY_I: return Keys::I; + case GLFW_KEY_J: return Keys::J; + case GLFW_KEY_K: return Keys::K; + case GLFW_KEY_L: return Keys::L; + case GLFW_KEY_M: return Keys::M; + case GLFW_KEY_N: return Keys::N; + case GLFW_KEY_O: return Keys::O; + case GLFW_KEY_P: return Keys::P; + case GLFW_KEY_Q: return Keys::Q; + case GLFW_KEY_R: return Keys::R; + case GLFW_KEY_S: return Keys::S; + case GLFW_KEY_T: return Keys::T; + case GLFW_KEY_U: return Keys::U; + case GLFW_KEY_V: return Keys::V; + case GLFW_KEY_W: return Keys::W; + case GLFW_KEY_X: return Keys::X; + case GLFW_KEY_Y: return Keys::Y; + case GLFW_KEY_Z: return Keys::Z; + case GLFW_KEY_LEFT_BRACKET: return Keys::LeftBracket; + case GLFW_KEY_BACKSLASH: return Keys::Backslash; + case GLFW_KEY_RIGHT_BRACKET: return Keys::RightBracket; + case GLFW_KEY_GRAVE_ACCENT: return Keys::GraveAccent; + case GLFW_KEY_WORLD_1: return Keys::World1; + case GLFW_KEY_WORLD_2: return Keys::World2; + case GLFW_KEY_ESCAPE: return Keys::Escape; + case GLFW_KEY_ENTER: return Keys::Enter; + case GLFW_KEY_TAB: return Keys::Tab; + case GLFW_KEY_BACKSPACE: return Keys::Backspace; + case GLFW_KEY_INSERT: return Keys::Insert; + case GLFW_KEY_DELETE: return Keys::Delete; + case GLFW_KEY_RIGHT: return Keys::Right; + case GLFW_KEY_LEFT: return Keys::Left; + case GLFW_KEY_DOWN: return Keys::Down; + case GLFW_KEY_UP: return Keys::Up; + case GLFW_KEY_PAGE_UP: return Keys::PageUp; + case GLFW_KEY_PAGE_DOWN: return Keys::PageDown; + case GLFW_KEY_HOME: return Keys::Home; + case GLFW_KEY_END: return Keys::End; + case GLFW_KEY_CAPS_LOCK: return Keys::CapsLock; + case GLFW_KEY_SCROLL_LOCK: return Keys::ScrollLock; + case GLFW_KEY_NUM_LOCK: return Keys::NumLock; + case GLFW_KEY_PRINT_SCREEN: return Keys::PrintScreen; + case GLFW_KEY_PAUSE: return Keys::Pause; + case GLFW_KEY_F1: return Keys::F1; + case GLFW_KEY_F2: return Keys::F2; + case GLFW_KEY_F3: return Keys::F3; + case GLFW_KEY_F4: return Keys::F4; + case GLFW_KEY_F5: return Keys::F5; + case GLFW_KEY_F6: return Keys::F6; + case GLFW_KEY_F7: return Keys::F7; + case GLFW_KEY_F8: return Keys::F8; + case GLFW_KEY_F9: return Keys::F9; + case GLFW_KEY_F10: return Keys::F10; + case GLFW_KEY_F11: return Keys::F11; + case GLFW_KEY_F12: return Keys::F12; + case GLFW_KEY_F13: return Keys::F13; + case GLFW_KEY_F14: return Keys::F14; + case GLFW_KEY_F15: return Keys::F15; + case GLFW_KEY_F16: return Keys::F16; + case GLFW_KEY_F17: return Keys::F17; + case GLFW_KEY_F18: return Keys::F18; + case GLFW_KEY_F19: return Keys::F19; + case GLFW_KEY_F20: return Keys::F20; + case GLFW_KEY_F21: return Keys::F21; + case GLFW_KEY_F22: return Keys::F22; + case GLFW_KEY_F23: return Keys::F23; + case GLFW_KEY_F24: return Keys::F24; + case GLFW_KEY_F25: return Keys::F25; + case GLFW_KEY_KP_0: return Keys::KeyPad0; + case GLFW_KEY_KP_1: return Keys::KeyPad1; + case GLFW_KEY_KP_2: return Keys::KeyPad2; + case GLFW_KEY_KP_3: return Keys::KeyPad3; + case GLFW_KEY_KP_4: return Keys::KeyPad4; + case GLFW_KEY_KP_5: return Keys::KeyPad5; + case GLFW_KEY_KP_6: return Keys::KeyPad6; + case GLFW_KEY_KP_7: return Keys::KeyPad7; + case GLFW_KEY_KP_8: return Keys::KeyPad8; + case GLFW_KEY_KP_9: return Keys::KeyPad9; + case GLFW_KEY_KP_DECIMAL: return Keys::KeyPadDecimal; + case GLFW_KEY_KP_DIVIDE: return Keys::KeyPadDivide; + case GLFW_KEY_KP_MULTIPLY: return Keys::KeyPadMultiply; + case GLFW_KEY_KP_SUBTRACT: return Keys::KeyPadSubtract; + case GLFW_KEY_KP_ADD: return Keys::KeyPadAdd; + case GLFW_KEY_KP_ENTER: return Keys::KeyPadEnter; + case GLFW_KEY_KP_EQUAL: return Keys::KeyPadEqual; + case GLFW_KEY_MENU: return Keys::Menu; + default: return Keys::Invalid; + } +} \ No newline at end of file diff --git a/main/gui/source/window/win_window.cpp b/main/gui/source/window/win_window.cpp index 80c298ed6..ed4fbb024 100644 --- a/main/gui/source/window/win_window.cpp +++ b/main/gui/source/window/win_window.cpp @@ -19,6 +19,7 @@ #include #define GLFW_EXPOSE_NATIVE_WIN32 + #include #include #undef GLFW_EXPOSE_NATIVE_WIN32 diff --git a/plugins/builtin/source/content/events.cpp b/plugins/builtin/source/content/events.cpp index 4f33e21cf..bfe68ac4a 100644 --- a/plugins/builtin/source/content/events.cpp +++ b/plugins/builtin/source/content/events.cpp @@ -29,6 +29,8 @@ #include #include +#include + namespace hex::plugin::builtin { static void openFile(const std::fs::path &path) { diff --git a/plugins/builtin/source/content/main_menu_items.cpp b/plugins/builtin/source/content/main_menu_items.cpp index cea1c4fc6..11ec4b400 100644 --- a/plugins/builtin/source/content/main_menu_items.cpp +++ b/plugins/builtin/source/content/main_menu_items.cpp @@ -26,6 +26,8 @@ #include #include +#include + using namespace std::literals::string_literals; using namespace wolv::literals; diff --git a/plugins/builtin/source/content/window_decoration.cpp b/plugins/builtin/source/content/window_decoration.cpp index a86d493e9..e1d3773d3 100644 --- a/plugins/builtin/source/content/window_decoration.cpp +++ b/plugins/builtin/source/content/window_decoration.cpp @@ -19,6 +19,8 @@ #include #include +#include + namespace hex::plugin::builtin { // Function that draws the provider popup, defiend in the ui_items.cpp file