From cea367c529bd8400a44fab3f580d43120457e1b9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 23 May 2017 23:03:45 +0300 Subject: Add chat command for send any number of pritable chars to input. --- src/actions/chat.cpp | 19 +++++++++++++++++++ src/actions/chat.h | 1 + src/dyetool/actions/chat.cpp | 1 + src/enums/input/inputaction.h | 1 + src/input/inputactionmap.h | 6 ++++++ 5 files changed, 28 insertions(+) diff --git a/src/actions/chat.cpp b/src/actions/chat.cpp index d8743e06a..4f69b31b8 100644 --- a/src/actions/chat.cpp +++ b/src/actions/chat.cpp @@ -780,4 +780,23 @@ impHandler(sendMouseKey) return true; } +impHandler(sendChars) +{ + if (!guiInput) + return false; + + const std::string args = event.args; + if (args.empty()) + return false; + + const size_t sz = args.size(); + for (size_t f = 0; f < sz; f ++) + { + guiInput->simulateKey(CAST_S32(args[f]), + InputAction::NO_VALUE); + } + + return true; +} + } // namespace Actions diff --git a/src/actions/chat.h b/src/actions/chat.h index 5d4f1c02d..0e3c362a7 100644 --- a/src/actions/chat.h +++ b/src/actions/chat.h @@ -64,6 +64,7 @@ namespace Actions decHandler(translate); decHandler(sendGuiKey); decHandler(sendMouseKey); + decHandler(sendChars); } // namespace Actions #undef decHandler diff --git a/src/dyetool/actions/chat.cpp b/src/dyetool/actions/chat.cpp index bf57c1c49..ece0e42b9 100644 --- a/src/dyetool/actions/chat.cpp +++ b/src/dyetool/actions/chat.cpp @@ -64,5 +64,6 @@ impHandlerVoid(guildNotice) impHandlerVoid(translate) impHandlerVoid(sendGuiKey) impHandlerVoid(sendMouseKey) +impHandlerVoid(sendChars) } // namespace Actions diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h index 9b1d2e99a..f838bf092 100644 --- a/src/enums/input/inputaction.h +++ b/src/enums/input/inputaction.h @@ -694,6 +694,7 @@ enumStart(InputAction) MOVE_PRIORITY_ATTACK_DOWN, SHOW_ITEMS, COMMAND_SEND_MOUSE_KEY, + COMMAND_SEND_CHARS, TOTAL } enumEnd(InputAction); diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index bc18cd7a4..b49b36904 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -5654,6 +5654,12 @@ static const InputActionData inputActionData "mousekey|sendmousekey", UseArgs_true, Protected_true}, + {"keyCommandSendChars", + defaultAction(&Actions::sendChars), + InputCondition::ENABLED, + "sendchar|sendchars|charsend", + UseArgs_true, + Protected_true}, }; #undef defaultAction -- cgit v1.2.3-60-g2f50