From 327bd0ccf649629e92b46eb858234eb0593349b3 Mon Sep 17 00:00:00 2001 From: pit-ray Date: Wed, 29 Dec 2021 04:57:39 +0900 Subject: [PATCH] Fixed a problem with map not printing capital letters --- CMakeLists.txt | 2 +- res/build_assets/resource.rc | 10 +- src/core/inputgate.cpp | 172 ++++++++++++++++------------------ src/core/inputgate.hpp | 84 +++++++++-------- src/core/syscalldef.hpp | 2 +- src/core/version.hpp | 2 +- tests/each/inputgate_test.cpp | 20 ++-- 7 files changed, 144 insertions(+), 148 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 89a89496..395b2ade 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.6.0) -project(win-vind VERSION 4.3.0) +project(win-vind VERSION 4.3.1) if(NOT BIT_TYPE) set(BIT_TYPE 64) diff --git a/res/build_assets/resource.rc b/res/build_assets/resource.rc index 4fb036d7..23890e94 100644 --- a/res/build_assets/resource.rc +++ b/res/build_assets/resource.rc @@ -3,7 +3,7 @@ IDI_ICON1 ICON DISCARDABLE "icon512.ico" VS_VERSION_INFO VERSIONINFO -FILEVERSION 4,3,0 +FILEVERSION 4,3,1 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGS VS_FF_PRERELEASE FILEOS VOS_NT_WINDOWS32 @@ -14,12 +14,12 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "pit-ray\0" - VALUE "FileDescription", "win-vind (64-bit)\0" + VALUE "FileDescription", "win-vind (32-bit)\0" VALUE "LegalCopyright", "Copyright (c) 2020-2021 pit-ray\0" - VALUE "InternalName", "win-vind (64-bit)\0" + VALUE "InternalName", "win-vind (32-bit)\0" VALUE "OriginalFilename", "win-vind.exe\0" - VALUE "ProductName", "win-vind (64bit)\0" - VALUE "ProductVersion", "4.3.0\0" + VALUE "ProductName", "win-vind (32bit)\0" + VALUE "ProductVersion", "4.3.1\0" END END BLOCK "VarFileInfo" diff --git a/src/core/inputgate.cpp b/src/core/inputgate.cpp index 869fb4cc..851e2335 100644 --- a/src/core/inputgate.cpp +++ b/src/core/inputgate.cpp @@ -18,6 +18,7 @@ #include "util/keystroke_repeater.hpp" #include "util/winwrap.hpp" +#include #include #include @@ -31,6 +32,9 @@ #define KEYUP_MASK 0x0001 +#define SC_MAPHOOK static_cast(105) +#define SC_MAPHOOK_REPRD static_cast(100) + namespace { @@ -38,54 +42,40 @@ namespace using namespace vind::core ; class MapHook : public bind::BindedFunc { + private: + SystemCall do_process() const override { + return SC_MAPHOOK ; + } + SystemCall do_process(core::NTypeLogger&) const override { + return SC_MAPHOOK ; + } + SystemCall do_process(const core::CharLogger&) const override { + return SC_MAPHOOK ; + } public: template explicit MapHook(IDString&& id) : BindedFunc("maphook_" + id) {} - - virtual ~MapHook() noexcept = default ; - - MapHook(MapHook&&) = default ; - MapHook& operator=(MapHook&&) = default ; - - MapHook(const MapHook&) = delete ; - MapHook& operator=(const MapHook&) = delete ; } ; - class MapHookReproduce : public bind::BindedFunc { private: - Command cmd_ ; - SystemCall do_process() const override { - auto& igate = InputGate::get_instance() ; - for(const auto& keyset : cmd_) { - igate.pushup(keyset.begin(), keyset.end()) ; - } - return SystemCall::NOTHING ; + return SC_MAPHOOK_REPRD ; } SystemCall do_process(core::NTypeLogger&) const override { - return SystemCall::NOTHING ; + return SC_MAPHOOK_REPRD ; } SystemCall do_process(const core::CharLogger&) const override { - return SystemCall::NOTHING ; + return SC_MAPHOOK_REPRD ; } public: - template - explicit MapHookReproduce(IDString&& id, TypeCommand&& cmd) - : BindedFunc("maphook_reproduce_" + id), - cmd_(std::forward(cmd)) + template + explicit MapHookReproduce(IDString&& id) + : BindedFunc("maphook_reproduce_" + id) {} - - virtual ~MapHookReproduce() noexcept = default ; - - MapHookReproduce(MapHookReproduce&&) = default ; - MapHookReproduce& operator=(MapHookReproduce&&) = default ; - - MapHookReproduce(const MapHookReproduce&) = delete ; - MapHookReproduce& operator=(const MapHookReproduce&) = delete ; } ; @@ -273,6 +263,8 @@ namespace } } + util::remove_deplication(mapped_set) ; + if(!mapped_set.empty()) { merged.push_back(std::move(mapped_set)) ; } @@ -299,15 +291,6 @@ namespace for(const auto& parser : parsers) { auto funcid = parser->get_func()->id() ; - // To generate keystrokes, convert them to physical - // keys and also arrange the order of the keys. - for(auto& keyset : target_cmds[funcid]) { - for(auto& key : keyset) { - key = key.to_physical() ; - } - util::remove_deplication(keyset) ; - } - auto mapid = id_func2map[funcid] ; solved_outcmd[mapid] = std::move(target_cmds[funcid]) ; } @@ -316,7 +299,7 @@ namespace struct MapGate { - std::unordered_map> logpool_{} ; + std::unordered_map cmdtable_{} ; LoggerParserManager mgr_{} ; Key2KeysetMap syncmap_{} ; @@ -384,7 +367,7 @@ namespace keys.push_back(key) ; } else { - syskeys.push_back(key.to_physical()) ; + syskeys.push_back(key) ; } } @@ -393,14 +376,15 @@ namespace } } - logpool_.clear() ; + cmdtable_.clear() ; auto solved_target_cmds = solve_recursive_cmd2cmd_mapping(map_cmd2cmd, syncmap_) ; std::vector parsers{} ; for(const auto& [mapid, map] : map_cmd2cmd) { if(solved_target_cmds.find(mapid) == solved_target_cmds.end()) { - PRINT_ERROR( mode_to_prefix(mode) + "map " + \ + PRINT_ERROR( + mode_to_prefix(mode) + "map " + \ map.trigger_command_string() + " " + map.target_command_string() + " recursively remaps itself.") ; @@ -408,26 +392,25 @@ namespace } auto func = std::make_shared( - map.trigger_command_string(), solved_target_cmds[mapid]) ; + map.trigger_command_string()) ; + auto parser = std::make_shared(func) ; parser->append_binding(map.trigger_command()) ; - parsers.push_back(std::move(parser)) ; + parsers.push_back(parser) ; - for(const auto& keyset : solved_target_cmds[mapid]) { - logpool_[func->id()].emplace_back(keyset.begin(), keyset.end()) ; - } + cmdtable_[func->id()] = solved_target_cmds[mapid] ; } for(const auto& [mapid, map] : noremap_cmd2cmd) { auto func = std::make_shared( map.trigger_command_string()) ; + auto parser = std::make_shared(func) ; parser->append_binding(map.trigger_command()) ; - parsers.push_back(std::move(parser)) ; - for(const auto& keyset : map.target_command()) { - logpool_[func->id()].emplace_back(keyset.begin(), keyset.end()) ; - } + parsers.push_back(parser) ; + + cmdtable_[func->id()] = map.target_command() ; } mgr_ = LoggerParserManager(std::move(parsers)) ; @@ -457,7 +440,8 @@ namespace vind ModeArray mapgate_ ; - std::queue pool_ ; + std::queue pool_ ; + bool pool_reprd_mode_ ; Impl() : hook_(nullptr), @@ -469,7 +453,8 @@ namespace vind absorb_state_(true), lgr_(), mapgate_(), - pool_() + pool_(), + pool_reprd_mode_(false) {} ~Impl() noexcept = default ; @@ -814,12 +799,25 @@ namespace vind return true ; } - std::vector InputGate::map_logger( - const KeyLog& log, - Mode mode) { + + KeyLog InputGate::pop_log(Mode mode) { + if(!pimpl->pool_.empty()) { + auto keyset = std::move(pimpl->pool_.front()) ; + pimpl->pool_.pop() ; + + if(pimpl->pool_reprd_mode_ && !keyset.empty()) { + pushup(keyset.begin(), keyset.end()) ; + } + + return KeyLog( + std::make_move_iterator(keyset.begin()), + std::make_move_iterator(keyset.end())) ; + } + + auto log = pressed_list() ; if(NTYPE_EMPTY(pimpl->lgr_.logging_state(log))) { - return std::vector{} ; + return log ; } auto& gate = pimpl->mapgate_[static_cast(mode)] ; @@ -828,51 +826,43 @@ namespace vind if(!parser) { pimpl->lgr_.reject() ; gate.mgr_.reset_parser_states() ; - return std::vector{} ; + return log ; } if(parser->is_accepted()) { - auto func = parser->get_func() ; - func->process() ; pimpl->lgr_.accept() ; gate.mgr_.reset_parser_states() ; - return gate.logpool_[func->id()] ; - } - if(parser->is_rejected_with_ready()) { - gate.mgr_.backward_parser_states(1) ; - pimpl->lgr_.remove_from_back(1) ; - } - return std::vector{} ; - } + auto func = parser->get_func() ; + auto sc = func->process() ; - KeyLog InputGate::pop_log(Mode mode) { - if(!pimpl->pool_.empty()) { - auto log = std::move(pimpl->pool_.front()) ; - pimpl->pool_.pop() ; - return log ; - } + pimpl->pool_reprd_mode_ = sc == SC_MAPHOOK_REPRD ; - auto log = pressed_list() ; + const auto& cmd = gate.cmdtable_.at(func->id()) ; - auto logs = map_logger(log, mode) ; - if(logs.empty()) { - return log ; - } + auto itr = cmd.begin() ; - auto itr = std::make_move_iterator(logs.begin()) ; - log = std::move(*itr) ; - itr ++ ; + log = KeyLog(itr->begin(), itr->end()) ; - // - // To simulate the input, make a state transition with an empty log. - // This is to make the logger recognize that it is a key release, - // not a long pressing of the key. - // - while(itr != std::make_move_iterator(logs.end())) { - pimpl->pool_.emplace() ; - pimpl->pool_.push(std::move(*itr)) ; + if(pimpl->pool_reprd_mode_) { + pushup(itr->begin(), itr->end()) ; + } itr ++ ; + + // + // To simulate the input, make a state transition with an empty log. + // This is to make the logger recognize that it is a key release, + // not a long pressing of the key. + // + while(itr != cmd.end()) { + pimpl->pool_.emplace() ; + pimpl->pool_.push(*itr) ; + itr ++ ; + } + } + else if(parser->is_rejected_with_ready()) { + gate.mgr_.backward_parser_states(1) ; + pimpl->lgr_.remove_from_back(1) ; } return log ; } diff --git a/src/core/inputgate.hpp b/src/core/inputgate.hpp index 8625cba6..586b23f0 100644 --- a/src/core/inputgate.hpp +++ b/src/core/inputgate.hpp @@ -5,7 +5,7 @@ #include "keycodedef.hpp" #include "keylog.hpp" #include "mode.hpp" - +#include "util/debug.hpp" #include "util/def.hpp" #include @@ -133,7 +133,7 @@ namespace vind #if defined(__GNUC__) #pragma gcc diagnostic warning "-wmissing-field-initializers" #endif - in.ki.wVk = static_cast(begin->to_code()) ; + in.ki.wVk = static_cast(begin->to_physical().to_code()) ; in.ki.wScan = static_cast(MapVirtualKeyA(in.ki.wVk, MAPVK_VK_TO_VSC)) ; in.ki.dwFlags = KEYEVENTF_KEYUP | extended_key_flag(in.ki.wVk) ; in.ki.dwExtraInfo = GetMessageExtraInfo() ; @@ -156,12 +156,12 @@ namespace vind #if defined(__GNUC__) #pragma gcc diagnostic warning "-wmissing-field-initializers" #endif - ins[0].ki.wVk = static_cast(begin->to_code()) ; + ins[0].ki.wVk = static_cast(begin->to_physical().to_code()) ; ins[0].ki.wScan = static_cast(MapVirtualKeyA(ins[0].ki.wVk, MAPVK_VK_TO_VSC)) ; ins[0].ki.dwFlags = KEYEVENTF_KEYUP | extended_key_flag(ins[0].ki.wVk) ; ins[0].ki.dwExtraInfo = GetMessageExtraInfo() ; - ins[1].ki.wVk = static_cast((begin + 1)->to_code()) ; + ins[1].ki.wVk = static_cast((begin + 1)->to_physical().to_code()) ; ins[1].ki.wScan = static_cast(MapVirtualKeyA(ins[1].ki.wVk, MAPVK_VK_TO_VSC)) ; ins[1].ki.dwFlags = KEYEVENTF_KEYUP | extended_key_flag(ins[1].ki.wVk) ; ins[1].ki.dwExtraInfo = GetMessageExtraInfo() ; @@ -187,17 +187,17 @@ namespace vind #if defined(__GNUC__) #pragma gcc diagnostic warning "-wmissing-field-initializers" #endif - ins[0].ki.wVk = static_cast(begin->to_code()) ; + ins[0].ki.wVk = static_cast(begin->to_physical().to_code()) ; ins[0].ki.wScan = static_cast(MapVirtualKeyA(ins[0].ki.wVk, MAPVK_VK_TO_VSC)) ; ins[0].ki.dwFlags = KEYEVENTF_KEYUP | extended_key_flag(ins[0].ki.wVk) ; ins[0].ki.dwExtraInfo = GetMessageExtraInfo() ; - ins[1].ki.wVk = static_cast((begin + 1)->to_code()) ; + ins[1].ki.wVk = static_cast((begin + 1)->to_physical().to_code()) ; ins[1].ki.wScan = static_cast(MapVirtualKeyA(ins[1].ki.wVk, MAPVK_VK_TO_VSC)) ; ins[1].ki.dwFlags = KEYEVENTF_KEYUP | extended_key_flag(ins[1].ki.wVk) ; ins[1].ki.dwExtraInfo = GetMessageExtraInfo() ; - ins[2].ki.wVk = static_cast((begin + 2)->to_code()) ; + ins[2].ki.wVk = static_cast((begin + 2)->to_physical().to_code()) ; ins[2].ki.wScan = static_cast(MapVirtualKeyA(ins[2].ki.wVk, MAPVK_VK_TO_VSC)) ; ins[2].ki.dwFlags = KEYEVENTF_KEYUP | extended_key_flag(ins[2].ki.wVk) ; ins[2].ki.dwExtraInfo = GetMessageExtraInfo() ; @@ -215,7 +215,7 @@ namespace vind default: { std::unique_ptr dins(new INPUT[size]) ; for(std::size_t i = 0 ; i < size ; i ++) { - dins[i].ki.wVk = static_cast((begin + i)->to_code()) ; + dins[i].ki.wVk = static_cast((begin + i)->to_physical().to_code()) ; dins[i].ki.wScan = static_cast(MapVirtualKeyA(dins[i].ki.wVk, MAPVK_VK_TO_VSC)) ; dins[i].ki.dwFlags = KEYEVENTF_KEYUP | extended_key_flag(dins[i].ki.wVk) ; dins[i].ki.dwExtraInfo = GetMessageExtraInfo() ; @@ -280,7 +280,7 @@ namespace vind #if defined(__GNUC__) #pragma gcc diagnostic warning "-wmissing-field-initializers" #endif - in.ki.wVk = static_cast(begin->to_code()) ; + in.ki.wVk = static_cast(begin->to_physical().to_code()) ; in.ki.wScan = static_cast(MapVirtualKeyA(in.ki.wVk, MAPVK_VK_TO_VSC)) ; in.ki.dwFlags = extended_key_flag(in.ki.wVk) ; in.ki.dwExtraInfo = GetMessageExtraInfo() ; @@ -304,12 +304,12 @@ namespace vind #pragma gcc diagnostic warning "-wmissing-field-initializers" #endif - ins[0].ki.wVk = static_cast(begin->to_code()) ; + ins[0].ki.wVk = static_cast(begin->to_physical().to_code()) ; ins[0].ki.wScan = static_cast(MapVirtualKeyA(ins[0].ki.wVk, MAPVK_VK_TO_VSC)) ; ins[0].ki.dwFlags = extended_key_flag(ins[0].ki.wVk) ; ins[0].ki.dwExtraInfo = GetMessageExtraInfo() ; - ins[1].ki.wVk = static_cast((begin + 1)->to_code()) ; + ins[1].ki.wVk = static_cast((begin + 1)->to_physical().to_code()) ; ins[1].ki.wScan = static_cast(MapVirtualKeyA(ins[1].ki.wVk, MAPVK_VK_TO_VSC)) ; ins[1].ki.dwFlags = extended_key_flag(ins[1].ki.wVk) ; ins[1].ki.dwExtraInfo = GetMessageExtraInfo() ; @@ -335,17 +335,17 @@ namespace vind #pragma gcc diagnostic warning "-wmissing-field-initializers" #endif - ins[0].ki.wVk = static_cast(begin->to_code()) ; + ins[0].ki.wVk = static_cast(begin->to_physical().to_code()) ; ins[0].ki.wScan = static_cast(MapVirtualKeyA(ins[0].ki.wVk, MAPVK_VK_TO_VSC)) ; ins[0].ki.dwFlags = extended_key_flag(*begin) ; ins[0].ki.dwExtraInfo = GetMessageExtraInfo() ; - ins[1].ki.wVk = static_cast((begin + 1)->to_code()) ; + ins[1].ki.wVk = static_cast((begin + 1)->to_physical().to_code()) ; ins[1].ki.wScan = static_cast(MapVirtualKeyA(ins[1].ki.wVk, MAPVK_VK_TO_VSC)) ; ins[1].ki.dwFlags = extended_key_flag(ins[1].ki.wVk) ; ins[1].ki.dwExtraInfo = GetMessageExtraInfo() ; - ins[2].ki.wVk = static_cast((begin + 2)->to_code()) ; + ins[2].ki.wVk = static_cast((begin + 2)->to_physical().to_code()) ; ins[2].ki.wScan = static_cast(MapVirtualKeyA(ins[2].ki.wVk, MAPVK_VK_TO_VSC)) ; ins[2].ki.dwFlags = extended_key_flag(ins[2].ki.wVk) ; ins[2].ki.dwExtraInfo = GetMessageExtraInfo() ; @@ -362,7 +362,7 @@ namespace vind default: { std::unique_ptr dins(new INPUT[size]) ; for(std::size_t i = 0 ; i < size ; i ++) { - dins[i].ki.wVk = static_cast((begin + i)->to_code()) ; + dins[i].ki.wVk = static_cast((begin + i)->to_physical().to_code()) ; dins[i].ki.wScan = static_cast(MapVirtualKeyA(dins[i].ki.wVk, MAPVK_VK_TO_VSC)) ; dins[i].ki.dwFlags = extended_key_flag(dins[i].ki.wVk) ; dins[i].ki.dwExtraInfo = GetMessageExtraInfo() ; @@ -428,8 +428,6 @@ namespace vind auto size = static_cast(end - begin) ; - open_some_ports(begin, end) ; - //optimizing for 1 switch(size) { case 1: { @@ -444,7 +442,8 @@ namespace vind #pragma gcc diagnostic warning "-wmissing-field-initializers" #endif - ins[0].ki.wVk = static_cast(begin->to_code()) ; + auto phy = begin->to_physical() ; + ins[0].ki.wVk = static_cast(phy.to_code()) ; ins[0].ki.wScan = static_cast(MapVirtualKeyA(ins[0].ki.wVk, MAPVK_VK_TO_VSC)) ; ins[0].ki.dwFlags = extended_key_flag(ins[0].ki.wVk) ; ins[0].ki.dwExtraInfo = GetMessageExtraInfo() ; @@ -454,6 +453,8 @@ namespace vind ins[1].ki.dwFlags = ins[0].ki.dwFlags | KEYEVENTF_KEYUP ; ins[1].ki.dwExtraInfo = GetMessageExtraInfo() ; + open_port(phy) ; + if(!SendInput(2, ins, sizeof(INPUT))) { throw RUNTIME_EXCEPT("failed sending keyboard event") ; } @@ -473,12 +474,14 @@ namespace vind #pragma gcc diagnostic warning "-wmissing-field-initializers" #endif - ins[0].ki.wVk = static_cast(begin->to_code()) ; + auto phy1 = begin->to_physical() ; + ins[0].ki.wVk = static_cast(phy1.to_code()) ; ins[0].ki.wScan = static_cast(MapVirtualKeyA(ins[0].ki.wVk, MAPVK_VK_TO_VSC)) ; ins[0].ki.dwFlags = extended_key_flag(ins[0].ki.wVk) ; ins[0].ki.dwExtraInfo = GetMessageExtraInfo() ; - ins[1].ki.wVk = static_cast((begin + 1)->to_code()) ; + auto phy2 = (begin + 1)->to_physical() ; + ins[1].ki.wVk = static_cast(phy2.to_code()) ; ins[1].ki.wScan = static_cast(MapVirtualKeyA(ins[1].ki.wVk, MAPVK_VK_TO_VSC)) ; ins[1].ki.dwFlags = extended_key_flag(ins[1].ki.wVk) ; ins[1].ki.dwExtraInfo = GetMessageExtraInfo() ; @@ -493,6 +496,9 @@ namespace vind ins[3].ki.dwFlags = ins[0].ki.dwFlags | KEYEVENTF_KEYUP ; ins[3].ki.dwExtraInfo = GetMessageExtraInfo() ; + open_port(phy1) ; + open_port(phy2) ; + if(!SendInput(4, ins, sizeof(INPUT))) { throw RUNTIME_EXCEPT("failed sending keyboard event") ; } @@ -513,17 +519,20 @@ namespace vind #if defined(__GNUC__) #pragma gcc diagnostic warning "-wmissing-field-initializers" #endif - ins[0].ki.wVk = static_cast(begin->to_code()) ; + auto phy1 = begin->to_physical() ; + ins[0].ki.wVk = static_cast(phy1.to_code()) ; ins[0].ki.wScan = static_cast(MapVirtualKeyA(ins[0].ki.wVk, MAPVK_VK_TO_VSC)) ; ins[0].ki.dwFlags = extended_key_flag(ins[0].ki.wVk) ; ins[0].ki.dwExtraInfo = GetMessageExtraInfo() ; - ins[1].ki.wVk = static_cast((begin + 1)->to_code()) ; + auto phy2 = (begin + 1)->to_physical() ; + ins[1].ki.wVk = static_cast(phy2.to_code()) ; ins[1].ki.wScan = static_cast(MapVirtualKeyA(ins[1].ki.wVk, MAPVK_VK_TO_VSC)) ; ins[1].ki.dwFlags = extended_key_flag(ins[1].ki.wVk) ; ins[1].ki.dwExtraInfo = GetMessageExtraInfo() ; - ins[2].ki.wVk = static_cast((begin + 2)->to_code()) ; + auto phy3 = (begin + 2)->to_physical() ; + ins[2].ki.wVk = static_cast(phy3.to_code()) ; ins[2].ki.wScan = static_cast(MapVirtualKeyA(ins[2].ki.wVk, MAPVK_VK_TO_VSC)) ; ins[2].ki.dwFlags = extended_key_flag(ins[2].ki.wVk) ; ins[2].ki.dwExtraInfo = GetMessageExtraInfo() ; @@ -543,6 +552,10 @@ namespace vind ins[5].ki.dwFlags = ins[0].ki.dwFlags | KEYEVENTF_KEYUP ; ins[5].ki.dwExtraInfo = GetMessageExtraInfo() ; + open_port(phy1) ; + open_port(phy2) ; + open_port(phy3) ; + if(!SendInput(6, ins, sizeof(INPUT))) { throw RUNTIME_EXCEPT("failed sending keyboard event") ; } @@ -552,7 +565,8 @@ namespace vind //>=4 std::unique_ptr dins(new INPUT[size * 2]) ; for(std::size_t i = 0 ; i < size ; i ++) { - dins[i].ki.wVk = static_cast((begin + i)->to_code()) ; + auto phy = (begin + 1)->to_physical() ; + dins[i].ki.wVk = static_cast(phy.to_code()) ; dins[i].ki.wScan = static_cast(MapVirtualKeyA(dins[i].ki.wVk, MAPVK_VK_TO_VSC)) ; dins[i].ki.dwFlags = extended_key_flag(dins[i].ki.wVk) ; dins[i].ki.dwExtraInfo = GetMessageExtraInfo() ; @@ -561,6 +575,8 @@ namespace vind dins[size - i - 1].ki.wScan = dins[i].ki.wScan ; dins[size - i - 1].ki.dwFlags = dins[i].ki.dwFlags | KEYEVENTF_KEYUP ; dins[size - i - 1].ki.dwExtraInfo = GetMessageExtraInfo() ; + + open_port(phy) ; } if(!SendInput(static_cast(size), dins.get(), sizeof(INPUT))) { @@ -612,24 +628,14 @@ namespace vind /** - * NOTE: This function samples a log from the log pool based on the key mapping - * instead of getting the key status obtained from the hook. + * NOTE: This function samples a log from the log pool based on + * the key mapping instead of getting the key status obtained + * from the hook. In the case of noremap, the key message is + * not actually generated, but in the case of map, the key + * message is generated in a state that is passed to Windows. */ KeyLog pop_log(Mode mode=get_global_mode()) ; - - /** - * NOTE: map_logger is a mapping from NTypeLogger to NTypeLogger. - * What it means is that it is excited by a command, and return the log pool. - * it would have been in if the corresponding command had been entered. - * - * In the case of noremap, the key message is not actually generated, - * but in the case of map, the key message is generated in a state that is passed to Windows. - */ - std::vector map_logger( - const KeyLog& log, - Mode mode=get_global_mode()) ; - /** * A gate uses to synchronize the state of a key at low-level * with mapped to the hook_key. It return ture if the map was done, diff --git a/src/core/syscalldef.hpp b/src/core/syscalldef.hpp index 227528f1..e0aed43c 100644 --- a/src/core/syscalldef.hpp +++ b/src/core/syscalldef.hpp @@ -6,7 +6,7 @@ namespace vind enum class SystemCall : unsigned char { NOTHING = 0b0000'0000, TERMINATE = 0b0000'0001, - RECONSTRUCT = 0b0000'0010 + RECONSTRUCT = 0b0000'0010, } ; } diff --git a/src/core/version.hpp b/src/core/version.hpp index 72be77e7..422058d7 100644 --- a/src/core/version.hpp +++ b/src/core/version.hpp @@ -1,6 +1,6 @@ #ifndef _VERSION_HPP #define _VERSION_HPP -#define WIN_VIND_VERSION "4.3.0" +#define WIN_VIND_VERSION "4.3.1" #endif diff --git a/tests/each/inputgate_test.cpp b/tests/each/inputgate_test.cpp index 99cb0dbd..01a4bfff 100644 --- a/tests/each/inputgate_test.cpp +++ b/tests/each/inputgate_test.cpp @@ -128,13 +128,13 @@ TEST_CASE("inputgate::solve_recursive_cmd2cmd_mapping") { // gh -> zgyg Command expect1 { {KEYCODE_Z}, - {KEYCODE_LSHIFT, KEYCODE_LCTRL, KEYCODE_Z}, - {KEYCODE_LSHIFT, KEYCODE_Z}, - {KEYCODE_LSHIFT, KEYCODE_Z}, + {KEYCODE_SHIFT, KEYCODE_CTRL, KEYCODE_Z}, + {KEYCODE_SHIFT, KEYCODE_Z}, + {KEYCODE_SHIFT, KEYCODE_Z}, {KEYCODE_G}, {KEYCODE_Y}, - {KEYCODE_LSHIFT, KEYCODE_Z}, - {KEYCODE_LSHIFT, KEYCODE_Z}, + {KEYCODE_SHIFT, KEYCODE_Z}, + {KEYCODE_SHIFT, KEYCODE_Z}, {KEYCODE_G} } ; CHECK_EQ(result[map1.in_hash()], expect1) ; @@ -142,17 +142,17 @@ TEST_CASE("inputgate::solve_recursive_cmd2cmd_mapping") { // t -> zg Command expect2 { {KEYCODE_Z}, - {KEYCODE_LSHIFT, KEYCODE_LCTRL, KEYCODE_Z}, - {KEYCODE_LSHIFT, KEYCODE_Z}, - {KEYCODE_LSHIFT, KEYCODE_Z}, + {KEYCODE_SHIFT, KEYCODE_CTRL, KEYCODE_Z}, + {KEYCODE_SHIFT, KEYCODE_Z}, + {KEYCODE_SHIFT, KEYCODE_Z}, {KEYCODE_G} } ; CHECK_EQ(result[map2.in_hash()], expect2) ; // -> g Command expect3 { - {KEYCODE_LSHIFT, KEYCODE_Z}, - {KEYCODE_LSHIFT, KEYCODE_Z}, + {KEYCODE_SHIFT, KEYCODE_Z}, + {KEYCODE_SHIFT, KEYCODE_Z}, {KEYCODE_G} } ; CHECK_EQ(result[map3.in_hash()], expect3) ;