diff --git a/cth/CMakeLists.txt b/cth/CMakeLists.txt index 3c69052..6cc5bf1 100644 --- a/cth/CMakeLists.txt +++ b/cth/CMakeLists.txt @@ -9,7 +9,13 @@ cth_pkg_target_include_directories( INTERFACE incl ) -target_compile_options(cth INTERFACE $<$:/Zc:preprocessor>) +# nvcc rejects cl flags, it forwards them to its MSVC host compiler with -Xcompiler +target_compile_options( + cth + INTERFACE + $<$:/Zc:preprocessor> + $<$,$>:-Xcompiler=/Zc:preprocessor> +) # cth/hash/hash_aggregates.hpp includes boost/pfr.hpp cth_pkg_target_find_package(cth boost_pfr CONFIG REQUIRED) diff --git a/cth_net/src/websocket_server.cpp b/cth_net/src/websocket_server.cpp index 4181504..5eb53bd 100644 --- a/cth_net/src/websocket_server.cpp +++ b/cth_net/src/websocket_server.cpp @@ -4,17 +4,44 @@ #include "websocket_connection_state.hpp" #include "cth/data/hash_map.hpp" +#include "cth/io/log.hpp" #include +#include #include #include #include +#include #include +#include #include #include namespace cth::net { +namespace { + void forward_libhv_log(int level, char const* message, int length) { + std::string_view text{message, static_cast(length)}; + while(text.ends_with('\n') || text.ends_with('\r')) + text.remove_suffix(1); + + auto const severity = level >= LOG_LEVEL_ERROR ? except::ERR : except::WARNING; + log::msg(severity, std::format("libhv: {}", text)); + } + + /** + * libhv's default logger writes libhv..log into the working directory, + * its warnings and errors go to cth::log instead + */ + void route_libhv_log() { + static std::once_flag once; + std::call_once(once, [] { + hlog_set_format("%s"); + hlog_set_level(LOG_LEVEL_WARN); + hlog_set_handler(forward_libhv_log); + }); + } +} struct websocket_server::impl { hv::WebSocketService service; @@ -48,6 +75,7 @@ websocket_server::impl::impl(std::uint16_t port, std::size_t maxMessageSize) : maxMessageSize{maxMessageSize} { CTH_CRITICAL(maxMessageSize == 0, "WebSocket maximum message size must be positive") {} + route_libhv_log(); configure_callbacks(); auto const listenFd = Listen(port, "127.0.0.1"); diff --git a/cth_win/src/io/win_key_convert.hpp b/cth_win/src/io/win_key_convert.hpp index 9167d00..9cfa577 100644 --- a/cth_win/src/io/win_key_convert.hpp +++ b/cth_win/src/io/win_key_convert.hpp @@ -284,7 +284,9 @@ struct win_key_params { break; default: - if(p.vkCode >= 'A' && p.vkCode <= 'Z') + if(p.vkCode >= VK_F1 && p.vkCode <= VK_F12) + key = static_cast(static_cast(Key::F1) + (p.vkCode - VK_F1)); + else if(p.vkCode >= 'A' && p.vkCode <= 'Z') key = static_cast(static_cast(Key::A) + (p.vkCode - 'A')); else if(p.vkCode >= '0' && p.vkCode <= '9') key = static_cast(static_cast(Key::DIGIT_0) + (p.vkCode - '0'));