diff options
Diffstat (limited to 'src/actions')
-rw-r--r-- | src/actions/chat.cpp | 37 | ||||
-rw-r--r-- | src/actions/chat.h | 1 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/actions/chat.cpp b/src/actions/chat.cpp index 6e6f3cae1..266f610b8 100644 --- a/src/actions/chat.cpp +++ b/src/actions/chat.cpp @@ -28,6 +28,8 @@ #include "being/localplayer.h" +#include "gui/sdlinput.h" + #include "gui/windows/chatwindow.h" #include "listeners/inputactionreplaylistener.h" @@ -48,6 +50,7 @@ #include "utils/booleanoptions.h" #include "utils/chatutils.h" +#include "utils/parameters.h" #include "utils/translation/podict.h" @@ -716,4 +719,38 @@ impHandler(translate) return true; } +impHandler0(sendGuiKey) +{ + if (!guiInput) + return false; + + const std::string args = event.args; + if (args.empty()) + return false; + StringVect pars; + if (!splitParameters(pars, args, " ,", '\"')) + return false; + const int sz = CAST_S32(pars.size()); + if (sz < 1) + return false; + + int keyValue = atoi(pars[0].c_str()); + if (keyValue == 0 && + pars[0].size() == 1) + { + keyValue = CAST_S32(pars[0][0]); + } + if (sz == 2) + { + const InputActionT actionId = inputManager.getActionByConfigField( + pars[1]); + guiInput->simulateKey(keyValue, actionId); + } + else + { + guiInput->simulateKey(keyValue, InputAction::NO_VALUE); + } + return true; +} + } // namespace Actions diff --git a/src/actions/chat.h b/src/actions/chat.h index ba33806a3..3815e53e7 100644 --- a/src/actions/chat.h +++ b/src/actions/chat.h @@ -62,6 +62,7 @@ namespace Actions decHandler(chatClipboard); decHandler(guildNotice); decHandler(translate); + decHandler(sendGuiKey); } // namespace Actions #undef decHandler |