From a62ea11553271db94e5eca67899c8477a42ab9cc Mon Sep 17 00:00:00 2001 From: Arthur <121949966+ShinyWasabi@users.noreply.github.com> Date: Thu, 5 Sep 2024 21:02:40 +0300 Subject: [PATCH] Disable CMD executor if in-game keyboard is active (#3656) --- src/function_types.hpp | 2 ++ src/gta/enums.hpp | 8 ++++++++ src/gta_pointers.hpp | 2 ++ src/pointers.cpp | 9 +++++++++ src/views/core/view_cmd_executor.cpp | 2 +- 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/function_types.hpp b/src/function_types.hpp index e628f7d8..c199f11f 100644 --- a/src/function_types.hpp +++ b/src/function_types.hpp @@ -228,4 +228,6 @@ namespace big::functions using is_ped_enemies_with = bool (*)(CPedIntelligence* from, CPed* target, bool check_relationship, bool skip_friend_check, bool skip_combat_task_check); using can_do_damage_to_ped = bool (*)(CPed* from, CWeaponInfo* current_weapon, CPed* target); + + using get_last_keyboard_state = KeyboardState (*)(); } diff --git a/src/gta/enums.hpp b/src/gta/enums.hpp index 03251322..62b02591 100644 --- a/src/gta/enums.hpp +++ b/src/gta/enums.hpp @@ -2806,4 +2806,12 @@ enum HudColors : int //https://docs.fivem.net/docs/game-references/hud-colors/ HUD_COLOUR_PLACEHOLDER_09, HUD_COLOUR_PLACEHOLDER_10, HUD_COLOUR_JUNK_ENERGY +}; + +enum KeyboardState : int32_t +{ + INVALID = -1, + ACTIVE, + COMPLETED, + CANCELED }; \ No newline at end of file diff --git a/src/gta_pointers.hpp b/src/gta_pointers.hpp index 9bc1a973..bb872770 100644 --- a/src/gta_pointers.hpp +++ b/src/gta_pointers.hpp @@ -415,6 +415,8 @@ namespace big bool* m_allow_keyboard_layout_change; InputMethodEditor* m_ime; + + functions::get_last_keyboard_state m_get_last_keyboard_state; }; #pragma pack(pop) static_assert(sizeof(gta_pointers) % 8 == 0, "Pointers are not properly aligned"); diff --git a/src/pointers.cpp b/src/pointers.cpp index e141a4dd..85f68ca8 100644 --- a/src/pointers.cpp +++ b/src/pointers.cpp @@ -1968,6 +1968,15 @@ namespace big g_pointers->m_gta.m_allow_keyboard_layout_change = ptr.sub(4).rip().as(); g_pointers->m_gta.m_ime = ptr.add(44).rip().sub(0x278 + 0x8).as(); } + }, + // Get Last Keyboard State + { + "GLKS", + "33 C9 38 0D ? ? ? ? 74 ? 8B 05 ? ? ? ? 38 0D", + [](memory::handle ptr) + { + g_pointers->m_gta.m_get_last_keyboard_state = ptr.as(); + } } >(); // don't leave a trailing comma at the end diff --git a/src/views/core/view_cmd_executor.cpp b/src/views/core/view_cmd_executor.cpp index 7c60755d..a45e49e5 100644 --- a/src/views/core/view_cmd_executor.cpp +++ b/src/views/core/view_cmd_executor.cpp @@ -579,7 +579,7 @@ namespace big void view::cmd_executor() { - if (!g.cmd_executor.enabled) + if (!g.cmd_executor.enabled || g_pointers->m_gta.m_get_last_keyboard_state() == KeyboardState::ACTIVE) return; float screen_x = (float)*g_pointers->m_gta.m_resolution_x;